-
Notifications
You must be signed in to change notification settings - Fork 59
98 lines (81 loc) · 2.63 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: go
on:
pull_request:
push:
permissions:
contents: read
jobs:
build-and-test:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GO111MODULE: 'on'
CGO_ENABLED: '0'
strategy:
fail-fast: true
matrix:
go: ['1.22.5']
os:
- ubuntu-latest
- windows-latest
- macos-latest
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
name: ${{ matrix.go }} on ${{ matrix.os }}
steps:
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- id: go-cache-paths
run: |
echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
- run: echo ${{ steps.go-cache-paths.outputs.go-build }}
- run: echo ${{ steps.go-cache-paths.outputs.go-mod }}
- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-${{ matrix.go }}-build-${{ hashFiles('**/go.sum') }}
- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-${{ matrix.go }}-build-${{ hashFiles('**/go.sum') }}
- name: Check out code
uses: actions/checkout@v3
- run: go mod download && go mod tidy && go mod verify
- run: git --no-pager diff --exit-code
- run: go vet ./...
- run: git --no-pager diff --exit-code
- if: runner.os == 'Linux'
name: Generate breaking-changes examples
run: |
sh scripts/doc_breaking_changes.sh > docs/BREAKING-CHANGES-EXAMPLES.md
- run: go fmt ./...
- run: git --no-pager diff --exit-code
- run: go test ./... -coverprofile=coverage.txt -covermode=atomic
env:
CGO_ENABLED: '1'
- run: git --no-pager diff --exit-code
- if: runner.os == 'Linux'
name: Errors must not be capitalized https://github.com/golang/go/wiki/CodeReviewComments#error-strings
run: |
! git grep -E '(fmt|errors)[^(]+\(.[A-Z]'
# - if: runner.os == 'Linux'
# name: Did you mean %q
# run: |
# ! git grep -E "'[%].'"
- if: runner.os == 'Linux'
name: Also add yaml tags
run: |
! git grep -InE 'json:"' | grep -v _test.go | grep -v yaml:
- uses: codecov/codecov-action@v4
with:
files: ./coverage.txt
flags: unittests # optional
name: codecov-umbrella # optional
fail_ci_if_error: false # optional (default = false)
verbose: true # optional (default = false)
token: ${{ secrets.CODECOV_TOKEN }} # required