Skip to content

Commit e07d745

Browse files
committed
build: move build complexity to justfile
Keep build and test logic as agnostic as possible to whatever CI task runner is used (today that is Github Actions). Let the CI job focus on performance, like caching artifacts and keep the build and test logic in the forefront easy for developers to use. With that goal in mind, the CI job has been refactored to a handful of jobs which each call a `just` recipe. Consistent caching has been added to each job which shows a nice improvement in speed for the workflow, running in less than a minute. The justfile has been refactored with the logic that previously lived in the CI yaml. This makes it easier to maintain as well as run locally when developing. A few un-used recipes have been cleaned up. Lockfile complexity has been relegated to the _test-msrv recipe. This recipe checks that there is at least one set of dependencies which satisfy the msrv requirements. The check no longer depends on the checked in lockfile which doesn't matter much since consumers create their own. A rust-toolchain.toml file was added as a gently nudge for contributers to stay on a recent version of "stable", that way we can use some of the newer features like the v3 resolver and see less of "works on my machine". CI will most likely not use the file however, since it usually needs to test more complex things like MSRV.
1 parent c4ac382 commit e07d745

File tree

12 files changed

+107
-1244
lines changed

12 files changed

+107
-1244
lines changed

.cargo/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Opt in to the v3 MSRV-aware resolver.
2+
[resolver]
3+
incompatible-rust-versions = "fallback"

.github/workflows/ci.yml

Lines changed: 50 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,70 @@
1-
name: Build & Test
1+
# A few guiding principles.
2+
#
3+
# * Always use actions-rust-lang/setup-rust-toolchain for its built-in caching.
4+
# * Complexity lives in the justfile, this runner is as light as possible.
5+
6+
name: CI
27

8+
# Run on direct commits to master, including merges, and any pull requests against master.
39
on:
410
push:
511
branches:
612
- master
713
pull_request:
14+
branches:
15+
- master
816

917
jobs:
10-
build:
18+
# Quick canary of code as well as potential issues with upcoming toolchains.
19+
check:
1120
strategy:
1221
matrix:
13-
platform: [ubuntu-latest, macos-latest, windows-latest]
1422
toolchain: [stable, beta, nightly]
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: extractions/setup-just@v3
27+
- uses: actions-rust-lang/setup-rust-toolchain@v1
28+
with:
29+
toolchain: ${{ matrix.toolchain }}
30+
components: clippy,rustfmt
31+
- run: just check
32+
# Build and test the code across platforms.
33+
test:
34+
strategy:
35+
matrix:
36+
platform: [ubuntu-latest, macos-latest, windows-latest]
1537
runs-on: ${{ matrix.platform }}
1638
steps:
17-
- uses: actions/checkout@v3
18-
- name: Update Toolchain
19-
run: |
20-
rustup default ${{ matrix.toolchain }}
21-
rustup component add --toolchain ${{ matrix.toolchain }} rustfmt
22-
rustup component add --toolchain ${{ matrix.toolchain }} clippy
23-
rustup update ${{ matrix.toolchain }}
24-
- name: Lint all targets
25-
run: cargo clippy --all-targets
26-
- name: Format
27-
run: cargo fmt -- --check
28-
- name: Build with defeault features
29-
run: cargo build --verbose
30-
- name: Check release build on Rust ${{ matrix.toolchain }}
31-
run: cargo check --release --verbose --color always
32-
- name: Unit test
33-
run: cargo test --verbose --lib
34-
- name: Doc test
35-
run: cargo test --verbose --doc
36-
# Check that library code can be compiled with MSRV (1.63.0).
39+
- uses: actions/checkout@v4
40+
- uses: extractions/setup-just@v3
41+
- uses: actions-rust-lang/setup-rust-toolchain@v1
42+
- run: just test unit
43+
features:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v4
47+
- uses: extractions/setup-just@v3
48+
- uses: actions-rust-lang/setup-rust-toolchain@v1
49+
- run: just test features
3750
msrv:
3851
runs-on: ubuntu-latest
3952
steps:
40-
- uses: actions/checkout@v3
41-
# Modify build tools just for MSRV testing. This avoids us having
42-
# to bump our MSRV just for tooling. Tooling doesn't effect consumers so not a risk.
43-
- name: Prepare environment for MSRV toolchain
44-
run: |
45-
# Remove resolver = "3" line for MSRV compatibility. We use V3 to
46-
# generate an MSRV-compliant lockfile, but this isn't necessary to
47-
# check if library code is MSRV compliant. Any resolver can go
48-
# and grab the versions specified in the committed lockfile.
49-
#
50-
# The V3 resolver is standard in rust 1.85.
51-
sed -i '/resolver = "3"/d' Cargo.toml
52-
- name: Install MSRV toolchain
53-
run: |
54-
rustup toolchain install 1.63.0
55-
rustup default 1.63.0
56-
- name: Build with MSRV compiler
57-
run: cargo build --verbose
58-
signet:
53+
- uses: actions/checkout@v4
54+
- uses: extractions/setup-just@v3
55+
- uses: actions-rust-lang/setup-rust-toolchain@v1
56+
- run: just test msrv
57+
sync:
5958
runs-on: ubuntu-latest
6059
steps:
61-
- uses: actions/checkout@v3
62-
- name: Sync signet
63-
run: cargo test --verbose signet_syncs
64-
bitcoind:
60+
- uses: actions/checkout@v4
61+
- uses: extractions/setup-just@v3
62+
- uses: actions-rust-lang/setup-rust-toolchain@v1
63+
- run: just test sync
64+
integration:
6565
runs-on: ubuntu-latest
6666
steps:
67-
- uses: actions/checkout@v3
68-
- name: Integration test
69-
run: cargo test -- --test-threads 1 --skip signet_syncs --nocapture
67+
- uses: actions/checkout@v4
68+
- uses: extractions/setup-just@v3
69+
- uses: actions-rust-lang/setup-rust-toolchain@v1
70+
- run: just test integration

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
Cargo.lock
12
/target
23
/data
34
/light_client_data

0 commit comments

Comments
 (0)