-
Notifications
You must be signed in to change notification settings - Fork 1.2k
103 lines (103 loc) · 3.93 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Test
on:
push:
branches:
- master
pull_request:
types: [ opened, synchronize ]
env:
GOTOOLCHAIN: local
# When a new revision is pushed to a PR, cancel all in-progress CI runs for that
# PR. See https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
# Required: allow read access to the content for analysis.
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read
# Optional: allow write access to checks to allow the action to annotate code in the PR.
checks: write
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
go: ["1.22", "1.23"]
runs-on: ${{ matrix.os }}
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
# Install gotestsum on the VM running the action.
- name: Setup gotestsum
run: go install gotest.tools/gotestsum@latest
- name: Core tests
shell: bash
run: |
set -euo pipefail
go mod download
gotestsum --jsonfile go_test.json --junitfile report.xml --format-icons=hivis --format=pkgname-and-test-fails -- -race ./... -trimpath
- name: Example tests
shell: bash
if: success() || failure() # always run even if the previous step fails
run: |
cd _examples
go mod download
gotestsum --junitfile ../go_examples_report.xml --format-icons=hivis --format=pkgname-and-test-fails -- -race ./... -trimpath
- name: Upload Test Report
uses: actions/upload-artifact@v4.4.3
if: always() # always run even if the previous step fails
with:
name: test-junit-${{ matrix.os }}-${{ matrix.go }}
path: '*.xml'
retention-days: 1
- name: action-junit-report
shell: bash
if: success() || failure() # always run even if the previous step fails
run: |
echo "### mikepenz/action-junit-report! :rocket:" >> $GITHUB_STEP_SUMMARY
- name: Publish Test Report
uses: mikepenz/action-junit-report@v5
if: success() || failure() # always run even if the previous step fails
with:
report_paths: |
report.xml
go_examples_report.xml
- name: robherley/go-test-action announcement
shell: bash
if: success() || failure() # always run even if the previous step fails
run: |
echo "### robherley/go-test-action! :rocket:" >> $GITHUB_STEP_SUMMARY
# - name: Annotate tests does not work on pull-requests for security
# if: success() || failure() # always run even if the previous step fails
# uses: guyarb/golang-test-annotations@v0.8.0
# with:
# test-results: go_test.json
- name: Publish go-test-action Report
if: success() || failure() # always run even if the previous step fails
uses: robherley/go-test-action@v0.5.0
with:
# Parse an exisiting [test2json](https://pkg.go.dev/cmd/test2json) file, instead of executing go test.
# Will always exit(0) on successful test file parse.
# Optional. No default
fromJSONFile: go_test.json
omit: |
untested
successful
- name: test-summary/action announcement
shell: bash
if: success() || failure() # always run even if the previous step fails
run: |
echo "### test-summary/action! :rocket:" >> $GITHUB_STEP_SUMMARY
- name: Publish Test Summary Report
uses: test-summary/action@v2.4
if: success() || failure() # always run even if the previous step fails
with:
show: "fail, skip"
paths: |
report.xml
go_examples_report.xml