Skip to content

Commit de7f5fd

Browse files
committed
Fix GitHub Actions test reporter configuration
- Install go-junit-report to convert Go test output to JUnit XML - Change reporter from 'go-test' (invalid) to 'java-junit' (supported) - Update test results file from JSON to XML format - Update test results check to parse XML instead of JSON
1 parent 1579f43 commit de7f5fd

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

.github/workflows/test.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ jobs:
2727
- name: Download dependencies
2828
run: go mod download
2929

30+
- name: Install go-junit-report
31+
run: go install github.com/jstemmer/go-junit-report/v2@latest
32+
3033
- name: Run tests with coverage
3134
run: |
32-
go test ./... -v -race -coverprofile=coverage.out -covermode=atomic -json > test-results.json || true
35+
go test ./... -v -race -coverprofile=coverage.out -covermode=atomic 2>&1 | tee test-output.txt || true
36+
cat test-output.txt | go-junit-report -set-exit-code > test-results.xml
3337
3438
- name: Generate coverage report
3539
run: |
@@ -48,8 +52,8 @@ jobs:
4852
if: always()
4953
with:
5054
name: Go Test Results
51-
path: test-results.json
52-
reporter: 'go-test'
55+
path: test-results.xml
56+
reporter: 'java-junit'
5357
fail-on-error: true
5458
fail-on-empty: true
5559

@@ -61,7 +65,7 @@ jobs:
6165

6266
- name: Check test results
6367
run: |
64-
if grep -q '"Action":"fail"' test-results.json; then
68+
if grep -q 'failures="[1-9]' test-results.xml || grep -q 'errors="[1-9]' test-results.xml; then
6569
echo "Some tests failed"
6670
exit 1
6771
else

0 commit comments

Comments
 (0)