-
Notifications
You must be signed in to change notification settings - Fork 9
81 lines (69 loc) · 1.94 KB
/
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
70
71
72
73
74
75
76
77
78
79
80
81
name: Go
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Cancel running workflows on new push to a PR.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
tidy:
name: Tidy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.22.x'
- name: gofmt
run: test -z "$(gofmt -s -l $(find -name '*.go'))"
- name: go mod tidy
run: |
go mod tidy
git status
if [[ -n "$(git status --porcelain .)" ]]; then
echo 'go.mod/go.sum is out-of-date: run `go mod tidy` and then check in the changes'
echo 'If `go mod tidy` results in no changes, make sure you are using the latest relase of Go'
git status --porcelain .
exit 1
fi
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
goversion: ['1.21.x', '1.22.x']
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.goversion }}
- run: go build -v ./...
- run: ./cross-compile.sh
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
goversion: ['1.21.x', '1.22.x']
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.goversion }}
- name: Test
run: go test -v -covermode atomic -coverpkg ./... -coverprofile cover.out ./...
- name: Race
run: go test -race -v ./...
- uses: codecov/codecov-action@v4-beta
env:
CODECOV_TOKEN: '9f38c23a-5d79-4a19-a90f-72edcac95ce1'
with:
flags: ${{ matrix.goversion }}
fail_ci_if_error: true
verbose: true