Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Commit 4d5975c

Browse files
committed
drop Travis, add Github Actions
Also fix the benchmarks which were not building.
1 parent 634a91c commit 4d5975c

File tree

5 files changed

+160
-40
lines changed

5 files changed

+160
-40
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 && cargo update -p serde_json --precise "1.0.39"
78+
- name: Running cargo
79+
env:
80+
DO_FEATURE_MATRIX: true
81+
run: ./contrib/test.sh
82+

.travis.yml

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

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ since these are needed to display hashes anway.
1212
## Minimum Supported Rust Version (MSRV)
1313

1414
This library should always compile with any combination of features on **Rust 1.29**.
15+
However, due to some dependencies breaking their MSRV in patch releases, you may
16+
need to pin these deps explicitly, e.g. with the following commands
17+
18+
```
19+
cargo generate-lockfile
20+
cargo update -p serde_json --precise "1.0.39"
21+
```
1522

1623
## Contributions
1724

contrib/test.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/sh -ex
2+
3+
FEATURES="serde serde-std"
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+
# Make all cargo invocations verbose
15+
export CARGO_TERM_VERBOSE=true
16+
17+
# Defaults / sanity checks
18+
cargo build --all
19+
cargo test --all
20+
21+
if [ "$DO_FEATURE_MATRIX" = true ]; then
22+
cargo build --all --no-default-features
23+
cargo test --all --no-default-features
24+
25+
# All features
26+
cargo build --all --no-default-features --features="$FEATURES"
27+
cargo test --all --features="$FEATURES"
28+
# Single features
29+
for feature in ${FEATURES}
30+
do
31+
cargo build --all --no-default-features --features="$feature"
32+
cargo test --all --features="$feature"
33+
done
34+
35+
# Other combos
36+
cargo test --all --features="serde-std"
37+
fi
38+
39+
# Docs
40+
if [ "$DO_DOCS" = true ]; then
41+
cargo doc --all --features="$FEATURES"
42+
fi
43+
44+
# Webassembly stuff
45+
if [ "$DO_WASM" = true ]; then
46+
clang --version &&
47+
CARGO_TARGET_DIR=wasm cargo install --force wasm-pack &&
48+
printf '\n[lib]\ncrate-type = ["cdylib", "rlib"]\n' >> Cargo.toml &&
49+
CC=clang-9 wasm-pack build &&
50+
CC=clang-9 wasm-pack test --node;
51+
fi
52+
53+
# Address Sanitizer
54+
if [ "$DO_ASAN" = true ]; then
55+
cargo clean
56+
CC='clang -fsanitize=address -fno-omit-frame-pointer' \
57+
RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes' \
58+
ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' \
59+
cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu
60+
cargo clean
61+
CC='clang -fsanitize=memory -fno-omit-frame-pointer' \
62+
RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes' \
63+
cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu
64+
fi
65+
66+
# Bench
67+
if [ "$DO_BENCH" = true ]; then
68+
cargo bench --all --features="unstable"
69+
fi
70+

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pub trait Hash: Copy + Clone + PartialEq + Eq + Default + PartialOrd + Ord +
136136
}
137137

138138
#[cfg(test)]
139-
mod test {
139+
mod tests {
140140
use Hash;
141141
hash_newtype!(TestNewtype, ::sha256d::Hash, 32, doc="A test newtype");
142142
hash_newtype!(TestNewtype2, ::sha256d::Hash, 32, doc="A test newtype");

0 commit comments

Comments
 (0)