Skip to content

Commit 24a8d0c

Browse files
committed
Merge rust-bitcoin#5158: Add maintainer-tools support to the justfile
74052cd Add maintainer-tools support to the justfile (Nick Johnson) Pull request description: Testing the waters here a bit to see if this is a pain point for others. Happy to iterate on it in the background and prioritize other things. The justfile is a nice interface for local development, but ideally its logic is the exact same as what runs in CI to minimize wasted cycles found only in CI. This patch introduces teh maintianer-tools-version file as the source of truth for the version of CI script used in the workspace. The CI tooling as well as the justfile have been updated to pull from it. The justfile has also been extended with recipes which match the CI tasks as close as possible. Explicit rustup commands were introduced to the justfile with the new "ci" recipe. This isn't expanding scope though since rustup was already implicitly required by tasks like "format" which use the +toolchain syntax. ACKs for top commit: apoelstra: ACK 74052cd; successfully ran local tests tcharding: ACK 74052cd Tree-SHA512: db2ac558f1bbad25070f6516ca3eb3804fa786fbeb3c7d57f2443e7ddacecbac78bda048c6544a361a800325910639387bc6fb2a1989343bc02200e3d54e8471
2 parents ef9a3db + 74052cd commit 24a8d0c

File tree

5 files changed

+79
-22
lines changed

5 files changed

+79
-22
lines changed

.github/workflows/rust.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@ jobs:
1313
runs-on: ubuntu-24.04
1414
outputs:
1515
nightly_version: ${{ steps.read_toolchain.outputs.nightly_version }}
16+
maintainer_tools_version: ${{ steps.read_toolchain.outputs.maintainer_tools_version }}
1617
steps:
1718
- name: "Checkout repo"
1819
uses: actions/checkout@v5
19-
- name: "Read nightly version"
20+
- name: "Read workspace versions"
2021
id: read_toolchain
21-
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
2225
2326
Stable: # 2 jobs, one per manifest.
2427
name: Test - stable toolchain
28+
needs: Prepare
2529
runs-on: ubuntu-24.04
2630
strategy:
2731
fail-fast: false
@@ -34,7 +38,7 @@ jobs:
3438
uses: actions/checkout@v5
3539
with:
3640
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
37-
ref: 22eff1e5c114949d4b88a24735da38b37e7984fb
41+
ref: ${{ needs.Prepare.outputs.maintainer_tools_version }}
3842
path: maintainer-tools
3943
- name: "Select toolchain"
4044
uses: dtolnay/rust-toolchain@stable
@@ -58,7 +62,7 @@ jobs:
5862
uses: actions/checkout@v5
5963
with:
6064
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
61-
ref: 22eff1e5c114949d4b88a24735da38b37e7984fb
65+
ref: ${{ needs.Prepare.outputs.maintainer_tools_version }}
6266
path: maintainer-tools
6367
- name: "Select toolchain"
6468
uses: dtolnay/rust-toolchain@v1
@@ -71,6 +75,7 @@ jobs:
7175

7276
MSRV: # 2 jobs, one per manifest.
7377
name: Test - MSRV toolchain
78+
needs: Prepare
7479
runs-on: ubuntu-24.04
7580
strategy:
7681
fail-fast: false
@@ -83,7 +88,7 @@ jobs:
8388
uses: actions/checkout@v5
8489
with:
8590
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
86-
ref: 22eff1e5c114949d4b88a24735da38b37e7984fb
91+
ref: ${{ needs.Prepare.outputs.maintainer_tools_version }}
8792
path: maintainer-tools
8893
- name: "Select toolchain"
8994
uses: dtolnay/rust-toolchain@stable
@@ -109,7 +114,7 @@ jobs:
109114
uses: actions/checkout@v5
110115
with:
111116
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
112-
ref: 22eff1e5c114949d4b88a24735da38b37e7984fb
117+
ref: ${{ needs.Prepare.outputs.maintainer_tools_version }}
113118
path: maintainer-tools
114119
- name: "Select toolchain"
115120
uses: dtolnay/rust-toolchain@v1
@@ -124,6 +129,7 @@ jobs:
124129

125130
Docs:
126131
name: Docs - stable toolchain
132+
needs: Prepare
127133
runs-on: ubuntu-24.04
128134
strategy:
129135
fail-fast: false
@@ -136,7 +142,7 @@ jobs:
136142
uses: actions/checkout@v5
137143
with:
138144
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
139-
ref: 22eff1e5c114949d4b88a24735da38b37e7984fb
145+
ref: ${{ needs.Prepare.outputs.maintainer_tools_version }}
140146
path: maintainer-tools
141147
- name: "Select toolchain"
142148
uses: dtolnay/rust-toolchain@stable
@@ -160,7 +166,7 @@ jobs:
160166
uses: actions/checkout@v5
161167
with:
162168
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
163-
ref: 22eff1e5c114949d4b88a24735da38b37e7984fb
169+
ref: ${{ needs.Prepare.outputs.maintainer_tools_version }}
164170
path: maintainer-tools
165171
- name: "Select toolchain"
166172
uses: dtolnay/rust-toolchain@v1
@@ -186,7 +192,7 @@ jobs:
186192
uses: actions/checkout@v5
187193
with:
188194
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
189-
ref: 22eff1e5c114949d4b88a24735da38b37e7984fb
195+
ref: ${{ needs.Prepare.outputs.maintainer_tools_version }}
190196
path: maintainer-tools
191197
- name: "Select toolchain"
192198
uses: dtolnay/rust-toolchain@v1
@@ -335,8 +341,6 @@ jobs:
335341
steps:
336342
- name: "Checkout repo"
337343
uses: actions/checkout@v5
338-
- name: "Checkout maintainer tools"
339-
uses: actions/checkout@v5
340344
- name: "Select toolchain"
341345
uses: dtolnay/rust-toolchain@stable
342346
- name: "Run policy script"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ mutants.out*
1919
# Fuzz artifacts
2020
hfuzz_target
2121
hfuzz_workspace
22+
23+
# Local tooling
24+
.maintainer-tools

