-
Notifications
You must be signed in to change notification settings - Fork 8
101 lines (84 loc) · 2.49 KB
/
Copy pathci.yml
File metadata and controls
101 lines (84 loc) · 2.49 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
98
99
100
101
name: CI
# Run on every push and on pull requests targeting master/main.
on:
push:
branches: [master, main]
pull_request:
permissions:
contents: read
jobs:
# Run the full test suite with race detection and generate a coverage report.
# Matrix tests across supported Go versions since this is a library.
test:
name: Test (Go ${{ matrix.go-version }})
runs-on: ubuntu-latest
strategy:
matrix:
go-version:
- "1.21"
- "1.22"
- "1.23"
- "1.24"
- "1.25"
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}
# Verify dependency checksums match go.sum (detects corrupted or tampered modules).
- name: Verify dependencies
run: go mod verify
- name: Run tests
run: go test -race -coverprofile=coverage.out -covermode=atomic ./...
# Print coverage summary to the CI log (latest Go version only).
- name: Coverage summary
if: matrix.go-version == '1.25'
run: go tool cover -func=coverage.out | tail -1
# Static analysis: go vet for built-in checks, golangci-lint for extended linting.
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Run go vet
run: go vet ./...
# golangci-lint v2 runs 50+ linters in a single pass.
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.12.2
# Verify the project compiles on the minimum supported Go version.
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Build
run: go build ./...
# Scan dependencies for known vulnerabilities using Go's official scanner.
# See https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck
govulncheck:
name: govulncheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
- uses: golang/govulncheck-action@v1
with:
go-version-file: go.mod