22# both PRs and merged commits, and for the latter reports failures to slack.
33name : CI
44
5- env :
6- # Our fuzz job, powered by OSS-Fuzz, fails periodically because we upgrade to
7- # new Go versions very eagerly. OSS-Fuzz is a little more conservative, and
8- # ends up being unable to compile our code.
9- #
10- # When this happens, we want to disable the fuzz target until OSS-Fuzz catches
11- # up. However, we also don't want to forget to turn it back on when OSS-Fuzz
12- # can once again build our code.
13- #
14- # This variable toggles the fuzz job between two modes:
15- # - false: we expect fuzzing to be happy, and should report failure if it's not.
16- # - true: we expect fuzzing is broken, and should report failure if it start working.
17- TS_FUZZ_CURRENTLY_BROKEN : false
5+ permissions : {}
186
197on :
208 push :
@@ -40,6 +28,8 @@ concurrency:
4028
4129jobs :
4230 test :
31+ permissions :
32+ contents : read
4333 strategy :
4434 fail-fast : false # don't abort the entire matrix if one element fails
4535 matrix :
@@ -116,6 +106,8 @@ jobs:
116106 fi
117107
118108 windows :
109+ permissions :
110+ contents : read
119111 runs-on : windows-2022
120112 steps :
121113 - name : checkout
@@ -151,6 +143,8 @@ jobs:
151143 run : go test -bench . -benchtime 1x ./...
152144
153145 vm :
146+ permissions :
147+ contents : read
154148 runs-on : ["self-hosted", "linux", "vm"]
155149 # VM tests run with some privileges, don't let them run on 3p PRs.
156150 if : github.repository == 'tailscale/tailscale'
@@ -171,6 +165,8 @@ jobs:
171165 XDB_CACHE_HOME : " /var/lib/ghrunner/cache"
172166
173167 cross : # cross-compile checks, build only.
168+ permissions :
169+ contents : read
174170 strategy :
175171 fail-fast : false # don't abort the entire matrix if one element fails
176172 matrix :
@@ -248,6 +244,8 @@ jobs:
248244
249245 ios : # similar to cross above, but iOS can't build most of the repo. So, just
250246 # make it build a few smoke packages.
247+ permissions :
248+ contents : read
251249 runs-on : ubuntu-22.04
252250 steps :
253251 - name : checkout
@@ -259,6 +257,8 @@ jobs:
259257 GOARCH : arm64
260258
261259 android :
260+ permissions :
261+ contents : read
262262 # similar to cross above, but android fails to build a few pieces of the
263263 # repo. We should fix those pieces, they're small, but as a stepping stone,
264264 # only test the subset of android that our past smoke test checked.
@@ -281,65 +281,33 @@ jobs:
281281 GOARCH : arm64
282282
283283 fuzz :
284- # This target periodically breaks (see TS_FUZZ_CURRENTLY_BROKEN at the top
285- # of the file), so it's more complex than usual: the 'build fuzzers' step
286- # might fail, and depending on the value of 'TS_FUZZ_CURRENTLY_BROKEN', that
287- # might or might not be fine. The steps after the build figure out whether
288- # the success/failure is expected, and appropriately pass/fail the job
289- # overall accordingly.
290- #
291- # Practically, this means that all steps after 'build fuzzers' must have an
292- # explicit 'if' condition, because the default condition for steps is
293- # 'success()', meaning "only run this if no previous steps failed".
284+ permissions :
285+ contents : read
294286 if : github.event_name == 'pull_request'
295287 runs-on : ubuntu-22.04
296288 steps :
297289 - name : build fuzzers
298- id : build
299- uses : google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
300- # continue-on-error makes steps.build.conclusion be 'success' even if
301- # steps.build.outcome is 'failure'. This means this step does not
302- # contribute to the job's overall pass/fail evaluation.
303- continue-on-error : true
290+ uses : google/clusterfuzzlite/actions/build_fuzzers@v1
304291 with :
305- oss-fuzz-project-name : " tailscale"
306- dry-run : false
307292 language : go
308- - name : report unexpectedly broken fuzz build
309- if : steps.build.outcome == 'failure' && env.TS_FUZZ_CURRENTLY_BROKEN != 'true'
310- run : |
311- echo "fuzzer build failed, see above for why"
312- echo "if the failure is due to OSS-Fuzz not being on the latest Go yet,"
313- echo "set TS_FUZZ_CURRENTLY_BROKEN=true in .github/workflows/test.yml"
314- echo "to temporarily disable fuzzing until OSS-Fuzz works again."
315- exit 1
316- - name : report unexpectedly working fuzz build
317- if : steps.build.outcome == 'success' && env.TS_FUZZ_CURRENTLY_BROKEN == 'true'
318- run : |
319- echo "fuzzer build succeeded, but we expect it to be broken"
320- echo "please set TS_FUZZ_CURRENTLY_BROKEN=false in .github/workflows/test.yml"
321- echo "to reenable fuzz testing"
322- exit 1
293+ keep-unaffected-fuzz-targets : true
323294 - name : run fuzzers
324295 id : run
325- # Run the fuzzers whenever they're able to build, even if we're going to
326- # report a failure because TS_FUZZ_CURRENTLY_BROKEN is set to the wrong
327- # value.
328- if : steps.build.outcome == 'success'
329- uses : google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
296+ uses : google/clusterfuzzlite/actions/run_fuzzers@v1
330297 with :
331- oss-fuzz-project-name : " tailscale"
332298 fuzz-seconds : 300
333- dry-run : false
334299 language : go
300+ github-token : ${{ secrets.GITHUB_TOKEN }}
335301 - name : upload crash
336- uses : actions/upload-artifact@v3
337- if : steps.run.outcome != 'success' && steps.build .outcome == 'success '
302+ uses : actions/upload-artifact@v4
303+ if : failure() && steps.run .outcome == 'failure '
338304 with :
339305 name : artifacts
340306 path : ./out/artifacts
341307
342308 depaware :
309+ permissions :
310+ contents : read
343311 runs-on : ubuntu-22.04
344312 steps :
345313 - name : checkout
@@ -354,6 +322,8 @@ jobs:
354322 find . -name 'depaware.txt' | xargs -n1 dirname | xargs ./tool/go run github.com/tailscale/depaware --check
355323
356324 go_generate :
325+ permissions :
326+ contents : read
357327 runs-on : ubuntu-22.04
358328 steps :
359329 - name : checkout
@@ -371,6 +341,8 @@ jobs:
371341 git diff --name-only --exit-code || (echo "The files above need updating. Please run 'go generate'."; exit 1)
372342
373343 go_mod_tidy :
344+ permissions :
345+ contents : read
374346 runs-on : ubuntu-22.04
375347 steps :
376348 - name : checkout
@@ -387,6 +359,8 @@ jobs:
387359 git diff --name-only --exit-code || (echo "Please run 'go mod tidy'."; exit 1)
388360
389361 licenses :
362+ permissions :
363+ contents : read
390364 runs-on : ubuntu-22.04
391365 steps :
392366 - name : checkout
@@ -395,6 +369,8 @@ jobs:
395369 run : ./scripts/check_license_headers.sh .
396370
397371 staticcheck :
372+ permissions :
373+ contents : read
398374 runs-on : ubuntu-22.04
399375 strategy :
400376 fail-fast : false # don't abort the entire matrix if one element fails
@@ -483,4 +459,5 @@ jobs:
483459 if : github.event_name != 'push'
484460 uses : re-actors/alls-green@release/v1
485461 with :
462+ allowed-skips : ${{ github.repository != 'tailscale/tailscale' && 'vm' || '' }}
486463 jobs : ${{ toJSON(needs) }}
0 commit comments