This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 182
61 lines (52 loc) · 1.57 KB
/
gotests.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
name: gotests
on:
push:
branches:
- main
pull_request:
concurrency:
group: gotests-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
RESULT_PATH: "~/testresults"
GO_VERSION: 1.18.7
jobs:
gotests:
name: gotests
runs-on: ubuntu-20.04
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Caching dependency
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
~/go/bin
key: ${{ runner.os }}-v1-go-mod-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }}
- name: go mod download
run: |
[[ -d ~/go/pkg/mod ]] && exit 0
# retry up to 3 times in case of network issues
for i in $(seq 1 3); do
go mod download && exit 0
sleep 10
done
exit 1
- name: go test
run: |
mkdir ${{ env.RESULT_PATH }}
export NUM_CORES=$(getconf _NPROCESSORS_ONLN)
(cd /tmp; GO111MODULE=on go install gotest.tools/gotestsum@latest)
go generate ./...
CGO_ENABLED=0 gotestsum --format short-verbose --junitfile ${{ env.RESULT_PATH }}/unit.xml --raw-command -- go test --json -p $NUM_CORES ./...
- name: Uploading test results
uses: actions/upload-artifact@v3
with:
name: go-test-results
path: ${{ env.RESULT_PATH }}