-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (84 loc) · 2.51 KB
/
ci.yml
File metadata and controls
97 lines (84 loc) · 2.51 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
86
87
88
89
90
91
92
93
94
95
96
97
name: CI
# Build, vet, format-check, test (with coverage) and vulnerability scan on every
# push to main and every pull request. Pure-Go, CGO disabled to match the
# release build; a separate race job re-enables CGO for the concurrency-sensitive
# packages only.
on:
push:
branches: [main]
pull_request:
branches: [main]
# Weekly run so newly-disclosed vulnerabilities in dependencies are caught even
# when there are no new commits (the govulncheck job below).
schedule:
- cron: "0 6 * * 1"
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
build-test:
name: build & test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: gofmt (check formatting)
run: |
unformatted="$(gofmt -l .)"
if [ -n "$unformatted" ]; then
echo "::error::These files are not gofmt-clean:"
echo "$unformatted"
exit 1
fi
- name: go vet
env:
CGO_ENABLED: "0"
run: go vet ./...
- name: build
env:
CGO_ENABLED: "0"
run: go build ./...
- name: test (with coverage)
env:
CGO_ENABLED: "0"
run: go test ./... -count=1 -covermode=atomic -coverprofile=coverage.out
- name: upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage.out
if-no-files-found: error
race:
name: race detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
# The race detector needs CGO. Scope it to the packages with real
# concurrency (TUI ticks, the collection daemon, the store) to keep it fast.
- name: go test -race
env:
CGO_ENABLED: "1"
run: go test -race -count=1 ./internal/tui/... ./internal/collect/... ./internal/store/...
govulncheck:
name: vulnerability scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: govulncheck
# govulncheck reports only vulns actually reachable from this code.
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...