Skip to content

Commit f2af67d

Browse files
committed
Merge #320: Feature/ci rbmt
e3147ff ci: run Rust workflow through cargo-rbmt (Kyryl R) 53a4f3f ci: install cargo-rbmt in GitHub Actions (Kyryl R) 02807e7 lint: satisfy cargo-rbmt no-default clippy (Kyryl R) 80c15a2 lint: prepare manifests for cargo-rbmt lint (Kyryl R) b7f318b ci: pin cargo-rbmt inputs (Kyryl R) Pull request description: Fixes: #267 ACKs for top commit: apoelstra: ACK e3147ff; successfully ran local tests; this looks great! Tree-SHA512: 736b76fbeac1a86779e84cdb8b45a1d3f9f1bee784f96ca131db0c89ce9696de068c009121fbc22ca26a91213eda47e6b4f983c8eb0ce2f6e2da656704f48644
2 parents 5f1811d + e3147ff commit f2af67d

11 files changed

Lines changed: 85 additions & 161 deletions

File tree

.github/actions/checkout-maintainer-tools/action.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Setup RBMT
2+
description: Install cargo-rbmt and pinned Rust toolchains.
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Install cargo-rbmt
8+
shell: bash
9+
run: |
10+
cargo install \
11+
--git https://github.com/rust-bitcoin/rust-bitcoin-maintainer-tools \
12+
--rev "$(cat "${GITHUB_WORKSPACE}/rbmt-version")" \
13+
cargo-rbmt \
14+
--locked
15+
16+
- name: Install Rust toolchains
17+
shell: bash
18+
run: cargo rbmt toolchains

.github/workflows/rust.yml

Lines changed: 32 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,20 @@ on: # yamllint disable-line rule:truthy
88
name: Continuous integration
99

1010
jobs:
11-
Prepare:
12-
runs-on: ubuntu-latest
13-
outputs:
14-
nightly_version: ${{ steps.read_toolchain.outputs.nightly_version }}
15-
msrv_version: ${{ steps.read_msrv.outputs.msrv_version }}
16-
steps:
17-
- name: "Checkout repo"
18-
uses: actions/checkout@v4
19-
- name: "Read nightly version"
20-
id: read_toolchain
21-
run: |
22-
set -euo pipefail
23-
version=$(cat nightly-version)
24-
echo "nightly_version=$version" >> $GITHUB_OUTPUT
25-
- name: Read MSRV from clippy.toml
26-
id: read_msrv
27-
run: |
28-
set -euo pipefail
29-
msrv=$(grep '^msrv *= *"' clippy.toml | sed -E 's/.*"([^"]+)".*/\1/')
30-
echo "msrv_version=$msrv" >> "$GITHUB_OUTPUT"
31-
32-
Stable:
33-
name: Test - stable toolchain
11+
Test:
12+
name: Test - ${{ matrix.toolchain }} toolchain
3413
runs-on: ubuntu-latest
3514
strategy:
3615
fail-fast: false
16+
matrix:
17+
toolchain: [stable, nightly, msrv]
3718
steps:
3819
- name: "Checkout repo"
3920
uses: actions/checkout@v4
40-
- name: "Checkout maintainer tools"
41-
uses: ./.github/actions/checkout-maintainer-tools
42-
- name: "Select toolchain"
43-
uses: dtolnay/rust-toolchain@stable
44-
- name: "Run test script"
45-
run: ./maintainer-tools/ci/run_task.sh stable
21+
- name: "Setup cargo-rbmt"
22+
uses: ./.github/actions/setup-rbmt
23+
- name: "Run tests"
24+
run: cargo rbmt --lock-file existing test --toolchain ${{ matrix.toolchain }}
4625

4726
Windows:
4827
name: Test - Windows stable toolchain
@@ -57,118 +36,33 @@ jobs:
5736
- name: "Run tests"
5837
run: cargo test
5938

