Skip to content

Commit 3c1b576

Browse files
committed
ci: Rework github actions script
Rework the github actions script in line with `rust-bitcoin`, notably: - Use dtonlay runner - Split jobs up by toolchain - Add Arch32bit job - Add Cross test job - Run linter as part of the test script - Test docs build using stable toolchain and nightly toolchain
1 parent d41bcc8 commit 3c1b576

File tree

2 files changed

+95
-50
lines changed

2 files changed

+95
-50
lines changed

.github/workflows/rust.yml

+80-49
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,111 @@ on: [push, pull_request]
33
name: Continuous integration
44

55
jobs:
6-
Nightly:
7-
name: Nightly - ASan + Bench + Docs
6+
Stable:
7+
name: Test - stable toolchain
88
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
911
steps:
1012
- name: Checkout Crate
11-
uses: actions/checkout@v2
12-
- name: Install clang for ASan
13-
run: sudo apt-get install -y clang
13+
uses: actions/checkout@v3
1414
- name: Checkout Toolchain
15-
uses: actions-rs/toolchain@v1
16-
with:
17-
profile: minimal
18-
toolchain: nightly
19-
override: true
20-
components: rust-src
21-
- name: Check formatting
15+
# https://github.com/dtolnay/rust-toolchain
16+
uses: dtolnay/rust-toolchain@stable
17+
- name: Running test script
2218
env:
23-
DO_FMT: true
19+
DO_LINT: true
20+
DO_DOCS: true
21+
DO_FEATURE_MATRIX: true
2422
run: ./contrib/test.sh
25-
- name: Running address sanitizer
26-
env:
27-
DO_ASAN: true
23+
24+
Beta:
25+
name: Test - beta toolchain
26+
runs-on: ubuntu-latest
27+
strategy:
28+
fail-fast: false
29+
steps:
30+
- name: Checkout Crate
31+
uses: actions/checkout@v3
32+
- name: Checkout Toolchain
33+
uses: dtolnay/rust-toolchain@beta
34+
- name: Running test script
2835
run: ./contrib/test.sh
29-
- name: Running benchmarks
36+
37+
Nightly:
38+
name: Test - nightly toolchain
39+
runs-on: ubuntu-latest
40+
strategy:
41+
fail-fast: false
42+
steps:
43+
- name: Checkout Crate
44+
uses: actions/checkout@v3
45+
- name: Checkout Toolchain
46+
uses: dtolnay/rust-toolchain@nightly
47+
- name: Install src
48+
run: rustup component add rust-src
49+
- name: Running test script
3050
env:
51+
DO_FMT: true
3152
DO_BENCH: true
32-
run: ./contrib/test.sh
33-
- name: Building docs
34-
env:
35-
DO_DOCS: true
53+
DO_DOCSRS: true
54+
DO_ASAN: true
3655
run: ./contrib/test.sh
3756

38-
Tests:
39-
name: Tests
57+
MSRV:
58+
name: Test - 1.48.0 toolchain
4059
runs-on: ubuntu-latest
4160
strategy:
42-
matrix:
43-
rust: [stable, beta, nightly, 1.48.0]
61+
fail-fast: false
4462
steps:
4563
- name: Checkout Crate
46-
uses: actions/checkout@v2
64+
uses: actions/checkout@v3
4765
- name: Checkout Toolchain
48-
uses: actions-rs/toolchain@v1
49-
with:
50-
profile: minimal
51-
toolchain: ${{ matrix.rust }}
52-
override: true
53-
- name: Running cargo
66+
uses: dtolnay/[email protected]
67+
- name: Running test script
5468
env:
5569
DO_FEATURE_MATRIX: true
5670
run: ./contrib/test.sh
5771

72+
Arch32bit:
73+
name: Test 32-bit version
74+
runs-on: ubuntu-latest
75+
steps:
76+
- name: Checkout Crate
77+
uses: actions/checkout@v3
78+
- name: Checkout Toolchain
79+
uses: dtolnay/rust-toolchain@stable
80+
- name: Add architecture i386
81+
run: sudo dpkg --add-architecture i386
82+
- name: Install i686 gcc
83+
run: sudo apt-get update -y && sudo apt-get install -y gcc-multilib
84+
- name: Install target
85+
run: rustup target add i686-unknown-linux-gnu
86+
- name: Run test on i686
87+
run: cargo test --target i686-unknown-linux-gnu
88+
89+
Cross:
90+
name: Cross test
91+
if: ${{ !github.event.act }}
92+
runs-on: ubuntu-latest
93+
steps:
94+
- name: Checkout Crate
95+
uses: actions/checkout@v3
96+
- name: Checkout Toolchain
97+
uses: dtolnay/rust-toolchain@stable
98+
- name: Install target
99+
run: rustup target add s390x-unknown-linux-gnu
100+
- name: install cross
101+
run: cargo install cross --locked
102+
- name: run cross test
103+
run: cross test --target s390x-unknown-linux-gnu
104+
58105
WASM:
59106
name: WASM
60107
runs-on: ubuntu-latest
61108
steps:
62109
- name: Checkout Crate
63-
uses: actions/checkout@v2
110+
uses: actions/checkout@v3
64111
- name: Install clang
65112
run: sudo apt-get install -y clang
66113
- name: Checkout Toolchain
@@ -69,19 +116,3 @@ jobs:
69116
env:
70117
DO_WASM: true
71118
run: ./contrib/test.sh
72-
73-
Clippy:
74-
name: Clippy
75-
runs-on: ubuntu-latest
76-
steps:
77-
- uses: actions/checkout@v2
78-
- uses: actions-rs/toolchain@v1
79-
with:
80-
profile: minimal
81-
toolchain: stable
82-
override: true
83-
- run: rustup component add clippy
84-
- uses: actions-rs/cargo@v1
85-
with:
86-
command: clippy
87-
args: --features=rand-std,recovery,lowmemory,global-context --all-targets -- -D warnings

contrib/test.sh

+15-1
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,23 @@ if [ "$DO_FEATURE_MATRIX" = true ]; then
5858
cargo run --example generate_keys --features=rand-std
5959
fi
6060

61+
if [ "$DO_LINT" = true ]
62+
then
63+
cargo clippy --all-features --all-targets -- -D warnings
64+
cargo clippy --example sign_verify --features=bitcoin-hashes-std -- -D warnings
65+
cargo clippy --example sign_verify_recovery --features=recovery,bitcoin-hashes-std -- -D warnings
66+
cargo clippy --example generate_keys --features=rand-std -- -D warnings
67+
fi
68+
6169
# Build the docs if told to (this only works with the nightly toolchain)
70+
if [ "$DO_DOCSRS" = true ]; then
71+
RUSTDOCFLAGS="--cfg docsrs -D warnings -D rustdoc::broken-intra-doc-links" cargo +nightly doc --all-features
72+
fi
73+
74+
# Build the docs with a stable toolchain, in unison with the DO_DOCSRS command
75+
# above this checks that we feature guarded docs imports correctly.
6276
if [ "$DO_DOCS" = true ]; then
63-
RUSTDOCFLAGS="--cfg docsrs" cargo rustdoc --features="$FEATURES" -- -D rustdoc::broken-intra-doc-links -D warnings || exit 1
77+
RUSTDOCFLAGS="-D warnings" cargo +stable doc --all-features
6478
fi
6579

6680
# Webassembly stuff

0 commit comments

Comments
 (0)