feat: publish html report and test summary from gotest
galargh committed
Mar 11, 2023 at 11:00 UTC
92743b1bf5cb7185495b62c7e7d1b53845ae01c0
1 file changed
+45
-9
.github/workflows/gotest.yml
+45
-9
@@ -23,22 +23,28 @@ jobs:
23
run:
24
shell: bash
25
steps:
26
- - uses: actions/setup-go@v3
26
+ - name: Set up Go
27
+ uses: actions/setup-go@v3
28
with:
29
go-version: 1.19.1
29
- - uses: actions/checkout@v3
30
- - uses: protocol/cache-go-action@v1
30
+ - name: Check out Kubo
31
+ uses: actions/checkout@v3
32
+ - name: Restore Go cache
33
+ uses: protocol/cache-go-action@v1
34
with:
35
name: ${{ github.job }}
33
- - run: |
36
+ - name: 👉️ If this step failed, go to «Summary» (top left) → inspect the «Failures/Errors» table
37
+ run: |
38
make -j 1 test/unit/gotest.junit.xml &&
39
[[ ! $(jq -s -c 'map(select(.Action == "fail")) | .[]' test/unit/gotest.json) ]]
36
- - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
37
- if: always()
40
+ - name: Upload coverage to Codecov
41
+ uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
42
+ if: failure() || success()
43
with:
44
name: unittests
45
files: coverage/unit_tests.coverprofile
41
- - run: |
46
+ - name: Test kubo-as-a-library example
47
+ run: |
48
# we want to first test with the kubo version in the go.mod file
49
go test -v ./...
50
@@ -59,8 +65,38 @@ jobs:
65
mv go.mod.bak go.mod
66
mv go.sum.bak go.sum
67
working-directory: docs/examples/kubo-as-a-library
62
- - uses: actions/upload-artifact@v3
68
+ - name: Create a proper JUnit XML report
69
+ uses: pl-strflt/gotest-json-to-junit-xml@v1
70
+ with:
71
+ input: test/unit/gotest.json
72
+ output: test/unit/gotest.junit.xml
73
+ if: failure() || success()
74
+ - name: Archive the JUnit XML report
75
+ uses: actions/upload-artifact@v3
76
with:
77
name: unit
78
path: test/unit/gotest.junit.xml
66
- if: always()
79
+ if: failure() || success()
80
+ - name: Create a HTML report
81
+ uses: pl-strflt/junit-xml-to-html@v1
82
+ with:
83
+ mode: no-frames
84
+ input: test/unit/gotest.junit.xml
85
+ output: test/unit/gotest.html
86
+ if: failure() || success()
87
+ - name: Archive the HTML report
88
+ uses: actions/upload-artifact@v3
89
+ with:
90
+ name: html
91
+ path: test/unit/gotest.html
92
+ if: failure() || success()
93
+ - name: Create a Markdown report
94
+ uses: pl-strflt/junit-xml-to-html@v1
95
+ with:
96
+ mode: summary
97
+ input: test/unit/gotest.junit.xml
98
+ output: test/unit/gotest.md
99
+ if: failure() || success()
100
+ - name: Set the summary
101
+ run: cat test/unit/gotest.md >> $GITHUB_STEP_SUMMARY
102
+ if: failure() || success()