Skip to content

Commit

Permalink
Merge #81: Add CI script and minimal/recent lock files
Browse files Browse the repository at this point in the history
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
  • Loading branch information
apoelstra committed Jan 9, 2024
2 parents 875511c + 167032a commit bf5caea
Show file tree
Hide file tree
Showing 7 changed files with 235 additions and 83 deletions.
141 changes: 58 additions & 83 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,74 @@ name: Continuous integration

jobs:
Tests:
name: Tests
name: Test - stable toolchain
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust:
- 1.48.0
- nightly
- beta
- stable
steps:
- name: Checkout Crate
uses: actions/checkout@v2
with:
submodules: true
uses: actions/checkout@v3
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Running Cargo test
run: cargo test
# https://github.com/dtolnay/rust-toolchain
uses: dtolnay/rust-toolchain@stable
- name: Running test script
env:
DO_LINT: true
DO_DOCS: true
run: ./contrib/test.sh

Beta:
name: Test - beta toolchain
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout Crate
uses: actions/checkout@v3
- name: Checkout Toolchain
uses: dtolnay/rust-toolchain@beta
- name: Running test script
run: ./contrib/test.sh

Nightly:
name: Test - nightly toolchain
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout Crate
uses: actions/checkout@v3
- name: Checkout Toolchain
uses: dtolnay/rust-toolchain@nightly
- name: Install src
run: rustup component add rust-src
- name: Running test script
env:
DO_FMT: true
DO_DOCSRS: true
run: ./contrib/test.sh

MSRV:
name: Test - 1.48.0 toolchain
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout Crate
uses: actions/checkout@v3
- name: Checkout Toolchain
uses: dtolnay/rust-toolchain@1.48.0
- name: Running test script
run: ./contrib/test.sh

Arch32bit:
name: Tests 32-bit
name: Test 32-bit version
runs-on: ubuntu-latest
steps:
- name: Checkout Crate
uses: actions/checkout@v2
with:
submodules: true
uses: actions/checkout@v3
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
uses: dtolnay/rust-toolchain@stable
- name: Add architecture i386
run: sudo dpkg --add-architecture i386
- name: Install i686 gcc
Expand All @@ -56,67 +86,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Crate
uses: actions/checkout@v2
with:
submodules: true
uses: actions/checkout@v3
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
uses: dtolnay/rust-toolchain@stable
- name: Install target
run: rustup target add s390x-unknown-linux-gnu
- name: install cross
run: cargo install cross
- name: run cross test
run: cross test --target s390x-unknown-linux-gnu

Docs:
name: Docs
runs-on: ubuntu-latest
steps:
- name: Checkout Crate
uses: actions/checkout@v2
with:
submodules: true
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Create Doc
run: cargo doc

Clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets --all-features -- -D warnings

Fmt:
name: Fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --check
32 changes: 32 additions & 0 deletions Cargo-minimal.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3

[[package]]
name = "bitcoinconsensus"
version = "0.100.0+0.20.2"
dependencies = [
"cc",
"rustc-serialize",
]

[[package]]
name = "cc"
version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
dependencies = [
"libc",
]

[[package]]
name = "libc"
version = "0.2.151"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"

[[package]]
name = "rustc-serialize"
version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe834bc780604f4674073badbad26d7219cadfb4a2275802db12cbae17498401"
32 changes: 32 additions & 0 deletions Cargo-recent.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file is automatically @generated by Cargo.

Check warning on line 1 in Cargo-recent.lock

View workflow job for this annotation

GitHub Actions / Test - 1.48.0 toolchain

Dependencies could be updated

Check warning on line 1 in Cargo-recent.lock

View workflow job for this annotation

GitHub Actions / Test - stable toolchain

Dependencies could be updated

Check warning on line 1 in Cargo-recent.lock

View workflow job for this annotation

GitHub Actions / Test - beta toolchain

Dependencies could be updated

Check warning on line 1 in Cargo-recent.lock

View workflow job for this annotation

GitHub Actions / Test - nightly toolchain

Dependencies could be updated
# It is not intended for manual editing.
version = 3

[[package]]
name = "bitcoinconsensus"
version = "0.100.0+0.20.2"
dependencies = [
"cc",
"rustc-serialize",
]

[[package]]
name = "cc"
version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
dependencies = [
"libc",
]

[[package]]
name = "libc"
version = "0.2.151"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"

[[package]]
name = "rustc-serialize"
version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe834bc780604f4674073badbad26d7219cadfb4a2275802db12cbae17498401"
54 changes: 54 additions & 0 deletions contrib/_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash

set -ex

REPO_DIR=$(git rev-parse --show-toplevel)
FEATURES="std" # Note we don't currently test with "external-secp".

cargo --version
rustc --version

# Work out if we are using a nightly toolchain.
NIGHTLY=false
if cargo --version | grep nightly; then
NIGHTLY=true
fi

# Make all cargo invocations verbose
export CARGO_TERM_VERBOSE=true

# Defaults / "std" feature
cargo build --locked
cargo test --locked

# No features.
cargo build --locked --no-default-features
cargo test --locked --no-default-features

if [ "$DO_LINT" = true ]
then
cargo clippy --locked --all-features --all-targets -- -D warnings
fi

# Build the docs if told to (this only works with the nightly toolchain)
if [ "$DO_DOCSRS" = true ]; then
RUSTDOCFLAGS="--cfg docsrs -D warnings -D rustdoc::broken-intra-doc-links" cargo +nightly doc --all-features
fi

# Build the docs with a stable toolchain, in unison with the DO_DOCSRS command
# above this checks that we feature guarded docs imports correctly.
if [ "$DO_DOCS" = true ]; then
RUSTDOCFLAGS="-D warnings" cargo +stable doc --all-features
fi

# Run formatter if told to.
if [ "$DO_FMT" = true ]; then
if [ "$NIGHTLY" = false ]; then
echo "DO_FMT requires a nightly toolchain (consider using RUSTUP_TOOLCHAIN)"
exit 1
fi
rustup component add rustfmt
cargo fmt --check || exit 1
fi

exit 0
26 changes: 26 additions & 0 deletions contrib/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

set -ex

REPO_DIR=$(git rev-parse --show-toplevel)
DEPS="recent minimal"

for dep in $DEPS
do
cp "Cargo-$dep.lock" Cargo.lock
$REPO_DIR/contrib/_test.sh

if [ "$dep" = recent ];
then
# We always test committed dependencies but we want to warn if they could've been updated
cargo update
if diff Cargo-recent.lock Cargo.lock;
then
echo "Dependencies are up to date"
else
echo "::warning file=Cargo-recent.lock::Dependencies could be updated"
fi
fi
done

exit 0
11 changes: 11 additions & 0 deletions contrib/update-lock-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
#
# Update the minimal/recent lock file

set -euo pipefail

for file in Cargo-minimal.lock Cargo-recent.lock; do
cp --force "$file" Cargo.lock
cargo check
cp --force Cargo.lock "$file"
done
22 changes: 22 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
default:
@just --list

# Cargo build everything.
build:
cargo build --all-targets

# Cargo check everything.
check:
cargo check --all-targets

# Lint everything.
lint:
cargo clippy --all-targets -- --deny warnings

# Check the formatting
format:
cargo +nightly fmt --all --check

# Update the recent and minimal lock files.
update-lock-files:
contrib/update-lock-files.sh

0 comments on commit bf5caea

Please sign in to comment.