Skip to content

Commit bf5caea

Browse files
committed
Merge #81: Add CI script and minimal/recent lock files
167032a Add justfile (Tobin C. Harding) 7201282 CI: Add script and update github actions (Tobin C. Harding) cb682cd Add minimal and recent lock files (Tobin C. Harding) Pull request description: Add test scripts and lock files, as well as updating the github actions, to mimic how we do things in `rust-secp256k1`. ACKs for top commit: apoelstra: ACK 167032a Tree-SHA512: 879d360cc318e18a52945167f1e9f08094d3bd5690512c682131f29c90046a38dae4fc31b01993906cce32bd37230c6c412e66acc2568d1cb4de4d0a118deddc
2 parents 875511c + 167032a commit bf5caea

File tree

7 files changed

+235
-83
lines changed

7 files changed

+235
-83
lines changed

.github/workflows/rust.yml

Lines changed: 58 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,74 @@ name: Continuous integration
44

55
jobs:
66
Tests:
7-
name: Tests
7+
name: Test - stable toolchain
88
runs-on: ubuntu-latest
99
strategy:
1010
fail-fast: false
11-
matrix:
12-
rust:
13-
- 1.48.0
14-
- nightly
15-
- beta
16-
- stable
1711
steps:
1812
- name: Checkout Crate
19-
uses: actions/checkout@v2
20-
with:
21-
submodules: true
13+
uses: actions/checkout@v3
2214
- name: Checkout Toolchain
23-
uses: actions-rs/toolchain@v1
24-
with:
25-
profile: minimal
26-
toolchain: ${{ matrix.rust }}
27-
override: true
28-
- name: Running Cargo test
29-
run: cargo test
15+
# https://github.com/dtolnay/rust-toolchain
16+
uses: dtolnay/rust-toolchain@stable
17+
- name: Running test script
18+
env:
19+
DO_LINT: true
20+
DO_DOCS: true
21+
run: ./contrib/test.sh
22+
23+
Beta:
24+
name: Test - beta toolchain
25+
runs-on: ubuntu-latest
26+
strategy:
27+
fail-fast: false
28+
steps:
29+
- name: Checkout Crate
30+
uses: actions/checkout@v3
31+
- name: Checkout Toolchain
32+
uses: dtolnay/rust-toolchain@beta
33+
- name: Running test script
34+
run: ./contrib/test.sh
35+
36+
Nightly:
37+
name: Test - nightly toolchain
38+
runs-on: ubuntu-latest
39+
strategy:
40+
fail-fast: false
41+
steps:
42+
- name: Checkout Crate
43+
uses: actions/checkout@v3
44+
- name: Checkout Toolchain
45+
uses: dtolnay/rust-toolchain@nightly
46+
- name: Install src
47+
run: rustup component add rust-src
48+
- name: Running test script
49+
env:
50+
DO_FMT: true
51+
DO_DOCSRS: true
52+
run: ./contrib/test.sh
53+
54+
MSRV:
55+
name: Test - 1.48.0 toolchain
56+
runs-on: ubuntu-latest
57+
strategy:
58+
fail-fast: false
59+
steps:
60+
- name: Checkout Crate
61+
uses: actions/checkout@v3
62+
- name: Checkout Toolchain
63+
uses: dtolnay/rust-toolchain@1.48.0
64+
- name: Running test script
65+
run: ./contrib/test.sh
3066

