@@ -16,12 +16,14 @@ jobs:
16
16
- run : npm install
17
17
- id : set-test-chunks
18
18
name : Set Chunks
19
+ # Extracts the list of all test files, then uses js to split them into groups to allocate to each worker. The JSON is sent to the job output
19
20
run :
20
21
echo "test-chunks=$(npx jest -c test/e2e/jest.config.js --listTests --json | jq -cM '[_nwise(length / 24 |
21
22
floor)]')" >> $GITHUB_OUTPUT
22
23
23
24
- id : set-test-chunk-ids
24
25
name : Set Chunk IDs
26
+ # Extracts the chunk IDs from the JSON output and sends them to the job output. These will just be a sequence of array indices
25
27
run : echo "test-chunk-ids=$(echo $CHUNKS | jq -cM 'to_entries | map(.key)')" >> $GITHUB_OUTPUT
26
28
env :
27
29
CHUNKS : ${{ steps['set-test-chunks'].outputs['test-chunks'] }}
33
35
strategy :
34
36
fail-fast : false
35
37
matrix :
38
+ # Creates a job for each chunk ID. This will be assinged one or more test files to run
36
39
chunk : ${{ fromJson(needs.setup.outputs['test-chunk-ids']) }}
37
40
steps :
38
41
- uses : actions/checkout@v3
44
47
check-latest : true
45
48
- name : Run tests
46
49
run :
50
+ # Gets the list of test files for the current chunk ID and runs them, saving the results as a JUnit XML file
47
51
echo $CHUNKS | jq '.[${{ matrix.chunk }}] | .[] | @text' | xargs npx jest --reporters=jest-junit
48
52
--reporters=default -c test/e2e/jest.config.js
49
53
env :
53
57
- uses : phoenix-actions/test-reporting@v10
54
58
if : ${{ always() }}
55
59
name : Report Test Results
60
+ # Generates annotations for the test failures
56
61
id : test-report
57
62
with :
58
63
name : E2E Test chunk ${{ matrix.chunk }}
61
66
max-annotations : 49 # Maximum number of annotations to be created
62
67
reporter : jest-junit # Format of test results
63
68
64
- - uses : actions/upload-artifact@v3 # upload test results
69
+ - uses : actions/upload-artifact@v3
70
+ # upload test results
65
71
if : ${{ always() }}
66
72
with :
67
73
name : test-results-${{ matrix.chunk }}
@@ -78,10 +84,12 @@ jobs:
78
84
path : reports
79
85
- name : Combine reports
80
86
run : npx junit-report-merger combined.xml reports/**/*.xml
87
+ # The test reporter can handle multiple files, but these are arbitrary chunks and combining them gives more useful results
81
88
- uses : phoenix-actions/test-reporting@v10
82
89
with :
83
90
name : Jest Tests
84
91
output-to : ' step-summary'
85
92
path : ' combined.xml'
86
- max-annotations : 0 # Annotations were done in the test steps
93
+ # Annotations were done in the test steps. This is just the summary
94
+ max-annotations : 0
87
95
reporter : jest-junit
0 commit comments