-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (73 loc) · 2.5 KB
/
Copy pathgotest.yaml
File metadata and controls
85 lines (73 loc) · 2.5 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
name: Go test
on:
workflow_call:
inputs:
go:
type: string
default: "1.17.x"
mongo:
type: string
redis:
type: string
test-options:
type: string
default: "-race -count=1 -failfast -v"
jobs:
gotest:
name: Go Test
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@be3c94b385c4f180051c996d336f57a34c397495 # v3
with:
go-version: ${{ inputs.go }}
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Start Redis
if: ${{ inputs.redis != '' }}
uses: supercharge/redis-github-action@1f58ff85cf4f9ef3c036109c11acd8376b436b47 # 1.2.0
with:
redis-version: '${{ inputs.redis }}'
- name: Start MongoDB
if: ${{ inputs.mongo != '' }}
uses: supercharge/mongodb-github-action@751e4ddb1f8de2717b75f275abce04735664ef46 # 1.2.0
with:
mongodb-version: '${{ inputs.mongo }}'
- name: Cache
uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Set up test tooling
run: |
go install gotest.tools/gotestsum@v1.13.0 # c4a0df2e75a225d979a444342dd3db752b53619f
- name: Go Test
id: test
run: |
PKGS="$(go list ./...)"
OPTS="${{ inputs.test-options }}"
for pkg in ${PKGS}; do
tags=""
if [[ ${pkg} == *"goplugin" ]]; then
tags="--tags 'goplugin'"
fi
coveragefile=`echo "$pkg" | awk -F/ '{print $NF}'`
echo go test ${OPTS} -json -timeout 15m -coverprofile=${coveragefile}.cov ${pkg} ${tags}
gotestsum --junitfile ${coveragefile}.xml --raw-command go test ${OPTS} --json -timeout 15m -coverprofile=${coveragefile}.cov ${pkg} ${tags}
done
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: coverage
path: "*cov"
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
if: ${{ always() }}
with:
name: junit
path: "*xml"
- name: Github report view
if: ${{ always() }}
uses: phoenix-actions/test-reporting@1e9b578818d03d6df50ce8e60d024a000bf3ab63 # v8
with:
name: Unit Test Results
path: "*.xml"
reporter: java-junit