60-
Nightly:
61-
name: Test - nightly toolchain
62-
needs: Prepare
63-
runs-on: ubuntu-latest
64-
strategy:
65-
fail-fast: false
66-
steps:
67-
- name: "Checkout repo"
68-
uses: actions/checkout@v4
69-
- name: "Checkout maintainer tools"
70-
uses: ./.github/actions/checkout-maintainer-tools
71-
- name: "Select toolchain"
72-
uses: dtolnay/rust-toolchain@v1
73-
with:
74-
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
75-
- name: "Run test script"
76-
run: ./maintainer-tools/ci/run_task.sh nightly
77-
78-
MSRV:
79-
name: Test - MSRV
80-
needs: Prepare
81-
runs-on: ubuntu-latest
82-
strategy:
83-
fail-fast: false
84-
steps:
85-
- name: "Checkout repo"
86-
uses: actions/checkout@v4
87-
- name: "Checkout maintainer tools"
88-
uses: ./.github/actions/checkout-maintainer-tools
89-
- name: "Select toolchain"
90-
uses: dtolnay/rust-toolchain@stable
91-
with:
92-
toolchain: ${{ needs.Prepare.outputs.msrv_version }}
93-
- name: "Run test script"
94-
run: ./maintainer-tools/ci/run_task.sh msrv
95-
96-
Lint:
97-
name: Lint - nightly toolchain
98-
needs: Prepare
99-
runs-on: ubuntu-latest
100-
strategy:
101-
fail-fast: false
102-
matrix:
103-
dep: [recent]
104-
steps:
105-
- name: "Checkout repo"
106-
uses: actions/checkout@v4
107-
- name: "Checkout maintainer tools"
108-
uses: ./.github/actions/checkout-maintainer-tools
109-
- name: "Select toolchain"
110-
uses: dtolnay/rust-toolchain@v1
111-
with:
112-
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
113-
- name: Install clippy
114-
run: rustup component add clippy
115-
- name: "Run test script"
116-
run: ./maintainer-tools/ci/run_task.sh lint
117-
118-
Docs:
119-
name: Docs - stable toolchain
120-
runs-on: ubuntu-latest
121-
strategy:
122-
fail-fast: false
123-
matrix:
124-
dep: [recent]
125-
steps:
126-
- name: "Checkout repo"
127-
uses: actions/checkout@v4
128-
- name: "Checkout maintainer tools"
129-
uses: ./.github/actions/checkout-maintainer-tools
130-
- name: "Select toolchain"
131-
uses: dtolnay/rust-toolchain@stable
132-
- name: "Run test script"
133-
run: ./maintainer-tools/ci/run_task.sh docs
134-
135-
Docsrs:
136-
name: Docs - nightly toolchain
137-
needs: Prepare
39+
Check:
40+
name: Check - ${{ matrix.task }}
13841
runs-on: ubuntu-latest
13942
strategy:
14043
fail-fast: false
14144
matrix:
142-
dep: [recent]
45+
task: [lint, docs, docsrs]
14346
steps:
14447
- name: "Checkout repo"
14548
uses: actions/checkout@v4
146-
- name: "Checkout maintainer tools"
147-
uses: ./.github/actions/checkout-maintainer-tools
148-
- name: "Select toolchain"
149-
uses: dtolnay/rust-toolchain@v1
150-
with:
151-
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
152-
- name: "Run test script"
153-
run: ./maintainer-tools/ci/run_task.sh docsrs
49+
- name: "Setup cargo-rbmt"
50+
uses: ./.github/actions/setup-rbmt
51+
- name: "Run ${{ matrix.task }}"
52+
run: cargo rbmt --lock-file existing ${{ matrix.task }}
15453

15554
Format:
156-
name: Format - nightly toolchain
157-
needs: Prepare
55+
name: Format
15856
runs-on: ubuntu-latest
15957
strategy:
16058
fail-fast: false
16159
steps:
16260
- name: "Checkout repo"
16361
uses: actions/checkout@v4
164-
- name: "Select toolchain"
165-
uses: dtolnay/rust-toolchain@v1
166-
with:
167-
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
168-
- name: "Install rustfmt"
169-
run: rustup component add rustfmt
62+
- name: "Setup cargo-rbmt"
63+
uses: ./.github/actions/setup-rbmt
17064
- name: "Check formatting"
171-
run: cargo fmt --all -- --check
65+
run: cargo rbmt fmt --check
17266

17367
Wasm:
17468
name: Check WASM
@@ -185,31 +79,30 @@ jobs:
18579

18680
Fuzz:
18781
name: Check Fuzz
188-
needs: Prepare
18982
runs-on: ubuntu-latest
19083
strategy:
19184
fail-fast: false
19285
steps:
19386
- name: "Checkout repo"
19487
uses: actions/checkout@v4
19588

196-
- name: "Select nightly toolchain"
197-
uses: dtolnay/rust-toolchain@v1
198-
with:
199-
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
89+
- name: "Setup cargo-rbmt"
90+
uses: ./.github/actions/setup-rbmt
91+
92+
- name: "Install cargo-fuzz"
93+
run: cargo rbmt tools cargo-fuzz
20094

20195
- name: "Check fuzz crate"
202-
run: |
203-
cargo check --manifest-path=fuzz/Cargo.toml
96+
run: cargo rbmt --lock-file existing run --toolchain nightly -- check --manifest-path fuzz/Cargo.toml
20497

