Merge pull request #250 from rust-bitcoin/2020-11--github-actions

switch from travis to github workflows
This commit is contained in:
Andrew Poelstra 2020-11-23 21:25:21 +00:00 committed by GitHub
commit ac4541adb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 161 additions and 79 deletions

82
.github/workflows/rust.yml vendored Normal file
View File

@ -0,0 +1,82 @@
on: [push, pull_request]
name: Continuous integration
jobs:
bench_nightly:
name: Nightly - ASan + Bench
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- nightly
steps:
- name: Checkout Crate
uses: actions/checkout@v2
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rust-src
- name: Running address sanitizer
env:
DO_ASAN: true
run: ./contrib/test.sh
- name: Running benchmarks
env:
DO_BENCH: true
run: ./contrib/test.sh
wasm:
name: Stable - Docs / WebAssembly Build
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
steps:
- name: Checkout Crate
uses: actions/checkout@v2
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Building docs
env:
DO_DOCS: true
run: ./contrib/test.sh
- name: Running WASM build
env:
DO_WASM: true
run: ./contrib/test.sh
Tests:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- 1.29.0
- beta
- stable
steps:
- name: Checkout Crate
uses: actions/checkout@v2
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Pin cc if rust 1.29
if: matrix.rust == '1.29.0'
run: cargo generate-lockfile --verbose && cargo update -p cc --precise "1.0.41" --verbose
- name: Running cargo
env:
DO_FEATURE_MATRIX: true
run: ./contrib/test.sh

View File

@ -1,78 +0,0 @@
language: rust
cache:
directories:
- wasm
rust:
- stable
- beta
- nightly
- 1.29.0
distro: bionic
os:
- linux
- windows
addons:
chrome: stable
apt:
packages:
- clang-9
- nodejs
matrix:
exclude:
- rust: 1.29.0
os: windows
script:
- if [ "$TRAVIS_RUST_VERSION" == "1.29.0" ]; then
cargo generate-lockfile --verbose && cargo update -p cc --precise "1.0.41" --verbose;
fi
- cargo build --verbose --no-default-features
- cargo build --verbose --no-default-features --features="bitcoin_hashes"
- cargo build --verbose --no-default-features --features="serde"
- cargo build --verbose --no-default-features --features="lowmemory"
- cargo build --verbose --no-default-features --features="rand"
- cargo build --verbose --no-default-features --features="rand serde recovery endomorphism"
- cargo build --verbose --no-default-features --features="fuzztarget recovery"
- cargo build --verbose --features=rand
- cargo test --no-run --features=fuzztarget
- cargo test --verbose --features="bitcoin_hashes"
- cargo test --verbose --features=rand
- cargo test --verbose --features="rand rand-std"
- cargo test --verbose --features="rand serde"
- cargo test --verbose --features="rand serde recovery endomorphism"
- if [ ${TRAVIS_RUST_VERSION} != "1.29.0" ]; then
cargo test --verbose --features global-context;
fi
- cargo build --verbose
- cargo test --verbose
- cargo build --verbose --release
- cargo test --verbose --release
- cargo run --example sign_verify
- cargo run --example sign_verify_recovery --features=recovery
- cargo run --example generate_keys --features=rand
- if [ ${TRAVIS_RUST_VERSION} == "stable" ]; then cargo doc --verbose --features="rand,serde,recovery,endomorphism"; fi
- if [ ${TRAVIS_RUST_VERSION} == "nightly" ]; then cargo test --verbose --benches --features=unstable; fi
- |
if [ ${TRAVIS_RUST_VERSION} == "nightly" -a "$TRAVIS_OS_NAME" = "linux" ]; then
cargo clean
rustup component add rust-src
CC='clang -fsanitize=address -fno-omit-frame-pointer' \
RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes' \
ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' \
cargo test --lib --verbose --features="rand-std serde recovery bitcoin_hashes" -Zbuild-std --target x86_64-unknown-linux-gnu &&
cargo clean &&
CC='clang -fsanitize=memory -fno-omit-frame-pointer' \
RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes' \
cargo test --lib --verbose --features="rand-std serde recovery bitcoin_hashes" -Zbuild-std --target x86_64-unknown-linux-gnu &&
cd no_std_test && cargo run --release | grep -q "Verified Successfully"
fi
- if [ ${TRAVIS_RUST_VERSION} == "stable" -a "$TRAVIS_OS_NAME" = "linux" ]; then
clang --version &&
CARGO_TARGET_DIR=wasm cargo install --verbose --force wasm-pack &&
printf '\n[lib]\ncrate-type = ["cdylib", "rlib"]\n' >> Cargo.toml &&
CC=clang-9 wasm-pack build &&
CC=clang-9 wasm-pack test --node;
fi

77
contrib/test.sh Executable file
View File

@ -0,0 +1,77 @@
#!/bin/sh -ex
FEATURES="bitcoin_hashes endomorphism global-context lowmemory rand rand-std recovery serde"
# Use toolchain if explicitly specified
if [ -n "$TOOLCHAIN" ]
then
alias cargo="cargo +$TOOLCHAIN"
fi
cargo --version
rustc --version
# Defaults / sanity checks
cargo build --verbose
cargo test --verbose
if [ "$DO_FEATURE_MATRIX" = true ]; then
cargo build --verbose --no-default-features
#This doesn't work but probably should --andrew
#cargo test --verbose --no-default-features
# All features
cargo build --verbose --no-default-features --features="$FEATURES"
cargo test --verbose --features="$FEATURES"
# Single features
for feature in ${FEATURES}
do
cargo build --verbose --no-default-features --features="$feature"
cargo test --verbose --features="$feature"
done
# Other combos
cargo test --no-run --verbose --features="fuzztarget"
cargo test --no-run --verbose --features="fuzztarget recovery"
cargo test --verbose --features="rand rand-std"
cargo test --verbose --features="rand serde"
# Examples
cargo run --example sign_verify
cargo run --example sign_verify_recovery --features=recovery
cargo run --example generate_keys --features=rand
fi
# Docs
if [ "$DO_DOCS" = true ]; then
cargo doc --verbose --features="$FEATURES"
fi
# Webassembly stuff
if [ "$DO_WASM" = true ]; then
clang --version &&
CARGO_TARGET_DIR=wasm cargo install --verbose --force wasm-pack &&
printf '\n[lib]\ncrate-type = ["cdylib", "rlib"]\n' >> Cargo.toml &&
CC=clang-9 wasm-pack build &&
CC=clang-9 wasm-pack test --node;
fi
# Address Sanitizer
if [ "$DO_ASAN" = true ]; then
cargo clean
CC='clang -fsanitize=address -fno-omit-frame-pointer' \
RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes' \
ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' \
cargo test --lib --verbose --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu &&
cargo clean &&
CC='clang -fsanitize=memory -fno-omit-frame-pointer' \
RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes' \
cargo test --lib --verbose --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu &&
cd no_std_test && cargo run --release | grep -q "Verified Successfully"
fi
# Bench
if [ "$DO_BENCH" = true ]; then
cargo bench --features="unstable"
fi

View File

@ -12,6 +12,7 @@ pub use self::std_only::*;
#[cfg(feature = "global-context")]
/// Module implementing a singleton pattern for a global `Secp256k1` context
pub mod global {
use rand;
use std::ops::Deref;
use std::sync::Once;
use {Secp256k1, All};