contrib/ensure-maintainer-tools.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Ensure maintainer tools are available locally for CI task execution.
4+
5+
set -euo pipefail
6+
7+
REPO_DIR=$(git rev-parse --show-toplevel)
8+
MAINTAINER_TOOLS_REF=$(cat "$REPO_DIR/maintainer-tools-version")
9+
10+
cd "$REPO_DIR"
11+
12+
if [ ! -d ".maintainer-tools" ]; then
13+
echo "Fetching maintainer tools..."
14+
git clone "https://github.com/rust-bitcoin/rust-bitcoin-maintainer-tools.git" ".maintainer-tools"
15+
cd ".maintainer-tools"
16+
git checkout "$MAINTAINER_TOOLS_REF"
17+
else
18+
cd ".maintainer-tools"
19+
CURRENT_REF=$(git rev-parse HEAD)
20+
if [ "$CURRENT_REF" != "$MAINTAINER_TOOLS_REF" ]; then
21+
echo "Updating maintainer tools to $MAINTAINER_TOOLS_REF"
22+
git fetch
23+
git checkout "$MAINTAINER_TOOLS_REF"
24+
fi
25+
fi
26+
27+
if ! command -v jq >/dev/null 2>&1; then
28+
echo "Error: jq is required for maintainer tools but not found in PATH" >&2
29+
echo "Please install jq or ensure it's available in your environment" >&2
30+
exit 1
31+
fi

justfile

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,39 @@
11
set positional-arguments
22

3+
NIGHTLY_VERSION := `cat nightly-version`
4+
35
alias ulf := update-lock-files
46

57
default:
68
@just --list
79

10+
# Run the given CI task using maintainer tools.
11+
@ci task toolchain="stable" lock="recent":
12+
{{justfile_directory()}}/contrib/ensure-maintainer-tools.sh
13+
cp -f {{justfile_directory()}}/Cargo-{{lock}}.lock {{justfile_directory()}}/Cargo.lock
14+
rustup run {{toolchain}} {{justfile_directory()}}/.maintainer-tools/ci/run_task.sh {{task}}
15+
16+
# Test with stable toolchain.
17+
test-stable: (ci "stable")
18+
19+
# Test with nightly toolchain.
20+
test-nightly: (ci "nightly")
21+
22+
# Test with MSRV toolchain.
23+
test-msrv: (ci "msrv")
24+
25+
# Lint workspace.
26+
lint: (ci "lint" NIGHTLY_VERSION)
27+
28+
# Generate documentation.
29+
docs: (ci "docs")
30+
31+
# Generate documentation with nightly.
32+
docsrs: (ci "docsrs" NIGHTLY_VERSION)
33+
34+
# Run benchmarks.
35+
bench: (ci "bench")
36+
837
# Cargo build everything.
938
build:
1039
cargo build --workspace --all-targets --all-features
@@ -13,12 +42,6 @@ build:
1342
check:
1443
cargo check --workspace --all-targets --all-features
1544

16-
# Lint everything.
17-
lint:
18-
cargo +$(cat ./nightly-version) clippy --workspace --all-targets --all-features -- --deny warnings
19-
# lint warnings get inhibited unless we use `--nocapture`
20-
cargo test --quiet --workspace --doc -- --nocapture
21-
2245
# Run cargo fmt
2346
fmt:
2447
cargo +$(cat ./nightly-version) fmt --all
@@ -27,10 +50,6 @@ fmt:
2750
format:
2851
cargo +$(cat ./nightly-version) fmt --all --check
2952

30-
# Generate documentation.
31-
docsrs *flags:
32-
RUSTDOCFLAGS="--cfg docsrs -D warnings -D rustdoc::broken-intra-doc-links" cargo +$(cat ./nightly-version) doc --all-features {{flags}}
33-
3453
# Quick and dirty CI useful for pre-push checks.
3554
sane: lint
3655
cargo test --quiet --workspace --all-targets --no-default-features > /dev/null || exit 1
@@ -67,4 +86,3 @@ gen-dep-tree:
6786
-p bitcoin -p bitcoin-internals -p bitcoin_hashes@0.16.0 -p bitcoin-units \
6887
-p bitcoin-primitives -p chacha20-poly1305 -p base58ck -p bitcoin-addresses -p bitcoin-io@0.2.0 \
6988
-p bitcoin-consensus-encoding
70-

maintainer-tools-version

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

0 commit comments

Comments
 (0)