Skip to content

Commit ab5a348

Browse files
ci: leverage rust-toolchain.toml file in ci workflows
1 parent aa6bea0 commit ab5a348

File tree

3 files changed

+52
-49
lines changed

3 files changed

+52
-49
lines changed

.github/workflows/cont_integration.yml

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,77 +8,81 @@ env:
88
CARGO_TERM_COLOR: always
99

1010
jobs:
11-
prepare:
12-
runs-on: ubuntu-latest
13-
outputs:
14-
rust_version: ${{ steps.read_toolchain.outputs.rust_version }}
11+
build-test-msrv:
12+
name: Build & Test MSRV
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os:
17+
- ubuntu-latest
18+
- ubuntu-24.04-arm
19+
features:
20+
- --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
21+
- --all-features
1522
steps:
16-
- name: "Checkout repo"
23+
- name: Checkout
1724
uses: actions/checkout@v4
1825
with:
1926
persist-credentials: false
20-
- name: "Read rust version"
21-
id: read_toolchain
22-
run: echo "rust_version=$(cat rust-version)" >> $GITHUB_OUTPUT
27+
# The 'toolchain' argument on this action overrides the Rust compiler version set in rust-toolchain.toml
28+
# in order to test our MSRV.
29+
- name: Install Rust toolchain
30+
uses: actions-rust-lang/setup-rust-toolchain@v1
31+
with:
32+
toolchain: 1.85 # MSRV
33+
cache: true
34+
- name: Pin dependencies for MSRV
35+
run: ./ci/pin-msrv.sh
36+
- name: Build + Test
37+
run: |
38+
cargo build --workspace --all-targets ${{ matrix.features }}
39+
cargo test --workspace ${{ matrix.features }}
2340
24-
build-test:
25-
needs: prepare
26-
name: Build & Test
41+
build-test-stable:
42+
name: Build & Test Rust Stable
2743
runs-on: ${{ matrix.os }}
2844
strategy:
2945
matrix:
3046
os:
3147
- ubuntu-latest
3248
- ubuntu-24.04-arm
33-
rust:
34-
- version: ${{ needs.prepare.outputs.rust_version }}
35-
- version: 1.85.0 # MSRV
3649
features:
3750
- --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
3851
- --all-features
3952
steps:
40-
- name: checkout
53+
- name: Checkout
4154
uses: actions/checkout@v4
4255
with:
4356
persist-credentials: false
57+
# This action will honor the Rust compiler version set in rust-toolchain.toml. We aim to keep it in sync with
58+
# Rust stable.
4459
- name: Install Rust toolchain
45-
uses: dtolnay/rust-toolchain@v1
60+
uses: actions-rust-lang/setup-rust-toolchain@v1
4661
with:
47-
toolchain: ${{ matrix.rust.version }}
48-
- name: Rust Cache
49-
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0
50-
- name: Pin dependencies for MSRV
51-
if: matrix.rust.version == '1.85.0'
52-
run: ./ci/pin-msrv.sh
62+
cache: true
5363
- name: Build + Test
54-
env:
55-
MATRIX_RUST_VERSION: ${{ matrix.rust.version }}
5664
run: |
5765
cargo build --workspace --all-targets ${{ matrix.features }}
5866
cargo test --workspace ${{ matrix.features }}
5967
6068
check-no-std:
61-
needs: prepare
6269
name: Check no_std
6370
runs-on: ubuntu-latest
6471
steps:
6572
- name: Checkout
6673
uses: actions/checkout@v4
6774
with:
6875
persist-credentials: false
76+
# This action automatically reads and applies rust-toolchain.toml
6977
- name: Install Rust toolchain
70-
uses: dtolnay/rust-toolchain@v1
78+
uses: actions-rust-lang/setup-rust-toolchain@v1
7179
with:
72-
toolchain: ${{ needs.prepare.outputs.rust_version }}
73-
# target: "thumbv6m-none-eabi"
74-
- name: Rust Cache
75-
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0
80+
cache: true
7681
- name: Check no-std
7782
# TODO "--target thumbv6m-none-eabi" should work but currently does not
7883
run: cargo check --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
7984

8085
check-wasm:
81-
needs: prepare
8286
name: Check WASM
8387
runs-on: ubuntu-latest
8488
env:
@@ -93,15 +97,16 @@ jobs:
9397
- run: wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - || exit 1
9498
- run: sudo apt-get update || exit 1
9599
- run: sudo apt-get install -y libclang-common-14-dev clang-14 libc6-dev-i386 || exit 1
100+
# This action automatically reads and applies rust-toolchain.toml
96101
- name: Install Rust toolchain
97-
uses: dtolnay/rust-toolchain@v1
102+
uses: actions-rust-lang/setup-rust-toolchain@v1
98103
with:
99-
toolchain: ${{ needs.prepare.outputs.rust_version }}
100-
targets: "wasm32-unknown-unknown"
101-
- name: Rust Cache
102-
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0
104+
cache: true
105+
target: wasm32-unknown-unknown
103106
- name: Check WASM
104-
run: cargo check --target wasm32-unknown-unknown --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
107+
run: |
108+
rustup target add wasm32-unknown-unknown
109+
cargo check --target wasm32-unknown-unknown --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
105110
106111
fmt:
107112
name: Rust fmt
@@ -111,30 +116,29 @@ jobs:
111116
uses: actions/checkout@v4
112117
with:
113118
persist-credentials: false
119+
# This action automatically reads and applies rust-toolchain.toml
114120
- name: Install Rust toolchain
115-
uses: dtolnay/rust-toolchain@v1
121+
uses: actions-rust-lang/setup-rust-toolchain@v1
116122
with:
117-
toolchain: nightly
118-
components: rustfmt
123+
cache: true
119124
- name: Check fmt
120125
run: cargo fmt --all --check
121126

122127
clippy_check:
123-
needs: prepare
124128
name: Rust clippy
125129
runs-on: ubuntu-latest
126130
permissions:
127131
checks: write
128132
steps:
129-
- uses: actions/checkout@v4
133+
- name: Checkout
134+
uses: actions/checkout@v4
130135
with:
131136
persist-credentials: false
132-
- uses: dtolnay/rust-toolchain@v1
137+
# This action automatically reads and applies rust-toolchain.toml
138+
- name: Install Rust toolchain
139+
uses: actions-rust-lang/setup-rust-toolchain@v1
133140
with:
134-
toolchain: ${{ needs.prepare.outputs.rust_version }}
135-
components: clippy
136-
- name: Rust Cache
137-
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0
141+
cache: true
138142
- name: Clippy
139143
run: cargo clippy --all-features --all-targets -- -D warnings
140144

.github/zizmor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ rules:
44
config:
55
policies:
66
# Allow pin by ref/tag
7-
dtolnay/rust-toolchain: ref-pin
7+
actions-rust-lang/setup-rust-toolchain: ref-pin

rust-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)