-
Notifications
You must be signed in to change notification settings - Fork 21
189 lines (163 loc) · 5.09 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: Go
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
# Every day at 8am.
- cron: "0 8 * * *"
# 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: cd src && test -z "$(gofmt -s -l $(find -name '*.go'))"
- name: go mod tidy
run: |
cd src
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
unit-test:
name: Unit Test
runs-on: ubuntu-latest
strategy:
matrix:
goversion: ['1.20', '1.21.x', '1.22.x']
steps:
- uses: actions/checkout@v4
with:
path: go/src/github.com/u-root/gobusybox
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.goversion }}
- name: Test
run: |
cd go/src/github.com/u-root/gobusybox/src
# Unit tests cover both GO111MODULE=on and off cases.
GOPATH=$GITHUB_WORKSPACE/go go test -covermode=atomic -coverprofile cover.out ./...
- uses: codecov/codecov-action@036b81c4b4e8314b391265bc226440f9e2117e2a
env:
CODECOV_TOKEN: 'bf25d8b2-b4f9-43f4-b578-64eefbe31e61'
with:
working-directory: go/src/github.com/u-root/gobusybox
flags: ${{ matrix.goversion }}
fail_ci_if_error: true
verbose: true
test-gopath:
name: gobuilds-gopath
runs-on: ubuntu-latest
strategy:
matrix:
goversion: ['1.20', '1.21.x', '1.22.x']
steps:
- uses: actions/checkout@v4
with:
path: go/src/github.com/u-root/gobusybox
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.goversion }}
- name: Test
run: |
cd go/src/github.com/u-root/gobusybox
mkdir cover
GOPATH=$GITHUB_WORKSPACE/go GOCOVERDIR=$(pwd)/cover ./gobuilds-gopath.sh
go tool covdata textfmt -i=cover -o cover.out
- uses: codecov/codecov-action@036b81c4b4e8314b391265bc226440f9e2117e2a
env:
CODECOV_TOKEN: 'bf25d8b2-b4f9-43f4-b578-64eefbe31e61'
with:
working-directory: go/src/github.com/u-root/gobusybox
flags: ${{ matrix.goversion }}
fail_ci_if_error: true
verbose: true
test-gomodule:
name: gobuilds
runs-on: ubuntu-latest
strategy:
matrix:
goversion: ['1.20', '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: |
mkdir cover
GOCOVERDIR=$(pwd)/cover ./gobuilds.sh
go tool covdata textfmt -i=cover -o cover.out
- uses: codecov/codecov-action@036b81c4b4e8314b391265bc226440f9e2117e2a
env:
CODECOV_TOKEN: 'bf25d8b2-b4f9-43f4-b578-64eefbe31e61'
with:
flags: ${{ matrix.goversion }}
fail_ci_if_error: true
verbose: true
test-external-workspaces:
name: test-external-workspaces
runs-on: ubuntu-latest
strategy:
matrix:
goversion: ['1.20', '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: |
mkdir cover
GOCOVERDIR=$(pwd)/cover ./test-external-workspaces.sh
go tool covdata textfmt -i=cover -o cover.out
- uses: codecov/codecov-action@036b81c4b4e8314b391265bc226440f9e2117e2a
env:
CODECOV_TOKEN: 'bf25d8b2-b4f9-43f4-b578-64eefbe31e61'
with:
flags: ${{ matrix.goversion }}
fail_ci_if_error: true
verbose: true
test-external-gopath:
name: test-external-gopath
runs-on: ubuntu-latest
strategy:
matrix:
goversion: ['1.20', '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: |
mkdir cover
GOCOVERDIR=$(pwd)/cover ./test-external-gopath.sh
go tool covdata textfmt -i=cover -o cover.out
- uses: codecov/codecov-action@036b81c4b4e8314b391265bc226440f9e2117e2a
env:
CODECOV_TOKEN: 'bf25d8b2-b4f9-43f4-b578-64eefbe31e61'
with:
flags: ${{ matrix.goversion }}
fail_ci_if_error: true
verbose: true