205-
- name: "Install cargo-fuzz"
206-
run: |
207-
cargo install cargo-fuzz --locked
98+
- name: "Run fuzz target unit tests"
99+
run: cargo rbmt --lock-file existing run --toolchain nightly -- test --manifest-path fuzz/Cargo.toml --bins
208100

209-
- name: "Run cargo-fuzz"
101+
- name: "Run cargo-fuzz smoke tests"
210102
run: |
211103
set -euo pipefail
104+
export RUSTUP_TOOLCHAIN="$(cargo rbmt toolchains --nightly)"
212105
cargo fuzz list --fuzz-dir fuzz | while read -r target; do
213-
echo "fuzzing $target"
214-
cargo fuzz run --fuzz-dir fuzz "$target" -- -runs=1
215-
done
106+
echo "fuzzing $target"
107+
cargo fuzz run --fuzz-dir fuzz "$target" -- -runs=1
108+
done

Cargo.toml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ edition = "2021"
1010
rust-version = "1.79.0"
1111
default-run = "simc"
1212

13+
[package.metadata.rbmt.lint]
14+
# Existing transitive split: derive_arbitrary uses syn 1 while serde/wasm tooling uses syn 2.
15+
allowed_duplicates = ["syn"]
16+
1317
[lib]
1418
name = "simplicityhl"
1519
path = "src/lib.rs"
@@ -47,6 +51,13 @@ getrandom = { version = "0.2", features = ["js"] }
4751
members = ["codegen", "fuzz"]
4852
exclude = ["bitcoind-tests", "lsp"]
4953

54+
[workspace.metadata.rbmt.toolchains]
55+
nightly = "nightly-2025-08-23"
56+
stable = "1.95.0"
57+
58+
[workspace.metadata.rbmt.tools]
59+
cargo-fuzz = "0.13.1"
60+
5061
[lints.clippy]
5162
# Exclude lints we don't think are valuable.
5263
large_enum_variant = "allow" # docs say "measure before paying attention to this"; why is it on by default??
@@ -75,7 +86,7 @@ copy_iterator = "warn"
7586
default_trait_access = "warn"
7687
doc_link_with_quotes = "warn"
7788
doc_markdown = "warn"
78-
empty_enums = "warn"
89+
empty_enum = "warn"
7990
enum_glob_use = "allow"
8091
expl_impl_clone_on_copy = "warn"
8192
explicit_deref_methods = "warn"
@@ -159,7 +170,7 @@ struct_field_names = "warn"
159170
too_many_lines = "allow"
160171
transmute_ptr_to_ptr = "warn"
161172
trivially_copy_pass_by_ref = "warn"
162-
unchecked_time_subtraction = "warn"
173+
unchecked_duration_subtraction = "warn"
163174
unicode_not_nfc = "warn"
164175
unnecessary_box_returns = "warn"
165176
unnecessary_join = "warn"

clippy.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
msrv = "1.79.0"
21
# We have an error type, `RichError`, of size 144. This is pushing it but probably fine.
32
large-error-threshold = 145
43

5-
doc-valid-idents = [ "SimplicityHL" ]
4+
doc-valid-idents = [ "SimplicityHL" ]

codegen/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "codegen"
33
version = "0.1.0"
44
edition = "2021"
5+
rust-version = "1.79.0"
56
description = "Generator of Rust code as interface between SimplicityHL and Rust."
67
publish = false
78

fuzz/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ name = "simplicityhl-fuzz"
33
version = "0.0.0"
44
publish = false
55
edition = "2021"
6+
rust-version = "1.79.0"
67

78
[package.metadata]
89
cargo-fuzz = true
910

11+
[package.metadata.rbmt.lint]
12+
# Existing transitive split: derive_arbitrary uses syn 1 while serde/wasm tooling uses syn 2.
13+
allowed_duplicates = ["syn"]
14+
1015
[dependencies]
1116
libfuzzer-sys = "0.4"
1217
arbitrary = { version = "1", features = ["derive"] }

nightly-version

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

rbmt-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1778ab50a2a0cb23fc23c20a47532a6eceb637e1

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ pub(crate) mod tests {
554554
}
555555
}
556556

557+
#[cfg(feature = "serde")]
557558
pub fn get_encoding(self) -> String {
558559
let program_bytes = self.program.commit().to_vec_without_witness();
559560
Base64Display::new(&program_bytes, &STANDARD).to_string()
@@ -615,6 +616,7 @@ pub(crate) mod tests {
615616
}
616617
}
617618

619+
#[cfg(feature = "serde")]
618620
pub fn get_encoding_with_witness(self) -> (String, String) {
619621
let (program_bytes, witness_bytes) = self.program.redeem().to_vec_with_witness();
620622
(

0 commit comments

Comments
 (0)