Setup for L0 Testcases (#8)
* Setup for L0 Testcases * Issue Fix * Issue Fix * Review fix * Review fix * Review fix * Review fix * Review fix * Review fix * Review fix * Review fix * Review fix * Review fix * Install dependencies in all runs * To get review on the approach of installing only dev-dep in case of releases * Removed npm build, using just install
This commit is contained in:
parent
8405e87dd0
commit
41bde4ee53
80
.github/workflows/test.yml
vendored
Normal file
80
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- 'releases/*'
|
||||
|
||||
jobs:
|
||||
build_test_job:
|
||||
name: 'Build and test job'
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest, ubuntu-latest, macos-latest]
|
||||
steps:
|
||||
|
||||
- name: 'Checking out repo code'
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Extract branch name
|
||||
id: extract_branch
|
||||
run: |
|
||||
echo "##[set-output name=branchname;]$(echo ${GITHUB_REF##*/})"
|
||||
|
||||
- name: 'Install dependency for master'
|
||||
if: github.event.pull_request.base.ref == 'master' || steps.extract_branch.outputs.branchname == 'master'
|
||||
run: |
|
||||
npm install
|
||||
|
||||
- name: 'Install dependency for releases'
|
||||
if: github.event.pull_request.base.ref == 'releases/v1' || steps.extract_branch.outputs.branchname == 'releases/v1'
|
||||
run: |
|
||||
npm install --only=dev
|
||||
|
||||
- name: 'Run L0 tests'
|
||||
run: |
|
||||
npm run test
|
||||
- name : 'Run test coverage'
|
||||
if: runner.os == 'Windows'
|
||||
env:
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
$coverage_result = npm run test-coverage
|
||||
$start = $false;
|
||||
$middle = $false;
|
||||
$end = $false;
|
||||
$count = 0;
|
||||
|
||||
foreach ($j in $coverage_result)
|
||||
{
|
||||
if ($j.tostring().startswith("----------"))
|
||||
{
|
||||
if (!$start)
|
||||
{
|
||||
$start = $true;
|
||||
$start_index = $count
|
||||
}
|
||||
elseif (!$middle)
|
||||
{
|
||||
$middle = $true;
|
||||
}
|
||||
elseif (!$end)
|
||||
{
|
||||
$end = $true;
|
||||
$end_index = $count
|
||||
}
|
||||
}
|
||||
$count++
|
||||
}
|
||||
|
||||
$tbl_md = $coverage_result[($start_index+1)..($end_index-1)] -join "\n"
|
||||
$summary = $coverage_result[($end_index + 1)..$count] -join "\n"
|
||||
$comment = $tbl_md + "\n" + $summary
|
||||
$url = "https://api.github.com/repos/${env:GITHUB_REPOSITORY}/issues/${env:PR_NUMBER}/comments"
|
||||
$headers = @{
|
||||
"Authorization" = "token ${env:GITHUB_TOKEN}"
|
||||
}
|
||||
$body = "{ `"body`": `"${comment}`" }"
|
||||
Invoke-RestMethod -Method POST -Uri $url -Headers $headers -Body $body
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -327,3 +327,4 @@ ASALocalRun/
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
node_modules
|
||||
|
7
__tests__/run.test.ts
Normal file
7
__tests__/run.test.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { run } from '../src/login'
|
||||
|
||||
describe('This is a placeholder for intial test cases, to be removed', () => {
|
||||
test('Dummy test case', async () => {
|
||||
await expect(run()).rejects.toThrow();
|
||||
})
|
||||
})
|
18
jest.config.js
Normal file
18
jest.config.js
Normal file
@ -0,0 +1,18 @@
|
||||
module.exports = {
|
||||
clearMocks: true,
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest'
|
||||
},
|
||||
verbose: true,
|
||||
coverageThreshold: {
|
||||
"global": {
|
||||
"branches": 0,
|
||||
"functions": 40,
|
||||
"lines": 22,
|
||||
"statements": 22
|
||||
}
|
||||
}
|
||||
}
|
@ -115,4 +115,5 @@ function run() {
|
||||
yield setContext();
|
||||
});
|
||||
}
|
||||
exports.run = run;
|
||||
run().catch(core.setFailed);
|
||||
|
@ -4,7 +4,9 @@
|
||||
"private": true,
|
||||
"main": "lib/run.js",
|
||||
"scripts": {
|
||||
"build": "tsc --outDir .\\lib\\ --rootDir .\\src\\"
|
||||
"build": "tsc --outDir .\\lib\\ --rootDir .\\src\\",
|
||||
"test": "jest",
|
||||
"test-coverage": "jest --coverage"
|
||||
},
|
||||
"keywords": [
|
||||
"actions",
|
||||
@ -21,6 +23,9 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.0.4",
|
||||
"typescript": "^3.5.2"
|
||||
"typescript": "3.9.2",
|
||||
"jest": "^26.0.1",
|
||||
"@types/jest": "^25.2.2",
|
||||
"ts-jest": "^25.5.1"
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ async function setContext() {
|
||||
}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
export async function run() {
|
||||
let kubeconfig = getKubeconfig();
|
||||
const runnerTempDirectory = process.env['RUNNER_TEMP']; // Using process.env until the core libs are updated
|
||||
const kubeconfigPath = path.join(runnerTempDirectory, `kubeconfig_${Date.now()}`);
|
||||
|
@ -4,6 +4,7 @@
|
||||
"module": "commonjs"
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
"node_modules",
|
||||
"__tests__"
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user