forked from cilium/cilium
-
Notifications
You must be signed in to change notification settings - Fork 7
430 lines (377 loc) · 15.9 KB
/
Copy pathlint-build-commits.yaml
File metadata and controls
430 lines (377 loc) · 15.9 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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
name: Build Commits
# Any change in triggers needs to be reflected in the concurrency group.
on:
pull_request: {}
push:
branches:
- main
- ft/main/**
# If the cache was cleaned we should re-build the cache with the latest commit
workflow_run:
workflows:
- "Image CI Cache Cleaner"
branches:
- main
- ft/main/**
types:
- completed
permissions: read-all
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
cancel-in-progress: true
jobs:
compute-vars:
name: Compute variables
runs-on: ubuntu-24.04
outputs:
commits: ${{ steps.commits.outputs.commits }}
head-commit: ${{ steps.commits.outputs.head-commit }}
build-bpf: ${{ steps.bpf-changes.outputs.src }}
build-test: ${{ steps.test-changes.outputs.src }}
timeout-minutes: 180
steps:
- name: Configure git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "github-actions@users.noreply.github.com"
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Compute commit list
id: commits
run: |
if [[ "${{ github.event_name == 'push' || github.event_name == 'workflow_run' }}" == "true" ]]; then
commits=${{ github.sha }}
head_commit=${{ github.sha }}
else
commits=$(git rev-list ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | tr '\n' ' ')
head_commit=${{ github.event.pull_request.head.sha }}
fi
echo "commits=$commits" >> $GITHUB_OUTPUT
echo "head-commit=$head_commit" >> $GITHUB_OUTPUT
- name: Check bpf code changes
uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2
id: bpf-changes
with:
# If these filters are modified, also modify the step:
# build-commits-bpf: Check if datapath build works for every commit
filters: |
src:
- '.github/workflows/lint-build-commits.yaml'
- 'bpf/**'
- '!**/*.md'
- name: Check test code changes
uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2
id: test-changes
with:
# If these filters are modified, also modify the step:
# build-commits-test: Check if ginkgo test suite build works for every commit
filters: |
src:
- '.github/workflows/lint-build-commits.yaml'
- 'pkg/**'
- 'test/**'
- '!**/*.md'
build-commits-cilium:
name: Check if cilium builds for every commit
runs-on: ${{ vars.GH_RUNNER_EXTRA_POWER_UBUNTU_LATEST || 'ubuntu-24.04' }}
needs: [compute-vars]
timeout-minutes: 180
steps:
- name: Collect Workflow Telemetry
uses: cilium/workflow-telemetry-action@b1a318f80a08acede58027afe1455d037379966f # v2.2.0
with:
comment_on_pr: false
- name: Configure git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "github-actions@users.noreply.github.com"
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Cleanup Disk space in runner
uses: ./.github/actions/disk-cleanup
- name: Install Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
cache: false
# renovate: datasource=golang-version depName=go
go-version: 1.26.5
- name: Load Golang cache build from GitHub
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: go-cache
with:
path: /tmp/.cache/go
key: ${{ runner.os }}-go-all-cache-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-all-cache-
${{ runner.os }}-go-
- name: Load ccache cache build from GitHub
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: ccache-cache
with:
path: /tmp/.cache/ccache
key: ${{ runner.os }}-ccache-${{ hashFiles('bpf/**') }}
restore-keys: |
${{ runner.os }}-ccache-
- name: Create cache directories if they don't exist
if: ${{ steps.go-cache.outputs.cache-hit != 'true' || steps.ccache-cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
mkdir -p /tmp/.cache/go/.cache/go-build
mkdir -p /tmp/.cache/go/pkg
mkdir -p /tmp/.cache/ccache/.ccache
- name: Check if build works for every commit
if: ${{ github.event_name != 'push' || ( (github.event_name == 'push' || github.event_name == 'workflow_run' ) && (steps.go-cache.outputs.cache-hit != 'true' || steps.ccache-cache.outputs.cache-hit != 'true')) }}
env:
CLANG: "ccache clang"
BUILDER_GOCACHE_DIR: "/tmp/.cache/go/.cache/go-build"
BUILDER_GOMODCACHE_DIR: "/tmp/.cache/go/pkg"
BUILDER_CCACHE_DIR: "/tmp/.cache/ccache/.ccache"
run: |
set -eu -o pipefail
commits="${{ needs.compute-vars.outputs.commits }}"
for commit in $commits; do
git checkout $commit || exit 1
contrib/scripts/builder.sh make CLANG="${CLANG}" build -j "$(nproc)" || exit 1
done
- name: Reset cache ownership to GitHub runners user
if: ${{ steps.go-cache.outputs.cache-hit != 'true' || steps.ccache-cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
sudo du -sh /tmp/.cache/
sudo chown $USER:$USER -R /tmp/.cache
- name: Failed commit during the build
if: ${{ failure() }}
run: git --no-pager log --format=%B -n 1
build-commits-hubble-cli:
name: Check if hubble-cli builds for every commit
runs-on: ${{ vars.GH_RUNNER_EXTRA_POWER_UBUNTU_LATEST || 'ubuntu-24.04' }}
needs: [compute-vars]
timeout-minutes: 180
steps:
- name: Collect Workflow Telemetry
uses: cilium/workflow-telemetry-action@b1a318f80a08acede58027afe1455d037379966f # v2.2.0
with:
comment_on_pr: false
- name: Configure git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "github-actions@users.noreply.github.com"
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Cleanup Disk space in runner
uses: ./.github/actions/disk-cleanup
- name: Install Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
cache: false
# renovate: datasource=golang-version depName=go
go-version: 1.26.5
- name: Load hubble-cli Golang cache build from GitHub
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: hubble-cache
with:
path: /tmp/.cache/hubble-cli
key: ${{ runner.os }}-go-hubble-cli-cache-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-hubble-cli-cache-
${{ runner.os }}-go-
- name: Load ccache cache build from GitHub
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: ccache-cache
with:
path: /tmp/.cache/ccache
key: ${{ runner.os }}-ccache-${{ hashFiles('bpf/**') }}
restore-keys: |
${{ runner.os }}-ccache-
- name: Create cache directories if they don't exist
if: ${{ steps.ccache-cache.outputs.cache-hit != 'true' || steps.hubble-cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
mkdir -p /tmp/.cache/ccache/.ccache
mkdir -p /tmp/.cache/hubble-cli/.cache/go-build
mkdir -p /tmp/.cache/hubble-cli/pkg
- name: Check if hubble CLI builds for every commit
if: ${{ github.event_name != 'push' || ( github.event_name == 'push' && steps.hubble-cache.outputs.cache-hit != 'true' ) }}
env:
CLANG: "ccache clang"
BUILDER_GOCACHE_DIR: "/tmp/.cache/hubble-cli/.cache/go-build"
BUILDER_GOMODCACHE_DIR: "/tmp/.cache/hubble-cli/pkg"
run: |
set -eu -o pipefail
commits="${{ needs.compute-vars.outputs.commits }}"
head_commit="${{ needs.compute-vars.outputs.head-commit }}"
for commit in $commits; do
git checkout $commit || exit 1
echo "Only run full build (with \`local-release\`) for head commit (i.e. last commit in sequence)"
target=hubble
if [[ "$commit" == "$head_commit" ]]; then
target=local-release
fi
echo "Running build: $target (commit: $commit)"
contrib/scripts/builder.sh make CLANG="${CLANG}" -C hubble $target -j "$(nproc)" || exit 1
done
- name: Reset cache ownership to GitHub runners user
if: ${{ steps.ccache-cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
sudo du -sh /tmp/.cache/
sudo chown $USER:$USER -R /tmp/.cache
- name: Failed commit during the build
if: ${{ failure() }}
run: git --no-pager log --format=%B -n 1
build-commits-bpf:
name: Check if bpf builds for every commit
runs-on: ${{ vars.GH_RUNNER_EXTRA_POWER_UBUNTU_LATEST || 'ubuntu-24.04' }}
needs: [compute-vars]
# Runs only if code under bpf/ is changed.
if: needs.compute-vars.outputs.build-bpf == 'true'
timeout-minutes: 180
steps:
- name: Collect Workflow Telemetry
uses: cilium/workflow-telemetry-action@b1a318f80a08acede58027afe1455d037379966f # v2.2.0
with:
comment_on_pr: false
- name: Configure git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "github-actions@users.noreply.github.com"
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Cleanup Disk space in runner
uses: ./.github/actions/disk-cleanup
- name: Install Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
cache: false
# renovate: datasource=golang-version depName=go
go-version: 1.26.5
- name: Load Golang cache build from GitHub
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: go-cache
with:
path: /tmp/.cache/go
key: ${{ runner.os }}-go-all-cache-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-all-cache-
${{ runner.os }}-go-
- name: Load ccache cache build from GitHub
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: ccache-cache
with:
path: /tmp/.cache/ccache
key: ${{ runner.os }}-ccache-${{ hashFiles('bpf/**') }}
restore-keys: |
${{ runner.os }}-ccache-
- name: Create cache directories if they don't exist
if: ${{ steps.go-cache.outputs.cache-hit != 'true' || steps.ccache-cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
mkdir -p /tmp/.cache/go/.cache/go-build
mkdir -p /tmp/.cache/go/pkg
mkdir -p /tmp/.cache/ccache/.ccache
- name: Check if datapath build works for every commit
env:
CLANG: "ccache clang"
BUILDER_GOCACHE_DIR: "/tmp/.cache/go/.cache/go-build"
BUILDER_GOMODCACHE_DIR: "/tmp/.cache/go/pkg"
BUILDER_CCACHE_DIR: "/tmp/.cache/ccache/.ccache"
run: |
set -eu -o pipefail
commits="${{ needs.compute-vars.outputs.commits }}"
for commit in $commits; do
git checkout $commit || exit 1
# Do not run make if there aren't any files modified in these
# directories from the previous commit to the current commit.
# If these filters are modified, also modify the step:
# compute-vars: Check bpf code changes
if ! git diff --quiet HEAD^ bpf/ ; then
contrib/scripts/builder.sh make CLANG="${CLANG}" -C bpf build_all -j "$(nproc)" || exit 1
fi
done
- name: Reset cache ownership to GitHub runners user
if: ${{ steps.go-cache.outputs.cache-hit != 'true' || steps.ccache-cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
sudo du -sh /tmp/.cache/
sudo chown $USER:$USER -R /tmp/.cache
- name: Failed commit during the build
if: ${{ failure() }}
run: git --no-pager log --format=%B -n 1
build-commits-test:
name: Check if test builds for every commit
runs-on: ${{ vars.GH_RUNNER_EXTRA_POWER_UBUNTU_LATEST || 'ubuntu-24.04' }}
needs: [compute-vars]
# Runs only if code under test/ is changed.
if: needs.compute-vars.outputs.build-test == 'true'
timeout-minutes: 180
steps:
- name: Collect Workflow Telemetry
uses: cilium/workflow-telemetry-action@b1a318f80a08acede58027afe1455d037379966f # v2.2.0
with:
comment_on_pr: false
- name: Configure git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "github-actions@users.noreply.github.com"
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Cleanup Disk space in runner
uses: ./.github/actions/disk-cleanup
- name: Install Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
cache: false
# renovate: datasource=golang-version depName=go
go-version: 1.26.5
- name: Set clang directory
id: set_clang_dir
run: echo "clang_dir=$HOME/.clang" >> $GITHUB_OUTPUT
- name: Install LLVM and Clang prerequisites
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends libtinfo6
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@ebc0426251bc40c7cd31162802432c68818ab8f0 # v2.0.9
with:
version: "19.1.7"
directory: ${{ steps.set_clang_dir.outputs.clang_dir }}
- name: Install ginkgo
run: |
go install github.com/onsi/ginkgo/ginkgo@cc0216944b25a88d3259699a029d4e601fb8a222 # v1.12.1
- name: Check if ginkgo test suite build works for every commit
run: |
set -eu -o pipefail
commits="${{ needs.compute-vars.outputs.commits }}"
for commit in $commits; do
git checkout $commit || exit 1
# Do not run make if there aren't any files modified in these
# directories from the previous commit to the current commit.
# If these filters are modified, also modify the step:
# compute-vars: Check test code changes
if ! git diff --quiet HEAD^ pkg/ test/ ; then
(make -C test build -j "$(nproc)" && make -C test build-darwin -j "$(nproc)") || exit 1
fi
done
- name: Failed commit during the build
if: ${{ failure() }}
run: git --no-pager log --format=%B -n 1