3167
Arch32bit:
32-
name: Tests 32-bit
68+
name: Test 32-bit version
3369
runs-on: ubuntu-latest
3470
steps:
3571
- name: Checkout Crate
36-
uses: actions/checkout@v2
37-
with:
38-
submodules: true
72+
uses: actions/checkout@v3
3973
- name: Checkout Toolchain
40-
uses: actions-rs/toolchain@v1
41-
with:
42-
profile: minimal
43-
toolchain: stable
44-
override: true
74+
uses: dtolnay/rust-toolchain@stable
4575
- name: Add architecture i386
4676
run: sudo dpkg --add-architecture i386
4777
- name: Install i686 gcc
@@ -56,67 +86,12 @@ jobs:
5686
runs-on: ubuntu-latest
5787
steps:
5888
- name: Checkout Crate
59-
uses: actions/checkout@v2
60-
with:
61-
submodules: true
89+
uses: actions/checkout@v3
6290
- name: Checkout Toolchain
63-
uses: actions-rs/toolchain@v1
64-
with:
65-
profile: minimal
66-
toolchain: stable
67-
override: true
91+
uses: dtolnay/rust-toolchain@stable
6892
- name: Install target
6993
run: rustup target add s390x-unknown-linux-gnu
7094
- name: install cross
7195
run: cargo install cross
7296
- name: run cross test
7397
run: cross test --target s390x-unknown-linux-gnu
74-
75-
Docs:
76-
name: Docs
77-
runs-on: ubuntu-latest
78-
steps:
79-
- name: Checkout Crate
80-
uses: actions/checkout@v2
81-
with:
82-
submodules: true
83-
- name: Checkout Toolchain
84-
uses: actions-rs/toolchain@v1
85-
with:
86-
profile: minimal
87-
toolchain: stable
88-
override: true
89-
- name: Create Doc
90-
run: cargo doc
91-
92-
Clippy:
93-
name: Clippy
94-
runs-on: ubuntu-latest
95-
steps:
96-
- uses: actions/checkout@v2
97-
- uses: actions-rs/toolchain@v1
98-
with:
99-
profile: minimal
100-
toolchain: stable
101-
override: true
102-
- run: rustup component add clippy
103-
- uses: actions-rs/cargo@v1
104-
with:
105-
command: clippy
106-
args: --all-targets --all-features -- -D warnings
107-
108-
Fmt:
109-
name: Fmt
110-
runs-on: ubuntu-latest
111-
steps:
112-
- uses: actions/checkout@v2
113-
- uses: actions-rs/toolchain@v1
114-
with:
115-
profile: minimal
116-
toolchain: nightly
117-
override: true
118-
- run: rustup component add rustfmt
119-
- uses: actions-rs/cargo@v1
120-
with:
121-
command: fmt
122-
args: --check

Cargo-minimal.lock

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This file is automatically @generated by Cargo.
2+
# It is not intended for manual editing.
3+
version = 3
4+
5+
[[package]]
6+
name = "bitcoinconsensus"
7+
version = "0.100.0+0.20.2"
8+
dependencies = [
9+
"cc",
10+
"rustc-serialize",
11+
]
12+
13+
[[package]]
14+
name = "cc"
15+
version = "1.0.83"
16+
source = "registry+https://github.com/rust-lang/crates.io-index"
17+
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
18+
dependencies = [
19+
"libc",
20+
]
21+
22+
[[package]]
23+
name = "libc"
24+
version = "0.2.151"
25+
source = "registry+https://github.com/rust-lang/crates.io-index"
26+
checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
27+
28+
[[package]]
29+
name = "rustc-serialize"
30+
version = "0.3.25"
31+
source = "registry+https://github.com/rust-lang/crates.io-index"
32+
checksum = "fe834bc780604f4674073badbad26d7219cadfb4a2275802db12cbae17498401"

Cargo-recent.lock

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This file is automatically @generated by Cargo.
2+
# It is not intended for manual editing.
3+
version = 3
4+
5+
[[package]]
6+
name = "bitcoinconsensus"
7+
version = "0.100.0+0.20.2"
8+
dependencies = [
9+
"cc",
10+
"rustc-serialize",
11+
]
12+
13+
[[package]]
14+
name = "cc"
15+
version = "1.0.83"
16+
source = "registry+https://github.com/rust-lang/crates.io-index"
17+
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
18+
dependencies = [
19+
"libc",
20+
]
21+
22+
[[package]]
23+
name = "libc"
24+
version = "0.2.151"
25+
source = "registry+https://github.com/rust-lang/crates.io-index"
26+
checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
27+
28+
[[package]]
29+
name = "rustc-serialize"
30+
version = "0.3.25"
31+
source = "registry+https://github.com/rust-lang/crates.io-index"
32+
checksum = "fe834bc780604f4674073badbad26d7219cadfb4a2275802db12cbae17498401"

