Skip to content

Commit d7b76a9

Browse files
authored
[ci] enforce 'zizmor' checks in CI (#7218)
1 parent d14c4ba commit d7b76a9

16 files changed

+198
-79
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ concurrency:
1515
group: ${{ github.workflow }}-${{ github.ref }}
1616
cancel-in-progress: true
1717

18+
# default to 0 permissions
19+
# (job-level overrides add the minimal permissions needed)
20+
permissions:
21+
contents: none
22+
1823
env:
1924
# tell scripts where to put artifacts
2025
BUILD_ARTIFACTSTAGINGDIRECTORY: '${{ github.workspace }}/artifacts'
@@ -23,6 +28,8 @@ jobs:
2328
archive:
2429
runs-on: ubuntu-latest
2530
timeout-minutes: 15
31+
permissions:
32+
contents: write
2633
steps:
2734
- name: Checkout repository
2835
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -64,6 +71,8 @@ jobs:
6471
runs-on: ubuntu-latest
6572
needs:
6673
- archive
74+
permissions:
75+
statuses: read
6776
steps:
6877
- name: Note that all tests succeeded
6978
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2

.github/workflows/cpp.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ concurrency:
1313
group: ${{ github.workflow }}-${{ github.ref }}
1414
cancel-in-progress: true
1515

16+
# default to 0 permissions
17+
# (job-level overrides add the minimal permissions needed)
18+
permissions:
19+
contents: none
20+
1621
env:
1722
# tell scripts where to put artifacts
1823
# (this variable name is left over from when jobs ran on Azure DevOps)
@@ -28,6 +33,8 @@ jobs:
2833
runs-on: ${{ matrix.os }}
2934
container: ${{ matrix.container }}
3035
timeout-minutes: 60
36+
permissions:
37+
contents: write
3138
strategy:
3239
fail-fast: false
3340
matrix:
@@ -141,6 +148,8 @@ jobs:
141148
runs-on: ubuntu-latest
142149
needs:
143150
- test
151+
permissions:
152+
statuses: read
144153
steps:
145154
- name: Note that all tests succeeded
146155
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2

.github/workflows/cuda.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ concurrency:
99
group: ${{ github.workflow }}-${{ github.ref }}
1010
cancel-in-progress: true
1111

12+
# default to 0 permissions
13+
# (job-level overrides add the minimal permissions needed)
14+
permissions:
15+
contents: none
16+
1217
jobs:
1318
test:
1419
# yamllint disable-line rule:line-length
@@ -30,6 +35,8 @@ jobs:
3035
SKBUILD_STRICT_CONFIG: true
3136
options: --gpus all
3237
timeout-minutes: 30
38+
permissions:
39+
contents: write
3340
strategy:
3441
fail-fast: false
3542
matrix:
@@ -85,7 +92,10 @@ jobs:
8592
all-cuda-jobs-successful:
8693
if: always()
8794
runs-on: ubuntu-latest
88-
needs: [test]
95+
needs:
96+
- test
97+
permissions:
98+
statuses: read
8999
steps:
90100
- name: Note that all tests succeeded
91101
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2

.github/workflows/lock.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,21 @@ on:
99
# allow manual triggering from GitHub UI
1010
workflow_dispatch:
1111

12-
permissions:
13-
issues: write
14-
pull-requests: write
15-
12+
# only 1 job running in the repo at any time
1613
concurrency:
1714
group: lock
1815

16+
# default to 0 permissions
17+
# (job-level overrides add the minimal permissions needed)
18+
permissions:
19+
contents: none
20+
1921
jobs:
2022
action:
2123
runs-on: ubuntu-latest
24+
permissions:
25+
issues: write
26+
pull-requests: write
2227
steps:
2328
- uses: dessant/lock-threads@7266a7ce5c1df01b1c6db85bf8cd86c737dadbe7 # v6.0.0
2429
with:

.github/workflows/lychee.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ on:
77
schedule:
88
- cron: '0 8 * * *'
99

10+
# only 1 job running in the repo at any time
11+
concurrency:
12+
group: lock
13+
14+
# default to 0 permissions
15+
# (job-level overrides add the minimal permissions needed)
16+
permissions:
17+
contents: none
18+
1019
env:
1120
COMPILER: gcc
1221
OS_NAME: 'linux'
@@ -16,6 +25,8 @@ jobs:
1625
check-links:
1726
timeout-minutes: 60
1827
runs-on: ubuntu-latest
28+
permissions:
29+
contents: read
1930
steps:
2031
- name: Checkout repository
2132
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

.github/workflows/no_response.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
name: No Response Bot
22

3-
permissions:
4-
issues: write
5-
pull-requests: write
6-
73
on:
84
issue_comment:
95
types: [created]
106
schedule:
117
# "every day at 04:00 UTC"
128
- cron: '0 4 * * *'
139

10+
# only 1 job running in the repo at any time
11+
concurrency:
12+
group: lock
13+
14+
# default to 0 permissions
15+
# (job-level overrides add the minimal permissions needed)
16+
permissions:
17+
contents: none
18+
1419
jobs:
15-
noResponse:
20+
no-response:
1621
runs-on: ubuntu-latest
22+
permissions:
23+
issues: write
24+
pull-requests: write
1725
steps:
1826
- uses: lee-dohm/no-response@9bb0a4b5e6a45046f00353d5de7d90fb8bd773bb # v0.5.0
1927
with:

.github/workflows/optional_checks.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,25 @@ on:
55
branches:
66
- master
77

8+
# automatically cancel in-progress builds if another commit is pushed
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
# default to 0 permissions
14+
# (job-level overrides add the minimal permissions needed)
15+
permissions:
16+
contents: none
17+
818
jobs:
919
all-optional-checks-successful:
1020
timeout-minutes: 30
1121
runs-on: ubuntu-latest
1222
env:
1323
GITHUB_TOKEN: ${{ github.token }}
24+
permissions:
25+
contents: write
26+
id-token: write
1427
steps:
1528
- name: Checkout repository
1629
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

.github/workflows/python_package.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ concurrency:
1313
group: ${{ github.workflow }}-${{ github.ref }}
1414
cancel-in-progress: true
1515

16+
# default to 0 permissions
17+
# (job-level overrides add the minimal permissions needed)
18+
permissions:
19+
contents: none
20+
1621
env:
1722
# tell scripts where to put artifacts
1823
# (this variable name is left over from when jobs ran on Azure DevOps)
@@ -376,7 +381,8 @@ jobs:
376381
name: NuGet package
377382
runs-on: ubuntu-latest
378383
timeout-minutes: 30
379-
needs: [test]
384+
needs:
385+
- test
380386
steps:
381387
- name: Checkout repository
382388
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -401,12 +407,12 @@ jobs:
401407
mono-devel
402408
- name: Create NuGet package
403409
run: |
404-
python .ci/create-nuget.py "${{ env.BUILD_ARTIFACTSTAGINGDIRECTORY }}"
410+
python .ci/create-nuget.py "${BUILD_ARTIFACTSTAGINGDIRECTORY}"
405411
nuget pack \
406412
$(pwd)/.ci/nuget/LightGBM.nuspec \
407413
-NonInteractive \
408414
-Verbosity detailed \
409-
-OutputDirectory "${{ env.BUILD_ARTIFACTSTAGINGDIRECTORY }}"
415+
-OutputDirectory "${BUILD_ARTIFACTSTAGINGDIRECTORY}"
410416
- name: Upload artifacts
411417
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
412418
with:
@@ -485,6 +491,8 @@ jobs:
485491
- test
486492
- test-linux-aarch64
487493
- test-old-versions
494+
permissions:
495+
statuses: read
488496
steps:
489497
- name: Note that all tests succeeded
490498
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2

.github/workflows/r_configure.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,26 @@ on:
88
description: |
99
Branch in lightgbm-org/LightGBM to update.
1010
11+
# automatically cancel in-progress builds if another commit is pushed
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
# default to 0 permissions
17+
# (job-level overrides add the minimal permissions needed)
1118
permissions:
12-
actions: none
13-
checks: none
14-
contents: write
15-
deployments: none
16-
discussions: none
17-
id-token: write
18-
issues: none
19-
packages: none
20-
pages: none
21-
pull-requests: read
22-
repository-projects: none
23-
security-events: none
24-
statuses: none
19+
contents: none
2520

2621
jobs:
2722
r-configure:
2823
name: r-configure
2924
timeout-minutes: 60
3025
runs-on: ubuntu-latest
3126
container: "ubuntu:22.04"
27+
permissions:
28+
contents: write
29+
id-token: write
30+
pull-requests: read
3231
steps:
3332
- name: Install essential software before checkout
3433
run: |

.github/workflows/r_package.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ concurrency:
1313
group: ${{ github.workflow }}-${{ github.ref }}
1414
cancel-in-progress: true
1515

16+
# default to 0 permissions
17+
# (job-level overrides add the minimal permissions needed)
18+
permissions:
19+
contents: none
20+
1621
env:
1722
# tell scripts where to put artifacts
1823
# (this variable name is left over from when jobs ran on Azure DevOps)
@@ -55,6 +60,8 @@ jobs:
5560
runs-on: ${{ matrix.os }}
5661
container: ${{ matrix.container }}
5762
timeout-minutes: 60
63+
permissions:
64+
contents: write
5865
strategy:
5966
fail-fast: false
6067
matrix:
@@ -221,6 +228,8 @@ jobs:
221228
timeout-minutes: 60
222229
runs-on: ubuntu-latest
223230
container: wch1/r-debug
231+
permissions:
232+
contents: read
224233
strategy:
225234
fail-fast: false
226235
matrix:
@@ -256,6 +265,8 @@ jobs:
256265
test-r-extra-checks:
257266
name: r-package (${{ matrix.image }}, R-devel)
258267
timeout-minutes: 60
268+
permissions:
269+
contents: read
259270
strategy:
260271
fail-fast: false
261272
matrix:
@@ -361,7 +372,12 @@ jobs:
361372
all-r-package-jobs-successful:
362373
if: always()
363374
runs-on: ubuntu-latest
364-
needs: [test, test-r-sanitizers, test-r-extra-checks]
375+
needs:
376+
- test
377+
- test-r-sanitizers
378+
- test-r-extra-checks
379+
permissions:
380+
statuses: read
365381
steps:
366382
- name: Note that all tests succeeded
367383
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2

0 commit comments

Comments
 (0)