-
Notifications
You must be signed in to change notification settings - Fork 5
69 lines (59 loc) · 1.91 KB
/
test-go.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
---
name: test (go)
on:
push:
branches:
- master
pull_request:
permissions:
contents: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup cgo dependencies
run: sudo apt-get update && sudo apt-get install libcurl4-openssl-dev libssl-dev libsqlite3-mod-spatialite
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Download
run: go mod download all
- name: Generate (fail when generated code is not committed)
run: go generate -v ./... && git diff --exit-code ':!go.sum'
- name: Build
run: go build -v ./...
- name: Unit Test
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 2
retry_on: error
command: |
go test -v -shuffle=on -coverpkg "$(go list || go list -m | head -1)/..." -coverprofile cover.out.tmp ./...
# remove generate code from coverage results
grep -v "zz_generated" cover.out.tmp > cover.out
- name: Test generating example CRD
run: hack/generate-crd.sh
# we don't (yet) fail on benchmark results, these are just to make sure
# the benchmarks keep working
- name: Benchmark
run: go test -v ./... -bench=. -run=^# -benchmem -count=1
- name: Fail when coverage below threshold
uses: vladopajic/go-test-coverage@v2
with:
profile: cover.out
local-prefix: github.com/PDOK/gokoala
threshold-total: 80 # 80% overall coverage is the minimum
- name: Update coverage report
uses: ncruces/go-coverage-report@v0
with:
coverage-file: cover.out
report: true
chart: false
amend: false
reuse-go: true
if: |
github.event_name == 'push'
continue-on-error: false