Skip to content

Commit 9f9dfc5

Browse files
ci: adopt hardened workflows from main
1 parent c1a6acd commit 9f9dfc5

1 file changed

Lines changed: 30 additions & 7 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ name: CI
33
on:
44
push:
55
branches: [main]
6+
paths-ignore: [".github/**"]
67
pull_request:
78
branches: [main]
9+
paths-ignore: [".github/**"]
10+
11+
# The crate jobs never need more than read access.
12+
permissions:
13+
contents: read
814

915
env:
1016
CARGO_TERM_COLOR: always
@@ -13,37 +19,47 @@ jobs:
1319
fmt:
1420
name: Format
1521
runs-on: ubuntu-latest
22+
timeout-minutes: 15
1623
steps:
1724
- uses: actions/checkout@v4
18-
- uses: dtolnay/rust-toolchain@stable
25+
# Pinned to the MSRV so rustfmt matches the version clippy/test use.
26+
- uses: dtolnay/rust-toolchain@ffaa7fb73f2b6e3c49bc425913220fa3d71c3ee5 # 1.92.0
1927
with:
2028
components: rustfmt
2129
- run: cargo fmt --all --check
2230

2331
clippy:
2432
name: Clippy (${{ matrix.features }})
2533
runs-on: ubuntu-latest
34+
timeout-minutes: 45
2635
strategy:
2736
fail-fast: false
2837
matrix:
2938
features: ["--no-default-features", "--no-default-features --features node", "--no-default-features --features indexer", "--no-default-features --features wallet", "--no-default-features --features crypto", "--all-features"]
3039
steps:
3140
- uses: actions/checkout@v4
32-
- uses: dtolnay/rust-toolchain@1.92.0
41+
- uses: dtolnay/rust-toolchain@ffaa7fb73f2b6e3c49bc425913220fa3d71c3ee5 # 1.92.0
3342
with:
3443
components: clippy
35-
- run: cargo clippy ${{ matrix.features }} --all-targets -- -D warnings
44+
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2
45+
with:
46+
key: ${{ matrix.features }}
47+
- run: cargo clippy ${{ matrix.features }} --all-targets --locked -- -D warnings
3648

3749
test:
3850
name: Test (${{ matrix.features }})
3951
runs-on: ubuntu-latest
52+
timeout-minutes: 45
4053
strategy:
4154
fail-fast: false
4255
matrix:
4356
features: ["--no-default-features", "--no-default-features --features node", "--no-default-features --features indexer", "--no-default-features --features wallet", "--no-default-features --features crypto", "--all-features"]
4457
steps:
4558
- uses: actions/checkout@v4
46-
- uses: dtolnay/rust-toolchain@1.92.0
59+
- uses: dtolnay/rust-toolchain@ffaa7fb73f2b6e3c49bc425913220fa3d71c3ee5 # 1.92.0
60+
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2
61+
with:
62+
key: ${{ matrix.features }}
4763
- run: cargo test ${{ matrix.features }} --locked
4864

4965
# Cross-platform test gate, mirroring mintlayer-core's build.yml: the full
@@ -55,6 +71,7 @@ jobs:
5571
matrix:
5672
os: [ubuntu-latest, macos-latest, windows-latest]
5773
runs-on: ${{ matrix.os }}
74+
timeout-minutes: 60
5875
steps:
5976
- name: Shorten CARGO_HOME on Windows
6077
if: runner.os == 'Windows'
@@ -64,23 +81,29 @@ jobs:
6481
# build.yml does this).
6582
run: echo "CARGO_HOME=C:\crg" >> "$GITHUB_ENV"
6683
- uses: actions/checkout@v4
67-
- uses: dtolnay/rust-toolchain@1.92.0
84+
- uses: dtolnay/rust-toolchain@ffaa7fb73f2b6e3c49bc425913220fa3d71c3ee5 # 1.92.0
85+
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2
86+
with:
87+
key: ${{ matrix.os }}
6888
- run: cargo build --all-features --locked --examples
6989
- run: cargo test --all-features --locked
7090

7191
doc:
7292
name: Documentation
7393
runs-on: ubuntu-latest
94+
timeout-minutes: 30
7495
steps:
7596
- uses: actions/checkout@v4
76-
- uses: dtolnay/rust-toolchain@1.92.0
77-
- run: cargo doc --all-features --no-deps
97+
- uses: dtolnay/rust-toolchain@ffaa7fb73f2b6e3c49bc425913220fa3d71c3ee5 # 1.92.0
98+
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2
99+
- run: cargo doc --all-features --locked --no-deps
78100
env:
79101
RUSTDOCFLAGS: -D warnings
80102

81103
license:
82104
name: License headers
83105
runs-on: ubuntu-latest
106+
timeout-minutes: 15
84107
steps:
85108
- uses: actions/checkout@v4
86109
- run: ./scripts/check-license.sh

0 commit comments

Comments
 (0)