-
Notifications
You must be signed in to change notification settings - Fork 2
122 lines (111 loc) · 3.53 KB
/
go-test.yml
File metadata and controls
122 lines (111 loc) · 3.53 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: go-test
permissions:
pull-requests: read
contents: read
on:
workflow_call:
defaults:
run:
shell: bash
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
-
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version: stable
check-latest: true
cache: true
-
name: golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version: latest
only-new-issues: true
skip-cache: true
test:
name: Unit tests
runs-on: ${{ matrix.os }}
needs: [lint]
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
go: ['oldstable', 'stable' ]
steps:
-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
-
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version: '${{ matrix.go }}'
check-latest: true
cache: true
-
name: Install gotestsum
uses: go-openapi/gh-actions/install/gotestsum@8340d5403ad368f2ddaa0bc3b10ce38a10099e2c # v1.4.3
-
name: Ensure TMP is created on windows runners
# On windows, some tests require testing.TempDir to reside on the same drive as the code.
# TMP is used by os.TempDir() to determine the location of temporary files.
if: ${{ runner.os == 'Windows' }}
shell: bash
run: |
TMP="${{ github.workspace }}\..\tmp"
mkdir -p ${TMP}
echo "TMP=${TMP}" >> "${GITHUB_ENV}"
-
name: Run unit tests
run: >
gotestsum
--jsonfile 'unit.report.${{ matrix.os }}-${{ matrix.go }}.json'
--
-race
-p 2
-count 1
-timeout=20m
-coverprofile='unit.coverage.${{ matrix.os }}-${{ matrix.go }}.out'
-covermode=atomic
-coverpkg="$(go list)"/...
./...
-
name: Upload coverage artifacts
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
# *.coverage.* pattern is automatically detected by codecov
path: '**/*.coverage.*.out'
name: 'unit.coverage.${{ matrix.os }}-${{ matrix.go }}'
retention-days: 1
-
name: Upload test report artifacts
# upload report even if test fail. BTW, this is when they are valuable.
if: ${{ !cancelled() }}
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
path: '**/unit.report.*.json'
name: 'unit.report.${{ matrix.os }}-${{ matrix.go }}'
retention-days: 1
fuzz-test:
uses: ./.github/workflows/fuzz-test.yml
test-complete:
# description: |
# Be explicit about all tests being passed. This allows for setting up only a few status checks on PRs.
name: tests completed
needs: [test,fuzz-test]
runs-on: ubuntu-latest
steps:
-
name: Tests completed
run: |
echo "::notice title=Success::All tests passed"
collect-coverage:
needs: [test-complete]
if: ${{ !cancelled() && needs.test-complete.result == 'success' }}
uses: ./.github/workflows/collect-coverage.yml
collect-reports:
needs: [test]
if: ${{ !cancelled() }}
uses: ./.github/workflows/collect-reports.yml