Skip to content

Commit 78cf7e4

Browse files
authored
CI: Hash-pin all actions, apply other suggestions from zizmor (#1702)
1 parent 7cad9f5 commit 78cf7e4

7 files changed

Lines changed: 97 additions & 43 deletions

File tree

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ updates:
66
directory: "/"
77
schedule:
88
interval: "daily"
9+
cooldown:
10+
default-days: 7
911
- package-ecosystem: cargo
1012
directory: "/"
1113
schedule:
1214
interval: daily
1315
time: "08:00"
1416
open-pull-requests-limit: 10
17+
cooldown:
18+
default-days: 7

.github/workflows/main.yml

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ concurrency:
1616
group: ${{ github.workflow }}-${{ github.ref || github.event.pull_request.number || github.sha }}
1717
cancel-in-progress: true
1818

19+
permissions: {}
20+
1921
jobs:
2022
test:
2123
name: Test
@@ -157,7 +159,9 @@ jobs:
157159
CC: clang-cl
158160
CXX: clang-cl
159161
steps:
160-
- uses: actions/checkout@v6
162+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
163+
with:
164+
persist-credentials: false
161165
- run: curl -vv https://static.rust-lang.org/dist/channel-rust-1.87.0.toml.sha256
162166
shell: bash
163167
- name: Install Rust (rustup)
@@ -214,14 +218,16 @@ jobs:
214218
UPPERCASE_TARGET_NAME=$(echo "${{ matrix.target }}" | tr '[:lower:]-' '[:upper:]_')
215219
echo "CARGO_TARGET_${UPPERCASE_TARGET_NAME}_LINKER=rust-lld" >> $GITHUB_ENV
216220
- name: setup dev environment
217-
uses: ilammy/msvc-dev-cmd@v1
221+
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
218222
if: startsWith(matrix.build, 'windows-clang')
219223

220-
- uses: taiki-e/install-action@cargo-nextest
224+
- uses: taiki-e/install-action@97a5807a604e12de3a13b52d868ebecaeeea757c # v2.75.4
221225
if: ${{ ! matrix.no_run }}
226+
with:
227+
tool: cargo-nextest
222228

223229
- run: cargo update
224-
- uses: Swatinem/rust-cache@v2
230+
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
225231
- name: Compile tests but not run
226232
if: matrix.no_run
227233
run: |
@@ -239,18 +245,22 @@ jobs:
239245
name: Test linker-plugin-lto
240246
runs-on: ubuntu-latest
241247
steps:
242-
- uses: actions/checkout@v6
248+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
249+
with:
250+
persist-credentials: false
243251
- name: Install Rust (rustup)
244252
run: |
245253
set -euxo pipefail
246254
rustup toolchain install stable --no-self-update --profile minimal
247255
rustup default stable
248256
shell: bash
249257

250-
- uses: taiki-e/install-action@cargo-nextest
258+
- uses: taiki-e/install-action@97a5807a604e12de3a13b52d868ebecaeeea757c # v2.75.4
259+
with:
260+
tool: cargo-nextest
251261

252262
- run: cargo update
253-
- uses: Swatinem/rust-cache@v2
263+
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
254264
- run: |
255265
cargo nextest run --workspace --release
256266
env:
@@ -284,7 +294,9 @@ jobs:
284294
- aarch64-apple-visionos
285295
- aarch64-apple-visionos-sim
286296
steps:
287-
- uses: actions/checkout@v6
297+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
298+
with:
299+
persist-credentials: false
288300
- name: Install Rust (rustup)
289301
run: |
290302
set -euxo pipefail
@@ -293,7 +305,7 @@ jobs:
293305
rustup default nightly
294306
shell: bash
295307
- run: cargo update
296-
- uses: Swatinem/rust-cache@v2
308+
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
297309
- run: cargo test -Z build-std=std --no-run --workspace --target ${{ matrix.target }}
298310
- run: cargo test -Z build-std=std --no-run --workspace --target ${{ matrix.target }} --release
299311
- run: cargo test -Z build-std=std --no-run --workspace --target ${{ matrix.target }} --features parallel
@@ -308,13 +320,15 @@ jobs:
308320
matrix:
309321
target: [wasm32-unknown-unknown]
310322
steps:
311-
- uses: actions/checkout@v6
323+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
324+
with:
325+
persist-credentials: false
312326
- name: Install Rust (rustup)
313327
run: |
314328
rustup target add ${{ matrix.target }}
315329
shell: bash
316330
- run: cargo update
317-
- uses: Swatinem/rust-cache@v2
331+
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
318332
- run: cargo test --no-run --target ${{ matrix.target }}
319333
- run: cargo test --no-run --target ${{ matrix.target }} --release
320334
- run: cargo test --no-run --target ${{ matrix.target }} --features parallel
@@ -334,7 +348,9 @@ jobs:
334348
env:
335349
TARGET: ${{ matrix.target }}
336350
steps:
337-
- uses: actions/checkout@v6
351+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
352+
with:
353+
persist-credentials: false
338354
- name: Install Rust (rustup)
339355
run: |
340356
rustup toolchain install nightly --no-self-update --profile minimal --target $TARGET
@@ -362,7 +378,7 @@ jobs:
362378
echo "WASI_SDK_PATH=$WASI_SDK_PATH" >> "$GITHUB_ENV"
363379
364380
- run: cargo update
365-
- uses: Swatinem/rust-cache@v2
381+
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
366382
with:
367383
env-vars: "WASI_TOOLCHAIN_VERSION"
368384
cache-all-crates: "true"
@@ -378,7 +394,9 @@ jobs:
378394
name: Test CUDA support
379395
runs-on: ubuntu-22.04
380396
steps:
381-
- uses: actions/checkout@v6
397+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
398+
with:
399+
persist-credentials: false
382400
- name: Install cuda-minimal-build-11-8
383401
working-directory: ${{ runner.temp }}
384402
shell: bash
@@ -390,8 +408,10 @@ jobs:
390408
sudo apt-get -y install cuda-minimal-build-11-8
391409
echo "/usr/local/cuda/bin" >> "$GITHUB_PATH"
392410
- run: cargo update
393-
- uses: taiki-e/install-action@cargo-nextest
394-
- uses: Swatinem/rust-cache@v2
411+
- uses: taiki-e/install-action@97a5807a604e12de3a13b52d868ebecaeeea757c # v2.75.4
412+
with:
413+
tool: cargo-nextest
414+
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
395415
- name: Test 'cudart' feature
396416
shell: bash
397417
run: |
@@ -411,7 +431,9 @@ jobs:
411431
env:
412432
MSRV: 1.63.0
413433
steps:
414-
- uses: actions/checkout@v6
434+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
435+
with:
436+
persist-credentials: false
415437
- name: Install Rust
416438
run: |
417439
rustup toolchain install $MSRV --no-self-update --profile minimal
@@ -420,21 +442,23 @@ jobs:
420442
shell: bash
421443
- name: Create Cargo.lock with minimal version
422444
run: cargo +nightly update -Zminimal-versions
423-
- uses: Swatinem/rust-cache@v2
445+
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
424446
- run: env -u CARGO_REGISTRIES_CRATES_IO_PROTOCOL cargo check --lib -p cc --locked
425447
- run: env -u CARGO_REGISTRIES_CRATES_IO_PROTOCOL cargo check --lib -p cc --locked --all-features
426448

427449
clippy:
428450
name: Clippy
429451
runs-on: ubuntu-latest
430452
steps:
431-
- uses: actions/checkout@v6
453+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
454+
with:
455+
persist-credentials: false
432456
- name: Install Rust
433457
run: |
434458
rustup toolchain install stable --no-self-update --profile minimal --component clippy
435459
rustup default stable
436460
shell: bash
437-
- uses: Swatinem/rust-cache@v2
461+
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
438462
- run: cargo clippy --no-deps
439463
# check that there are no uncommitted changes to prevent bugs like https://github.com/rust-lang/cc-rs/issues/1411
440464
- name: check clean Git workting tree
@@ -444,22 +468,26 @@ jobs:
444468
name: Rustfmt
445469
runs-on: ubuntu-latest
446470
steps:
447-
- uses: actions/checkout@v6
471+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
472+
with:
473+
persist-credentials: false
448474
- name: Install Rust
449475
run: |
450476
rustup toolchain install stable --no-self-update --profile minimal --component rustfmt
451477
rustup default stable
452478
shell: bash
453-
- uses: Swatinem/rust-cache@v2
479+
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
454480
- run: cargo fmt -- --check
455481

456482
semver-checks:
457483
runs-on: ubuntu-latest
458484
steps:
459485
- name: Checkout
460-
uses: actions/checkout@v6
486+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
487+
with:
488+
persist-credentials: false
461489
- name: Check semver
462-
uses: obi1kenobi/cargo-semver-checks-action@v2
490+
uses: obi1kenobi/cargo-semver-checks-action@6b69fcf40e9b5fb17adeb57e4b6ecd020649a239 # v2.9
463491
with:
464492
release-type: minor
465493

.github/workflows/publish.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Publish release
22

3-
permissions:
4-
pull-requests: write
5-
contents: write
6-
id-token: write # Required for OIDC token exchange
3+
permissions: {}
74

85
on:
96
push:
@@ -16,15 +13,22 @@ jobs:
1613
name: Release-plz release
1714
runs-on: ubuntu-latest
1815
environment: publish
16+
permissions:
17+
pull-requests: write
18+
contents: write
19+
id-token: write # Required for OIDC token exchange
1920
steps:
2021
- name: Checkout repository
21-
uses: actions/checkout@v6
22+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2223
with:
2324
fetch-depth: 0
25+
persist-credentials: false
2426
- name: Install Rust toolchain
25-
uses: dtolnay/rust-toolchain@stable
27+
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
28+
with:
29+
toolchain: stable
2630
- name: Run release-plz
27-
uses: release-plz/action@v0.5
31+
uses: release-plz/action@1528104d2ca23787631a1c1f022abb64b34c1e11 # v0.5.128
2832
with:
2933
command: release
3034
env:

.github/workflows/regenerate-target-info.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@ on:
1010
paths:
1111
- 'dev-tools/gen-target-info/**'
1212

13+
permissions: {}
14+
1315
jobs:
1416
regenerate:
1517
if: github.repository_owner == 'rust-lang'
1618
name: Regenerate target info & Open Pull Request if necessary
1719
runs-on: ubuntu-latest
20+
permissions:
21+
contents: write
22+
pull-requests: write
1823
steps:
19-
- uses: actions/checkout@v6
24+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2025
with:
2126
persist-credentials: true
2227

@@ -32,7 +37,7 @@ jobs:
3237
- name: Create lockfile
3338
run: cargo update
3439

35-
- uses: Swatinem/rust-cache@v2
40+
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
3641
with:
3742
cache-all-crates: 'true'
3843
- name: Regenerate target info

.github/workflows/regenerate-windows-sys.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@ on:
1010
paths:
1111
- 'dev-tools/gen-windows-sys-binding/**'
1212

13+
permissions: {}
14+
1315
jobs:
1416
regenerate:
1517
if: github.repository_owner == 'rust-lang'
1618
name: Regenerate windows sys bindings & Open Pull Request if necessary
1719
runs-on: ubuntu-latest
20+
permissions:
21+
contents: write
22+
pull-requests: write
1823
steps:
19-
- uses: actions/checkout@v6
24+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2025
with:
2126
persist-credentials: true
2227

@@ -27,7 +32,7 @@ jobs:
2732
- name: Create lockfile
2833
run: cargo update
2934

30-
- uses: Swatinem/rust-cache@v2
35+
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
3136
with:
3237
cache-all-crates: 'true'
3338

.github/workflows/release-pr.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Create release PR
22

3-
permissions:
4-
pull-requests: write
5-
contents: write
3+
permissions: {}
64

75
on:
86
workflow_dispatch: # Allow running on-demand
@@ -16,15 +14,21 @@ jobs:
1614
concurrency:
1715
group: release-plz-${{ github.ref }}
1816
cancel-in-progress: false
17+
permissions:
18+
pull-requests: write
19+
contents: write
1920
steps:
2021
- name: Checkout repository
21-
uses: actions/checkout@v6
22+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2223
with:
2324
fetch-depth: 0
25+
persist-credentials: true
2426
- name: Install Rust toolchain
25-
uses: dtolnay/rust-toolchain@stable
27+
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
28+
with:
29+
toolchain: stable
2630
- name: Run release-plz
27-
uses: release-plz/action@v0.5
31+
uses: release-plz/action@1528104d2ca23787631a1c1f022abb64b34c1e11 # v0.5.128
2832
with:
2933
command: release-pr
3034
env:

.github/workflows/test-rustc-targets.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ on:
1010
paths:
1111
- 'src/target/**'
1212

13+
permissions: {}
14+
1315
jobs:
1416
rustc_target_test:
1517
if: github.repository_owner == 'rust-lang'
1618
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write # Required to add issue comment
1721
steps:
18-
- uses: actions/checkout@v6
22+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1923
with:
2024
persist-credentials: true
2125

@@ -24,7 +28,7 @@ jobs:
2428
rustup toolchain install nightly --no-self-update --profile minimal
2529
rustup default nightly
2630
- run: cargo update
27-
- uses: Swatinem/rust-cache@v2
31+
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
2832

2933
- name: Test with `RUSTFLAGS=--cfg=rustc_target_test cargo test --lib`
3034
id: test

0 commit comments

Comments
 (0)