Skip to content

Commit 1859ddc

Browse files
committed
switch from travis to github workflows
1 parent d31dcf2 commit 1859ddc

File tree

4 files changed

+161
-79
lines changed

4 files changed

+161
-79
lines changed

.github/workflows/rust.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
on: [push, pull_request]
2+
3+
name: Continuous integration
4+
5+
jobs:
6+
bench_nightly:
7+
name: Nightly - ASan + Bench
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
rust:
12+
- nightly
13+
steps:
14+
- name: Checkout Crate
15+
uses: actions/checkout@v2
16+
- name: Checkout Toolchain
17+
uses: actions-rs/toolchain@v1
18+
with:
19+
profile: minimal
20+
toolchain: ${{ matrix.rust }}
21+
override: true
22+
components: rust-src
23+
- name: Running address sanitizer
24+
env:
25+
DO_ASAN: true
26+
run: ./contrib/test.sh
27+
- name: Running benchmarks
28+
env:
29+
DO_BENCH: true
30+
run: ./contrib/test.sh
31+
32+
wasm:
33+
name: Stable - Docs / WebAssembly Build
34+
runs-on: ubuntu-latest
35+
strategy:
36+
matrix:
37+
rust:
38+
- stable
39+
steps:
40+
- name: Checkout Crate
41+
uses: actions/checkout@v2
42+
- name: Checkout Toolchain
43+
uses: actions-rs/toolchain@v1
44+
with:
45+
profile: minimal
46+
toolchain: ${{ matrix.rust }}
47+
override: true
48+
- name: Building docs
49+
env:
50+
DO_DOCS: true
51+
run: ./contrib/test.sh
52+
- name: Running WASM build
53+
env:
54+
DO_WASM: true
55+
run: ./contrib/test.sh
56+
57+
Tests:
58+
name: Tests
59+
runs-on: ubuntu-latest
60+
strategy:
61+
matrix:
62+
rust:
63+
- 1.29.0
64+
- beta
65+
- stable
66+
steps:
67+
- name: Checkout Crate
68+
uses: actions/checkout@v2
69+
- name: Checkout Toolchain
70+
uses: actions-rs/toolchain@v1
71+
with:
72+
profile: minimal
73+
toolchain: ${{ matrix.rust }}
74+
override: true
75+
- name: Pin cc if rust 1.29
76+
if: matrix.rust == '1.29.0'
77+
run: cargo generate-lockfile --verbose && cargo update -p cc --precise "1.0.41" --verbose
78+
- name: Running cargo
79+
env:
80+
DO_FEATURE_MATRIX: true
81+
run: ./contrib/test.sh
82+

.travis.yml

Lines changed: 0 additions & 78 deletions
This file was deleted.

contrib/test.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/sh -ex
2+
3+
FEATURES="bitcoin_hashes endomorphism global-context lowmemory rand rand-std recovery serde"
4+
5+
# Use toolchain if explicitly specified
6+
if [ -n "$TOOLCHAIN" ]
7+
then
8+
alias cargo="cargo +$TOOLCHAIN"
9+
fi
10+
11+
cargo --version
12+
rustc --version
13+
14+
# Defaults / sanity checks
15+
cargo build --verbose
16+
cargo test --verbose
17+
18+
if [ "$DO_FEATURE_MATRIX" = true ]; then
19+
cargo build --verbose --no-default-features
20+
#This doesn't work but probably should --andrew
21+
#cargo test --verbose --no-default-features
22+
23+
# All features
24+
cargo build --verbose --no-default-features --features="$FEATURES"
25+
cargo test --verbose --features="$FEATURES"
26+
# Single features
27+
for feature in ${FEATURES}
28+
do
29+
cargo build --verbose --no-default-features --features="$feature"
30+
cargo test --verbose --features="$feature"
31+
done
32+
33+
# Other combos
34+
cargo test --no-run --verbose --features="fuzztarget"
35+
cargo test --no-run --verbose --features="fuzztarget recovery"
36+
cargo test --verbose --features="rand rand-std"
37+
cargo test --verbose --features="rand serde"
38+
39+
# Examples
40+
cargo run --example sign_verify
41+
cargo run --example sign_verify_recovery --features=recovery
42+
cargo run --example generate_keys --features=rand
43+
fi
44+
45+
# Docs
46+
if [ "$DO_DOCS" = true ]; then
47+
cargo doc --verbose --features="$FEATURES"
48+
fi
49+
50+
# Webassembly stuff
51+
if [ "$DO_WASM" = true ]; then
52+
clang --version &&
53+
CARGO_TARGET_DIR=wasm cargo install --verbose --force wasm-pack &&
54+
printf '\n[lib]\ncrate-type = ["cdylib", "rlib"]\n' >> Cargo.toml &&
55+
CC=clang-9 wasm-pack build &&
56+
CC=clang-9 wasm-pack test --node;
57+
fi
58+
59+
# Address Sanitizer
60+
if [ "$DO_ASAN" = true ]; then
61+
cargo clean
62+
CC='clang -fsanitize=address -fno-omit-frame-pointer' \
63+
RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes' \
64+
ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' \
65+
cargo test --lib --verbose --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu &&
66+
cargo clean &&
67+
CC='clang -fsanitize=memory -fno-omit-frame-pointer' \
68+
RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes' \
69+
cargo test --lib --verbose --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu &&
70+
cd no_std_test && cargo run --release | grep -q "Verified Successfully"
71+
fi
72+
73+
# Bench
74+
if [ "$DO_BENCH" = true ]; then
75+
cargo bench --features="unstable"
76+
fi
77+

src/context.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub use self::std_only::*;
1212
#[cfg(feature = "global-context")]
1313
/// Module implementing a singleton pattern for a global `Secp256k1` context
1414
pub mod global {
15+
use rand;
1516
use std::ops::Deref;
1617
use std::sync::Once;
1718
use {Secp256k1, All};
@@ -337,4 +338,4 @@ impl<'buf> Secp256k1<VerifyOnlyPreallocated<'buf>> {
337338
buf: ptr::null_mut::<[u8;0]>() as *mut [u8] ,
338339
})
339340
}
340-
}
341+
}

0 commit comments

Comments
 (0)