-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (73 loc) · 2.12 KB
/
gotest.yaml
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@v3
with:
go-version: ${{ inputs.go }}
- uses: actions/checkout@v3
- name: Start Redis
if: ${{ inputs.redis != '' }}
uses: supercharge/redis-github-action@1.2.0
with:
redis-version: '${{ inputs.redis }}'
- name: Start MongoDB
if: ${{ inputs.mongo != '' }}
uses: supercharge/mongodb-github-action@1.2.0
with:
mongodb-version: '${{ inputs.mongo }}'
- name: Cache
uses: actions/cache@v2
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@latest
- 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@v3
with:
name: coverage
path: "*cov"
- uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: junit
path: "*xml"
- name: Github report view
if: ${{ always() }}
uses: phoenix-actions/test-reporting@v8
with:
name: Unit Test Results
path: "*.xml"
reporter: java-junit