Skip to content

Commit 4d2e6c1

Browse files
Update pull request CI to produce markdown summary (#6063)
1 parent 17ed902 commit 4d2e6c1

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

.github/workflows/test.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
on:
55
workflow_call:
66
workflow_dispatch:
7+
8+
9+
permissions:
10+
contents: read
11+
712
jobs:
813
test:
914
name: Unit testing
@@ -19,11 +24,18 @@ jobs:
1924
go-version-file: 'go.mod'
2025
- name: Set up helm (test dependency)
2126
uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4.3.1
22-
# Install gotestfmt on the VM running the action.
27+
# Install gotestfmt and go-junit-report on the VM running the action.
2328
- name: Set up gotestfmt
2429
uses: GoTestTools/gotestfmt-action@8b4478c7019be847373babde9300210e7de34bfb # v2.2.0
2530
with:
2631
token: ${{ secrets.GITHUB_TOKEN }}
32+
- name: Install go-junit-report
33+
run: |
34+
ARCH=$(echo "${{ runner.arch }}" | tr '[:upper:]' '[:lower:]' | sed 's/x64/amd64/')
35+
OS=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]' | sed 's/macos/darwin/')
36+
gh release download -R gotestyourself/gotestsum -p "gotestsum_1.13.0_${OS}_${ARCH}.tar.gz" -O - | tar -xzf - gotestsum
37+
env:
38+
GITHUB_TOKEN: ${{ github.token }}
2739
# copy config file into place
2840
- name: Copy config file
2941
run: cp config/server-config.yaml.example ./server-config.yaml
@@ -40,10 +52,22 @@ jobs:
4052
env:
4153
MINDER_TEST_REGISTRY: "localhost:5000"
4254
run: make test-cover-silent
43-
- name: Try converting to LCOV
55+
- name: Generate JUnit report
56+
run: |
57+
gotestsum --junitfile test-results.xml --junitfile-hide-empty-pkg --raw-command -- cat test-results.json
58+
- name: Upload test results
59+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
60+
with:
61+
name: test-results
62+
path: test-results.*
63+
- name: Convert go coverage to LCOV
4464
run: go run github.com/jandelgado/gcov2lcov@latest -infile=./coverage.out -outfile=./coverage.lcov
4565
- name: Coveralls GitHub Action
4666
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7
67+
- name: Add top-level report from JUnit XML
68+
if: ${{ !cancelled() }}
69+
run: |
70+
go run github.com/kitproj/[email protected] < test-results.xml > "$GITHUB_STEP_SUMMARY"
4771
authz:
4872
name: Authz tests
4973
runs-on: ubuntu-latest

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,6 @@ tuf-repo-cdn.sigstore.dev.json
6969

7070
# Offline tokens from minder CLI
7171
offline.token
72+
73+
# Test result files
74+
test-results.*

.mk/test.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ cover: init-examples ## display test coverage
2828

2929
.PHONY: test-cover-silent
3030
test-cover-silent: clean init-examples ## Run test coverage in a silent mode (errors only output)
31-
go test -json -race -v -coverpkg=${COVERAGE_PACKAGES} -coverprofile=coverage.out.tmp ./... | gotestfmt -hide "all"
31+
go test -json -race -v -coverpkg=${COVERAGE_PACKAGES} -coverprofile=coverage.out.tmp ./... 2>&1 | tee test-results.json | gotestfmt -hide "all"
32+
3233
cat coverage.out.tmp | grep -v ${COVERAGE_EXCLUSIONS} > coverage.out
3334
rm coverage.out.tmp
3435
go tool cover -func=coverage.out

0 commit comments

Comments
 (0)