contrib/_test.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
REPO_DIR=$(git rev-parse --show-toplevel)
6+
FEATURES="std" # Note we don't currently test with "external-secp".
7+
8+
cargo --version
9+
rustc --version
10+
11+
# Work out if we are using a nightly toolchain.
12+
NIGHTLY=false
13+
if cargo --version | grep nightly; then
14+
NIGHTLY=true
15+
fi
16+
17+
# Make all cargo invocations verbose
18+
export CARGO_TERM_VERBOSE=true
19+
20+
# Defaults / "std" feature
21+
cargo build --locked
22+
cargo test --locked
23+
24+
# No features.
25+
cargo build --locked --no-default-features
26+
cargo test --locked --no-default-features
27+
28+
if [ "$DO_LINT" = true ]
29+
then
30+
cargo clippy --locked --all-features --all-targets -- -D warnings
31+
fi
32+
33+
# Build the docs if told to (this only works with the nightly toolchain)
34+
if [ "$DO_DOCSRS" = true ]; then
35+
RUSTDOCFLAGS="--cfg docsrs -D warnings -D rustdoc::broken-intra-doc-links" cargo +nightly doc --all-features
36+
fi
37+
38+
# Build the docs with a stable toolchain, in unison with the DO_DOCSRS command
39+
# above this checks that we feature guarded docs imports correctly.
40+
if [ "$DO_DOCS" = true ]; then
41+
RUSTDOCFLAGS="-D warnings" cargo +stable doc --all-features
42+
fi
43+
44+
# Run formatter if told to.
45+
if [ "$DO_FMT" = true ]; then
46+
if [ "$NIGHTLY" = false ]; then
47+
echo "DO_FMT requires a nightly toolchain (consider using RUSTUP_TOOLCHAIN)"
48+
exit 1
49+
fi
50+
rustup component add rustfmt
51+
cargo fmt --check || exit 1
52+
fi
53+
54+
exit 0

contrib/test.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
REPO_DIR=$(git rev-parse --show-toplevel)
6+
DEPS="recent minimal"
7+
8+
for dep in $DEPS
9+
do
10+
cp "Cargo-$dep.lock" Cargo.lock
11+
$REPO_DIR/contrib/_test.sh
12+
13+
if [ "$dep" = recent ];
14+
then
15+
# We always test committed dependencies but we want to warn if they could've been updated
16+
cargo update
17+
if diff Cargo-recent.lock Cargo.lock;
18+
then
19+
echo "Dependencies are up to date"
20+
else
21+
echo "::warning file=Cargo-recent.lock::Dependencies could be updated"
22+
fi
23+
fi
24+
done
25+
26+
exit 0

contrib/update-lock-files.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Update the minimal/recent lock file
4+
5+
set -euo pipefail
6+
7+
for file in Cargo-minimal.lock Cargo-recent.lock; do
8+
cp --force "$file" Cargo.lock
9+
cargo check
10+
cp --force Cargo.lock "$file"
11+
done

justfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
default:
2+
@just --list
3+
4+
# Cargo build everything.
5+
build:
6+
cargo build --all-targets
7+
8+
# Cargo check everything.
9+
check:
10+
cargo check --all-targets
11+
12+
# Lint everything.
13+
lint:
14+
cargo clippy --all-targets -- --deny warnings
15+
16+
# Check the formatting
17+
format:
18+
cargo +nightly fmt --all --check
19+
20+
# Update the recent and minimal lock files.
21+
update-lock-files:
22+
contrib/update-lock-files.sh

0 commit comments

Comments
 (0)