35
35
matrix :
36
36
shard : [ 1, 2, 3, 4, 5, 6, 7, 8 ]
37
37
fail-fast : false
38
- outputs :
39
- jest_outcome : ${{ steps.output_variables.outputs.jest_outcome }}
40
- coverage_line : ${{ steps.output_variables.outputs.coverage_line }}
41
- coverage_statement : ${{ steps.output_variables.outputs.coverage_statement }}
42
- coverage_branch : ${{ steps.output_variables.outputs.coverage_branch }}
43
- coverage_function : ${{ steps.output_variables.outputs.coverage_function }}
44
38
steps :
45
39
- uses : actions/checkout@v4
46
40
- name : Use Node.js 20.11.1
@@ -57,30 +51,11 @@ jobs:
57
51
env :
58
52
NODE_OPTIONS : " --max-old-space-size=10240"
59
53
- name : jest
60
- id : jest
61
54
run : |
62
55
export NODE_OPTIONS="--max-old-space-size=8192"
63
- NODE_OPTIONS=--max-old-space-size=8192 node --max-old-space-size=8192 ./node_modules/.bin/jest --no-watchman --silent --logHeapUsage --bail --runInBand --forceExit --shard=${{ matrix.shard }}/${{ strategy.job-total }} --coverage
64
- if [ $exit_code -ne 0 ]; then
65
- echo "Some tests failed. Exiting with status code $exit_code"
66
- exit $exit_code
67
- fi
56
+ NODE_OPTIONS=--max-old-space-size=8192 node --max-old-space-size=8192 ./node_modules/.bin/jest --no-watchman --silent --logHeapUsage --runInBand --forceExit --shard=${{ matrix.shard }}/${{ strategy.job-total }} --coverage
68
57
env :
69
58
NODE_OPTIONS : " --max-old-space-size=10240"
70
- - name : Set output variables for badges
71
- id : output_variables
72
- run : |
73
- jest_outcome=${{ steps.jest.outcome }}
74
- echo "jest_outcome=$jest_outcome" >> $GITHUB_OUTPUT
75
- echo "Output of my_step: ${{ steps.jest.outcome }}"
76
- coverage_line=$(jq -r '.total.lines.pct' coverage/coverage-summary.json)
77
- coverage_statement=$(jq -r '.total.statements.pct' coverage/coverage-summary.json)
78
- coverage_branch=$(jq -r '.total.branches.pct' coverage/coverage-summary.json)
79
- coverage_function=$(jq -r '.total.functions.pct' coverage/coverage-summary.json)
80
- echo "coverage_line=$coverage_line" >> $GITHUB_OUTPUT
81
- echo "coverage_statement=$coverage_statement" >> $GITHUB_OUTPUT
82
- echo "coverage_branch=$coverage_branch" >> $GITHUB_OUTPUT
83
- echo "coverage_function=$coverage_function" >> $GITHUB_OUTPUT
84
59
- name : Rename coverage file name
85
60
if : github.ref == 'refs/heads/main'
86
61
run : mv coverage/coverage-final.json coverage/${{matrix.shard}}.json
90
65
with :
91
66
name : coverage-artifacts
92
67
path : coverage/
93
- create-badges :
94
- runs-on : ubuntu-latest
95
- if : ${{ always() }}
96
- needs : build
97
- steps :
98
- - name : Create Test Cases Status Badges
99
- uses :
peterrhodesdev/[email protected]
100
- with :
101
- token : ${{ secrets.GITHUB_TOKEN }}
102
- filename : testcases_status
103
- label : Test cases status
104
- message : ${{ needs.build.outputs.jest_outcome }}
105
- color : ${{ needs.build.outputs.jest_outcome == 'success' && '009900' || 'FF0000' }}
106
- - name : Create Test Cases Coverage Badges
107
- uses :
peterrhodesdev/[email protected]
108
- with :
109
- token : ${{ secrets.GITHUB_TOKEN }}
110
- filename : ("testcases_coverage_line" "testcases_coverage_statement" "testcases_coverage_branch" "testcases_coverage_function")
111
- label : ("Test cases coverage [Line]" "Test cases coverage [Statement]" "Test cases coverage [Branch]" "Test cases coverage [Function]")
112
- message : (${{ needs.build.outputs.coverage_line }} ${{ needs.build.outputs.coverage_statement }} ${{ needs.build.outputs.coverage_branch }} ${{ needs.build.outputs.coverage_function }})
113
- color : 993366
0 commit comments