-
Notifications
You must be signed in to change notification settings - Fork 21
83 lines (69 loc) · 2.42 KB
/
go-unit-tests.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
name: Unit Tests
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
concurrency:
group: quamina-unit-tests-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
test:
name: Unit Tests
strategy:
matrix:
go-version: ["1.22"]
platform: ["ubuntu-latest"]
type: ["Tests","Cover"] # run coverage as separate job w/out -race to avoid killing process
include:
- type: "Tests"
goflags: '-v -race -count=1 -json'
- type: "Cover"
goflags: "-v -count=1 -json"
coveropts: "-coverprofile=coverage.txt -covermode=atomic"
runs-on: ${{ matrix.platform }}
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a
with:
go-version: ${{ matrix.go-version }}
id: go
- name: Restore Go cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum', 'testdata/**') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}-
- name: Install tparse
run: go install github.com/mfridman/tparse@latest
- name: Check for .codecov.yaml
id: codecov-enabled
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6
with:
files: .codecov.yaml
- name: Test
env:
COVER_OPTS: ${{ matrix.coveropts }}
GOFLAGS: ${{ matrix.goflags }}
run: go test $COVER_OPTS | tparse -all -notests -format markdown >> $GITHUB_STEP_SUMMARY
- if: steps.codecov-enabled.outputs.files_exists == 'true'
name: Upload Codecov Report
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Verify git clean
shell: bash
run: |
if [[ -z "$(git status --porcelain)" ]]; then
echo "${{ github.repository }} up to date."
else
echo "${{ github.repository }} is dirty."
echo "::error:: $(git status)"
exit 1
fi