11# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
22# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+ # Tests are executed and coverage reports are emitted as to the action summary
4+ # A dependent workflow which uses workflow_run as a trigger reads the archived outputs and emits comments to the PR triggering this build
35
46name : Build pr
57
@@ -13,32 +15,53 @@ jobs:
1315
1416 strategy :
1517 matrix :
16- node-version : [14 .x]
18+ node-version : [16 .x]
1719
1820 steps :
1921 - uses : actions/checkout@v2
2022 - name : Use Node.js ${{ matrix.node-version }}
2123 uses : actions/setup-node@v1
2224 with :
2325 node-version : ${{ matrix.node-version }}
24- - run : npm install -g yarn
25- - run : yarn
26+ - name : Cache Node Modules
27+ id : cache-node-modules
28+ uses : actions/cache@v2
29+ with :
30+ path : |
31+ node_modules
32+ */*/node_modules
33+ key : ${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
34+ - run : npm install -g yarn lerna
35+ - name : Install node_modules
36+ if : steps.cache-node-modules.outputs.cache-hit != 'true'
37+ run : yarn
2638 - run : node scripts/setVersion.js --next
27- - run : yarn run tsc -v
2839 - run : yarn build
29- - run : yarn run pack
30-
31- - name : Upload a Build Artifact - package
32- uses : actions/upload-artifact@v2
40+ - run : yarn lint
41+ - run : yarn test
42+ - name : Archive test results
43+ uses : actions/upload-artifact@v2 # upload test results
44+ if : always() # run this step even if previous step failed
3345 with :
34- name : npm-packages
35- path : artifacts/*
46+ name : test-results
47+ path : testResults/junit.xml
48+ - name : Archive coverage report
49+ uses : actions/upload-artifact@v2 # upload coverage report
50+ if : always() # run this step even if previous step failed
51+ with :
52+ name : coverage
53+ path : coverage/cobertura-coverage.xml
3654
37- - name : Upload a Build Artifact - bundle
38- uses : actions/upload-artifact@v2
55+ - name : Code Coverage Summary Report
56+ 3957 with :
40- name : bundle
41- path : packages/mgt/dist/bundle
58+ filename : coverage/cobertura-coverage.xml
59+ badge : true
60+ format : ' markdown'
61+ output : ' both'
62+
63+ - name : Write to Job Summary
64+ run : cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
4265
4366 # The check-build-matrix returns success if all matrix jobs in build are successful; otherwise, it returns a failure.
4467 # Use this as a PR status check for GitHub Policy Service instead of individual matrix entry checks.
4770 needs : build
4871 if : always()
4972 steps :
50- - name : All build matrix options are successful
73+ - name : All build matrix options are successful
5174 if : ${{ !(contains(needs.*.result, 'failure')) }}
5275 run : exit 0
5376 - name : One or more build matrix options failed
0 commit comments