-
Notifications
You must be signed in to change notification settings - Fork 1
294 lines (229 loc) · 8.71 KB
/
build.yml
File metadata and controls
294 lines (229 loc) · 8.71 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
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
name: build
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
paths-ignore:
- ".github/labeler.yml"
- ".github/pages.yml"
- ".github/release.yml"
- ".github/workflows/labeler.yml"
- ".github/workflows/rbs-collection-updater.yml"
- "_benchmark/**"
env:
GO_TEST_ARGS: -coverprofile coverage.out -covermode atomic
TEST_GEM_DIR: ruby/testdata/example/
jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- id: set-matrix
run: echo "matrix=$(cat matrix.json | jq -c)" >> $GITHUB_OUTPUT
working-directory: .github/workflows/
build-and-test:
name: "build-and-test (Go ${{ matrix.go }}, Ruby ${{ matrix.ruby }}, Runner ${{ matrix.runner }})"
needs:
- generate-matrix
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
go: ${{ fromJSON(needs.generate-matrix.outputs.matrix).go }}
ruby: ${{ fromJSON(needs.generate-matrix.outputs.matrix).ruby }}
runner:
- ubuntu-latest
- macos-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version: ${{ matrix.go }}
- uses: ruby/setup-ruby@ac793fdd38cc468a4dd57246fa9d0e868aba9085 # v1.270.0
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: build and test (Go)
run: |
set -xe
bundle exec rake go:test
bundle exec rake go:testrace
- name: build and test (Ruby)
run: bundle exec rake
working-directory: ${{ env.TEST_GEM_DIR }}
# FIXME: workaround for gcov2lcov warning
- run: rm -rf vendor/
- name: Coveralls
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: coverage.out
format: golang
continue-on-error: true # NOTE: secrets cannot be obtained with forked repository PR
- name: Slack Notification (not success)
uses: act10ns/slack@cfcc30955fe9377f4f55e1079e5419ee1014269f # v2
if: "! success()"
continue-on-error: true
with:
status: ${{ job.status }}
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
matrix: ${{ toJson(matrix) }}
go-lint:
name: "go-lint (Ruby ${{ matrix.ruby }})"
needs:
- generate-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby: ${{ fromJSON(needs.generate-matrix.outputs.matrix).ruby }}
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version-file: "go.mod"
- uses: ruby/setup-ruby@ac793fdd38cc468a4dd57246fa9d0e868aba9085 # v1.270.0
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: export CGO_CFLAGS for golangci-lint
run: bundle exec rake go:build_envs[CGO_CFLAGS] >> $GITHUB_ENV
- run: echo $CGO_CFLAGS
- name: export BUILD_TAG for golangci-lint
run: echo "BUILD_TAG=$(bundle exec rake go:build_tag)" >> $GITHUB_ENV
- run: echo $BUILD_TAG
- name: golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version-file: .golangci-lint-version
args: --build-tags ${{ env.BUILD_TAG }} --modules-download-mode=readonly
- name: Slack Notification (not success)
uses: act10ns/slack@cfcc30955fe9377f4f55e1079e5419ee1014269f # v2
if: "! success()"
continue-on-error: true
with:
status: ${{ job.status }}
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
go-govulncheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version-file: go.mod
cache: true
- run: go install golang.org/x/vuln/cmd/govulncheck@latest
- uses: ruby/setup-ruby@ac793fdd38cc468a4dd57246fa9d0e868aba9085 # v1.270.0
with:
ruby-version: ruby
bundler-cache: true
- name: export CGO_CFLAGS for govulncheck
run: bundle exec rake go:build_envs[CGO_CFLAGS] >> $GITHUB_ENV
- run: echo $CGO_CFLAGS
- name: export BUILD_TAG for govulncheck
run: echo "BUILD_TAG=$(bundle exec rake go:build_tag)" >> $GITHUB_ENV
- run: echo $BUILD_TAG
# FIXME: Workaround for following error
#
# govulncheck: loading packages: err: exit status 1: stderr: go: inconsistent vendoring in /home/runner/work/go-gem-wrapper/go-gem-wrapper:
# github.com/stretchr/testify@v1.11.1: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
# github.com/davecgh/go-spew@v1.1.1: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
# github.com/pmezard/go-difflib@v1.0.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
# gopkg.in/yaml.v3@v3.0.1: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
#
# To ignore the vendor directory, use -mod=readonly or -mod=mod.
# To sync the vendor directory, run:
# go mod vendor
- run: rm -rf vendor/
# FIXME: golang/govulncheck-action@v1 doesn't support `-tags` arg
# - uses: golang/govulncheck-action@v1
# with:
# go-version-file: go.mod
- run: govulncheck -format text -tags "${BUILD_TAG}" ./...
- name: Slack Notification (not success)
uses: act10ns/slack@cfcc30955fe9377f4f55e1079e5419ee1014269f # v2
if: "! success()"
continue-on-error: true
with:
status: ${{ job.status }}
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
ruby-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: ruby/setup-ruby@ac793fdd38cc468a4dd57246fa9d0e868aba9085 # v1.270.0
with:
ruby-version: ruby
bundler-cache: true
- run: bundle exec rake ruby:rubocop
- name: Slack Notification (not success)
uses: act10ns/slack@cfcc30955fe9377f4f55e1079e5419ee1014269f # v2
if: "! success()"
continue-on-error: true
with:
status: ${{ job.status }}
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
ruby-rbs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: ruby/setup-ruby@ac793fdd38cc468a4dd57246fa9d0e868aba9085 # v1.270.0
with:
ruby-version: ruby
bundler-cache: true
- run: bundle exec rbs collection install
- run: bundle exec rbs validate
- run: bundle exec steep check
- name: Slack Notification (not success)
uses: act10ns/slack@cfcc30955fe9377f4f55e1079e5419ee1014269f # v2
if: "! success()"
continue-on-error: true
with:
status: ${{ job.status }}
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
go_gem:
name: "go_gem (Ruby ${{ matrix.ruby }})"
needs:
- generate-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby: ${{ fromJSON(needs.generate-matrix.outputs.matrix).ruby }}
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: ruby/setup-ruby@ac793fdd38cc468a4dd57246fa9d0e868aba9085 # v1.270.0
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake go_gem:test
- name: Slack Notification (not success)
uses: act10ns/slack@cfcc30955fe9377f4f55e1079e5419ee1014269f # v2
if: "! success()"
continue-on-error: true
with:
status: ${{ job.status }}
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
matrix: ${{ toJson(matrix) }}
all-pass-build:
if: always()
needs:
- build-and-test
- go-lint
- go-govulncheck
- ruby-lint
- ruby-rbs
- go_gem
runs-on: ubuntu-latest
steps:
- name: check dependent jobs
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
with:
jobs: ${{ toJSON(needs) }}