Skip to content

Commit 967bda0

Browse files
committed
Re-write CI to use cargo-rbmt
Re-write CI to use the `cargo-rbmt` tool [0] This is quite an overhaul, some notes: - Adds action to install `cargo-rbmt` directly from the repo - Upgrades to checkout v5 (and uses explicit commit hash) - Uses ubuntu-24.04 instead of latest (I can't remember why we did this) - Defaults jobs to no permissions and uses read in each job - Gets the MSRV from manifest instead of explicitly - Removes the `Beta` toolchain test [0] https://github.com/rust-bitcoin/rust-bitcoin-maintainer-tools/tree/master/cargo-rbmt According to this AI agent (duckduckgo): > permissions: {} in a GitHub Actions workflow disables all > permissions for the GITHUB_TOKEN by default, meaning no access to > any repository resources unless explicitly granted. Copied from `rust-bitcoin`. Default to no permissions then give each job read perms.
1 parent b7fab3a commit 967bda0

File tree

5 files changed

+194
-130
lines changed

5 files changed

+194
-130
lines changed

.github/actions/prepare/action.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: 'Prepare Rust Environment'
2+
description: 'Setup Rust toolchain and install RBMT'
3+
inputs:
4+
toolchain:
5+
description: 'Rust toolchain to use (nightly reads from nightly-version file)'
6+
required: false
7+
default: 'stable'
8+
components:
9+
description: 'Rust components to install (e.g., clippy, rustfmt)'
10+
required: false
11+
default: ''
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: "Determine toolchain"
16+
id: toolchain
17+
shell: bash
18+
run: |
19+
if [ "${INPUTS_TOOLCHAIN}" = "nightly" ]; then
20+
TOOLCHAIN="$(cat nightly-version)"
21+
else
22+
TOOLCHAIN="${INPUTS_TOOLCHAIN}"
23+
fi
24+
echo "version=$TOOLCHAIN" >> $GITHUB_OUTPUT
25+
env:
26+
INPUTS_TOOLCHAIN: ${{ inputs.toolchain }}
27+
28+
- name: "Setup requested toolchain"
29+
uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2
30+
with:
31+
toolchain: ${{ steps.toolchain.outputs.version }}
32+
components: ${{ inputs.components }}
33+
34+
- name: "Install RBMT"
35+
shell: bash
36+
run: cargo install --git https://github.com/rust-bitcoin/rust-bitcoin-maintainer-tools.git --rev "$(cat rbmt-version)" cargo-rbmt --locked

.github/workflows/rust.yml

Lines changed: 137 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,90 +2,167 @@ on: [push, pull_request]
22

33
name: Continuous Integration
44

5+
permissions: {}
6+
57
jobs:
68
Prepare:
7-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-24.04
10+
permissions:
11+
contents: read
812
outputs:
913
nightly_version: ${{ steps.read_toolchain.outputs.nightly_version }}
14+
maintainer_tools_version: ${{ steps.read_toolchain.outputs.maintainer_tools_version }}
1015
steps:
1116
- name: "Checkout repo"
12-
uses: actions/checkout@v4
13-
- name: "Read nightly version"
17+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
18+
with:
19+
persist-credentials: false
20+
- name: "Read workspace versions"
1421
id: read_toolchain
15-
run: echo "nightly_version=$(cat nightly-version)" >> $GITHUB_OUTPUT
22+
run: |
23+
echo "nightly_version=$(cat nightly-version)" >> $GITHUB_OUTPUT
24+
echo "maintainer_tools_version=$(cat maintainer-tools-version)" >> $GITHUB_OUTPUT
1625
17-
Stable:
26+
Stable: # 2 jobs, one per manifest.
1827
name: Test - stable toolchain
19-
runs-on: ubuntu-latest
28+
runs-on: ubuntu-24.04
29+
permissions:
30+
contents: read
2031
strategy:
2132
fail-fast: false
33+
matrix:
34+
dep: [minimal, recent]
2235
steps:
23-
- name: Checkout Crate
24-
uses: actions/checkout@v4
25-
- name: Checkout Toolchain
26-
# https://github.com/dtolnay/rust-toolchain
27-
uses: dtolnay/rust-toolchain@stable
28-
- name: Running test script
29-
env:
30-
DO_LINT: true
31-
DO_DOCS: true
32-
DO_FEATURE_MATRIX: true
33-
run: ./contrib/test.sh
36+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
37+
with:
38+
persist-credentials: false
39+
- uses: ./.github/actions/prepare
40+
with:
41+
toolchain: stable
42+
- name: "Run tests"
43+
run: cargo rbmt test stable --lock-file ${{ matrix.dep }}
3444

35-
Beta:
36-
name: Test - beta toolchain
37-
runs-on: ubuntu-latest
45+
Nightly: # 2 jobs, one per manifest.
46+
name: Test - nightly toolchain
47+
runs-on: ubuntu-24.04
48+
permissions:
49+
contents: read
3850
strategy:
3951
fail-fast: false
52+
matrix:
53+
dep: [minimal, recent]
4054
steps:
41-
- name: Checkout Crate
42-
uses: actions/checkout@v4
43-
- name: Checkout Toolchain
44-
uses: dtolnay/rust-toolchain@beta
45-
- name: Running test script
46-
env:
47-
DO_FEATURE_MATRIX: true
48-
run: ./contrib/test.sh
55+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
56+
with:
57+
persist-credentials: false
58+
- uses: ./.github/actions/prepare
59+
with:
60+
toolchain: nightly
61+
- name: "Run tests"
62+
run: cargo rbmt test nightly --lock-file ${{ matrix.dep }}
4963

50-
Nightly:
51-
name: Test - nightly toolchain
52-
needs: Prepare
53-
runs-on: ubuntu-latest
64+
MSRV: # 2 jobs, one per manifest.
65+
name: Test - MSRV toolchain
66+
runs-on: ubuntu-24.04
67+
permissions:
68+
contents: read
5469
strategy:
5570
fail-fast: false
71+
matrix:
72+
dep: [minimal, recent]
5673
steps:
57-
- name: Checkout Crate
58-
uses: actions/checkout@v4
59-
- name: Checkout Toolchain
60-
uses: dtolnay/rust-toolchain@v1
74+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
6175
with:
62-
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
63-
- name: Running test script
64-
env:
65-
DO_DOCSRS: true
66-
DO_FMT: true
67-
DO_BENCH: true
68-
run: ./contrib/test.sh
76+
persist-credentials: false
77+
- uses: ./.github/actions/prepare
78+
with:
79+
toolchain: "1.56.1"
80+
- name: "Run tests"
81+
run: cargo rbmt test msrv --lock-file ${{ matrix.dep }}
6982

70-
MSRV:
71-
name: Test - 1.56.1 toolchain
72-
runs-on: ubuntu-latest
83+
Lint:
84+
name: Lint - nightly toolchain
85+
runs-on: ubuntu-24.04
86+
permissions:
87+
contents: read
7388
strategy:
7489
fail-fast: false
90+
matrix:
91+
dep: [recent]
7592
steps:
76-
- name: Checkout Crate
77-
uses: actions/checkout@v4
78-
- name: Checkout Toolchain
79-
uses: dtolnay/rust-toolchain@1.56.1
80-
- name: Running test script
81-
env:
82-
DO_FEATURE_MATRIX: true
83-
run: ./contrib/test.sh
93+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
94+
with:
95+
persist-credentials: false
96+
- uses: ./.github/actions/prepare
97+
with:
98+
toolchain: nightly
99+
components: clippy
100+
- name: "Run lint"
101+
run: cargo rbmt lint
102+
103+
Docs:
104+
name: Docs - stable toolchain
105+
runs-on: ubuntu-24.04
106+
permissions:
107+
contents: read
108+
strategy:
109+
fail-fast: false
110+
matrix:
111+
dep: [recent]
112+
steps:
113+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
114+
with:
115+
persist-credentials: false
116+
- uses: ./.github/actions/prepare
117+
with:
118+
toolchain: stable
119+
- name: "Build docs"
120+
run: cargo rbmt docs
121+
122+
Docsrs:
123+
name: Docs - nightly toolchain
124+
runs-on: ubuntu-24.04
125+
permissions:
126+
contents: read
127+
strategy:
128+
fail-fast: false
129+
matrix:
130+
dep: [recent]
131+
steps:
132+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
133+
with:
134+
persist-credentials: false
135+
- uses: ./.github/actions/prepare
136+
with:
137+
toolchain: nightly
138+
- name: "Build docs.rs docs"
139+
run: cargo rbmt docsrs
140+
141+
Bench:
142+
name: Bench - nightly toolchain
143+
runs-on: ubuntu-24.04
144+
permissions:
145+
contents: read
146+
strategy:
147+
fail-fast: false
148+
matrix:
149+
dep: [recent]
150+
steps:
151+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
152+
with:
153+
persist-credentials: false
154+
- uses: ./.github/actions/prepare
155+
with:
156+
toolchain: nightly
157+
- name: "Run benches"
158+
run: cargo rbmt test nightly --lock-file ${{ matrix.dep }}
84159

85160
EmbeddedWithAlloc:
86161
name: no_std with alloc
87162
needs: Prepare
88163
runs-on: ubuntu-latest
164+
permissions:
165+
contents: read
89166
strategy:
90167
fail-fast: false
91168
steps:
@@ -108,6 +185,8 @@ jobs:
108185
name: no_std no alloc
109186
needs: Prepare
110187
runs-on: ubuntu-latest
188+
permissions:
189+
contents: read
111190
strategy:
112191
fail-fast: false
113192
steps:
@@ -129,6 +208,8 @@ jobs:
129208
Arch32bit:
130209
name: Test 32-bit version
131210
runs-on: ubuntu-latest
211+
permissions:
212+
contents: read
132213
steps:
133214
- name: Checkout Crate
134215
uses: actions/checkout@v4
@@ -147,6 +228,8 @@ jobs:
147228
name: Cross test
148229
if: ${{ !github.event.act }}
149230
runs-on: ubuntu-latest
231+
permissions:
232+
contents: read
150233
steps:
151234
- name: Checkout Crate
152235
uses: actions/checkout@v4

contrib/test.sh

Lines changed: 0 additions & 76 deletions
This file was deleted.

rbmt-version

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
c37a8536c65560ae34e8c719750e26563ba65bd2
2+

rbmt.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Configuration for rbmt (Rust Bitcoin Maintainer Tools)
2+
3+
[test]
4+
# Examples to run with specific features enabled.
5+
# Format: "example_name:feature1 feature2"
6+
examples = []
7+
8+
# Features to test with the conventional `std` feature enabled.
9+
# Tests each feature alone with std, all pairs, and all together.
10+
features_with_std = ["serde", "arbitrary"]
11+
12+
# Features to test without the `std` feature.
13+
# Tests each feature alone, all pairs, and all together.
14+
features_without_std = ["alloc", "serde", "arbitrary"]
15+
16+
[lint]
17+
allowed_duplicates = [
18+
"hex-conservative",
19+
]

0 commit comments

Comments
 (0)