-
-
Notifications
You must be signed in to change notification settings - Fork 138
92 lines (77 loc) · 2.25 KB
/
test.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
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
name: Tests
on:
pull_request: {}
push:
branches:
- main
jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Filter paths
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
filters: |
go:
- '**/*.go'
- name: Setup Go
if: ${{ steps.filter.outputs.go == 'true' }}
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache-dependency-path: "**/*.sum"
- name: Get dependencies
if: ${{ steps.filter.outputs.go == 'true' }}
run: go mod download
- name: Build
if: ${{ steps.filter.outputs.go == 'true' }}
run: go vet . && go build -v .
test:
name: Unit Tests
needs: build
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Filter paths
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
filters: |
go:
- '**/*.go'
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache-dependency-path: "**/*.sum"
- name: Get dependencies
if: ${{ steps.filter.outputs.go == 'true' }}
run: go mod download
- name: Set up gotestfmt
run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
- name: Unit tests
if: ${{ steps.filter.outputs.go == 'true' }}
timeout-minutes: 10
run: go test -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt -hide empty-packages
- name: Upload test log
uses: actions/upload-artifact@v4
if: ${{ steps.filter.outputs.go == 'true' }}
with:
name: test-log
path: /tmp/gotest.log
- name: Check for uncommitted changes in generated docs
run: make docs && git diff --exit-code