Skip to content

Commit 0e20b8a

Browse files
committed
ci: update to newer deps, modernize the CI job, add docs/clippy/fuzz
1 parent f18565e commit 0e20b8a

2 files changed

Lines changed: 136 additions & 43 deletions

File tree

.github/workflows/rust.yml

Lines changed: 99 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,112 @@
1-
on: [push, pull_request]
1+
on:
2+
push:
3+
branches:
4+
- master
5+
pull_request: {}
26

37
name: Continuous integration
48

59
jobs:
6-
Tests:
7-
name: Tests
10+
Stable:
11+
name: Test - stable toolchain
812
runs-on: ubuntu-latest
913
strategy:
1014
fail-fast: false
11-
matrix:
12-
include:
13-
- rust: 1.58.0
14-
env:
15-
DO_FUZZ: true
16-
- rust: stable
17-
env:
18-
DO_INTEGRATION: true
19-
- rust: beta
20-
- rust: nightly
21-
- rust: 1.48.0
2215
steps:
16+
- name: Checkout Crate
17+
uses: actions/checkout@v3
18+
- name: Checkout Toolchain
19+
# https://github.com/dtolnay/rust-toolchain
20+
uses: dtolnay/rust-toolchain@stable
21+
- name: Running test script
22+
env:
23+
DO_DOCS: true
24+
DO_DOCSRS: false
25+
DO_FUZZ: false
26+
DO_INTEGRATION: false
27+
DO_LINT: true
28+
DO_FEATURE_MATRIX: true
29+
run: ./contrib/test.sh
30+
31+
Nightly:
32+
name: Test - nightly toolchain
33+
runs-on: ubuntu-latest
34+
strategy:
35+
fail-fast: false
36+
steps:
37+
- name: Checkout Crate
38+
uses: actions/checkout@v3
39+
- name: Checkout Toolchain
40+
uses: dtolnay/rust-toolchain@nightly
41+
- name: Running test script
42+
env:
43+
DO_DOCS: true
44+
DO_DOCSRS: true
45+
DO_FUZZ: false
46+
DO_INTEGRATION: false
47+
DO_LINT: false
48+
DO_FEATURE_MATRIX: true
49+
run: ./contrib/test.sh
50+
51+
MSRV:
52+
name: Test - 1.48.0 toolchain
53+
runs-on: ubuntu-latest
54+
strategy:
55+
fail-fast: false
56+
steps:
57+
- name: Checkout Crate
58+
uses: actions/checkout@v3
59+
- name: Checkout Toolchain
60+
uses: dtolnay/rust-toolchain@1.48.0
61+
- name: Running test script
62+
env:
63+
DO_DOCS: false
64+
DO_DOCSRS: false
65+
DO_FUZZ: false
66+
DO_INTEGRATION: false
67+
DO_LINT: false
68+
DO_FEATURE_MATRIX: true
69+
run: ./contrib/test.sh
70+
71+
Fuzz:
72+
name: Fuzztests - 1.58.0 toolchain
73+
runs-on: ubuntu-latest
74+
strategy:
75+
fail-fast: false
76+
steps:
77+
- name: Checkout Crate
78+
uses: actions/checkout@v3
79+
- name: Checkout Toolchain
80+
uses: dtolnay/rust-toolchain@1.58.0
2381
- name: Install test dependencies
24-
run: sudo apt-get install -y binutils-dev libunwind8-dev
82+
run: sudo apt-get update -y && sudo apt-get install -y binutils-dev libunwind8-dev libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc libiberty-dev
83+
- name: Running test script
84+
env:
85+
DO_DOCS: false
86+
DO_DOCSRS: false
87+
DO_FUZZ: true
88+
DO_INTEGRATION: false
89+
DO_LINT: false
90+
DO_FEATURE_MATRIX: false
91+
run: ./contrib/test.sh
92+
93+
Integration:
94+
name: Integration tests - stable
95+
runs-on: ubuntu-latest
96+
strategy:
97+
fail-fast: false
98+
steps:
2599
- name: Checkout Crate
26-
uses: actions/checkout@v2
100+
uses: actions/checkout@v3
27101
- name: Checkout Toolchain
28-
uses: actions-rs/toolchain@v1
29-
with:
30-
profile: minimal
31-
toolchain: ${{ matrix.rust }}
32-
override: true
102+
uses: dtolnay/rust-toolchain@stable
33103
- name: Running test script
34-
env: ${{ matrix.env }}
104+
env:
105+
DO_DOCS: false
106+
DO_DOCSRS: false
107+
DO_FUZZ: false
108+
DO_INTEGRATION: true
109+
DO_LINT: false
110+
DO_FEATURE_MATRIX: false
35111
run: ./contrib/test.sh
112+

contrib/test.sh

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,49 @@
22

33
FEATURES="serde"
44

5-
# Use toolchain if explicitly specified
6-
if [ -n "$TOOLCHAIN" ]
7-
then
8-
alias cargo="cargo +$TOOLCHAIN"
9-
fi
10-
115
# Pin dependencies as required if we are using MSRV toolchain.
126
if cargo --version | grep "1\.48"; then
137
# 1.0.157 uses syn 2.0 which requires edition 2018
148
cargo update -p serde --precise 1.0.156
159
fi
1610

17-
# Test without any features first
18-
cargo test --verbose --no-default-features
19-
# Then test with the default features
20-
cargo test --verbose
21-
22-
# Also build and run each example to catch regressions
23-
cargo build --examples
24-
# run all examples
25-
run-parts ./target/debug/examples
26-
27-
# Test each feature
28-
for feature in ${FEATURES}
29-
do
30-
cargo test --verbose --features="$feature"
31-
done
11+
if [ "$DO_FEATURE_MATRX" = true ]
12+
then
13+
# Test without any features first
14+
cargo test --all --verbose --no-default-features
15+
# Then test with the default features
16+
cargo test --all --verbose
17+
# Then test with the default features
18+
cargo test --all --all-features --verbose
19+
20+
# Also build and run each example to catch regressions
21+
cargo build --examples
22+
# run all examples
23+
run-parts ./target/debug/examples
24+
25+
# Test each feature
26+
for feature in ${FEATURES}
27+
do
28+
cargo test --verbose --features="$feature"
29+
done
30+
fi
31+
32+
if [ "$DO_LINT" = true ]
33+
then
34+
cargo clippy --all-features --all-targets -- -D warnings
35+
fi
36+
37+
# Build the docs if told to (this only works with the nightly toolchain)
38+
if [ "$DO_DOCSRS" = true ]; then
39+
RUSTDOCFLAGS="--cfg docsrs -D warnings -D rustdoc::broken-intra-doc-links" cargo +nightly doc --all-features
40+
fi
41+
42+
# Build the docs with a stable toolchain, in unison with the DO_DOCSRS command
43+
# above this checks that we feature guarded docs imports correctly.
44+
if [ "$DO_DOCS" = true ]; then
45+
RUSTDOCFLAGS="-D warnings" cargo +stable doc --all-features
46+
fi
47+
3248

3349
# Fuzz if told to
3450
if [ "$DO_FUZZ" = true ]

0 commit comments

Comments
 (0)