Skip to content

Commit 551c892

Browse files
committed
revmap CI workflows
1 parent 8fef456 commit 551c892

5 files changed

Lines changed: 260 additions & 80 deletions

File tree

.github/DOCS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Workflows adapted from https://github.com/jonhoo/rust-ci-conf.

.github/workflows/check.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# This workflow runs whenever a PR is opened or updated, or a commit is pushed to main. It runs
2+
# several checks:
3+
# - fmt: checks that the code is formatted according to rustfmt
4+
# - clippy: checks that the code does not contain any clippy warnings
5+
# - doc: checks that the code can be documented without errors
6+
# - hack: check combinations of feature flags
7+
# - msrv: check that the msrv specified in the crate is correct
8+
permissions:
9+
contents: read
10+
# This configuration allows maintainers of this repo to create a branch and pull request based on
11+
# the new branch. Restricting the push trigger to the main branch ensures that the PR only gets
12+
# built once.
13+
on:
14+
push:
15+
branches: [master]
16+
pull_request:
17+
# If new code is pushed to a PR branch, then cancel in progress workflows for that PR. Ensures that
18+
# we don't waste CI time, and returns results quicker https://github.com/jonhoo/rust-ci-conf/pull/5
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
21+
cancel-in-progress: true
22+
name: check
23+
jobs:
24+
fmt:
25+
runs-on: ubuntu-latest
26+
name: stable / fmt
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
submodules: true
31+
- name: Install stable
32+
uses: dtolnay/rust-toolchain@stable
33+
with:
34+
components: rustfmt
35+
- name: cargo fmt --check
36+
run: cargo fmt --check
37+
clippy:
38+
runs-on: ubuntu-latest
39+
name: ${{ matrix.toolchain }} / clippy
40+
permissions:
41+
contents: read
42+
checks: write
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
# Get early warning of new lints which are regularly introduced in beta channels.
47+
toolchain: [stable, beta]
48+
steps:
49+
- uses: actions/checkout@v4
50+
with:
51+
submodules: true
52+
- name: Install ${{ matrix.toolchain }}
53+
uses: dtolnay/rust-toolchain@master
54+
with:
55+
toolchain: ${{ matrix.toolchain }}
56+
components: clippy
57+
- name: cargo clippy
58+
uses: giraffate/clippy-action@v1
59+
with:
60+
reporter: 'github-pr-check'
61+
github_token: ${{ secrets.GITHUB_TOKEN }}
62+
semver:
63+
runs-on: ubuntu-latest
64+
name: semver
65+
steps:
66+
- uses: actions/checkout@v4
67+
with:
68+
submodules: true
69+
- name: Install stable
70+
uses: dtolnay/rust-toolchain@stable
71+
with:
72+
components: rustfmt
73+
- name: cargo-semver-checks
74+
uses: obi1kenobi/cargo-semver-checks-action@v2
75+
doc:
76+
# run docs generation on nightly rather than stable. This enables features like
77+
# https://doc.rust-lang.org/beta/unstable-book/language-features/doc-cfg.html which allows an
78+
# API be documented as only available in some specific platforms.
79+
runs-on: ubuntu-latest
80+
name: nightly / doc
81+
steps:
82+
- uses: actions/checkout@v4
83+
with:
84+
submodules: true
85+
- name: Install nightly
86+
uses: dtolnay/rust-toolchain@nightly
87+
- name: cargo doc
88+
run: cargo doc --no-deps --all-features
89+
env:
90+
RUSTDOCFLAGS: --cfg docsrs
91+
hack:
92+
# cargo-hack checks combinations of feature flags to ensure that features are all additive
93+
# which is required for feature unification
94+
runs-on: ubuntu-latest
95+
name: ubuntu / stable / features
96+
steps:
97+
- uses: actions/checkout@v4
98+
with:
99+
submodules: true
100+
- name: Install stable
101+
uses: dtolnay/rust-toolchain@stable
102+
- name: cargo install cargo-hack
103+
uses: taiki-e/install-action@cargo-hack
104+
# intentionally no target specifier; see https://github.com/jonhoo/rust-ci-conf/pull/4
105+
# --feature-powerset runs for every combination of features
106+
- name: cargo hack
107+
run: cargo hack --feature-powerset check
108+
msrv:
109+
# check that we can build using the minimal rust version that is specified by this crate
110+
runs-on: ubuntu-latest
111+
# we use a matrix here just because env can't be used in job names
112+
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
113+
strategy:
114+
matrix:
115+
msrv: ["1.72.0"]
116+
name: ubuntu / ${{ matrix.msrv }}
117+
steps:
118+
- uses: actions/checkout@v4
119+
with:
120+
submodules: true
121+
- name: Install ${{ matrix.msrv }}
122+
uses: dtolnay/rust-toolchain@master
123+
with:
124+
toolchain: ${{ matrix.msrv }}
125+
- name: cargo +${{ matrix.msrv }} check
126+
run: cargo check

.github/workflows/rust.yml

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

.github/workflows/safety.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Runs:
2+
# - miri - detects undefined behavior and memory leaks
3+
# - address sanitizer - detects memory errors
4+
# - leak sanitizer - detects memory leaks
5+
# See check.yml for information about how the concurrency cancellation and workflow triggering works
6+
permissions:
7+
contents: read
8+
on:
9+
push:
10+
branches: [master]
11+
pull_request:
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
14+
cancel-in-progress: true
15+
name: safety
16+
jobs:
17+
sanitizers:
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 15
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
submodules: true
24+
- name: Install nightly
25+
uses: dtolnay/rust-toolchain@nightly
26+
- run: |
27+
# to get the symbolizer for debug symbol resolution
28+
sudo apt install llvm
29+
# to fix buggy leak analyzer:
30+
# https://github.com/japaric/rust-san#unrealiable-leaksanitizer
31+
# ensure there's a profile.dev section
32+
if ! grep -qE '^[ \t]*[profile.dev]' Cargo.toml; then
33+
echo >> Cargo.toml
34+
echo '[profile.dev]' >> Cargo.toml
35+
fi
36+
# remove pre-existing opt-levels in profile.dev
37+
sed -i '/^\s*\[profile.dev\]/,/^\s*\[/ {/^\s*opt-level/d}' Cargo.toml
38+
# now set opt-level to 1
39+
sed -i '/^\s*\[profile.dev\]/a opt-level = 1' Cargo.toml
40+
cat Cargo.toml
41+
name: Enable debug symbols
42+
- name: cargo test -Zsanitizer=address
43+
# only --lib --tests b/c of https://github.com/rust-lang/rust/issues/53945
44+
run: cargo test --lib --tests --all-features --target x86_64-unknown-linux-gnu
45+
env:
46+
ASAN_OPTIONS: "detect_odr_violation=0:detect_leaks=0"
47+
RUSTFLAGS: "-Z sanitizer=address"
48+
- name: cargo test -Zsanitizer=leak
49+
if: always()
50+
run: cargo test --all-features --target x86_64-unknown-linux-gnu
51+
env:
52+
LSAN_OPTIONS: "suppressions=lsan-suppressions.txt"
53+
RUSTFLAGS: "-Z sanitizer=leak"
54+
miri:
55+
runs-on: ubuntu-latest
56+
timeout-minutes: 15
57+
steps:
58+
- uses: actions/checkout@v4
59+
with:
60+
submodules: true
61+
- run: |
62+
echo "NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri)" >> $GITHUB_ENV
63+
- name: Install ${{ env.NIGHTLY }}
64+
uses: dtolnay/rust-toolchain@master
65+
with:
66+
toolchain: ${{ env.NIGHTLY }}
67+
components: miri
68+
- name: cargo miri test
69+
run: cargo miri test --all-features

.github/workflows/test.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# This is the main CI workflow that runs the test suite on all pushes to main and all pull requests.
2+
# It runs the following jobs:
3+
# - required: runs the test suite on ubuntu with stable and beta rust toolchains
4+
# requirements of this crate, and its dependencies
5+
# - os-check: runs the test suite on mac and windows
6+
# See check.yml for information about how the concurrency cancellation and workflow triggering works
7+
permissions:
8+
contents: read
9+
on:
10+
push:
11+
branches: [master]
12+
pull_request:
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
15+
cancel-in-progress: true
16+
name: test
17+
jobs:
18+
required:
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 15
21+
name: ubuntu / ${{ matrix.toolchain }}
22+
strategy:
23+
matrix:
24+
# run on stable and beta to ensure that tests won't break on the next version of the rust
25+
# toolchain
26+
toolchain: [stable, beta]
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
submodules: true
31+
- name: Install ${{ matrix.toolchain }}
32+
uses: dtolnay/rust-toolchain@master
33+
with:
34+
toolchain: ${{ matrix.toolchain }}
35+
- name: cargo generate-lockfile
36+
# enable this ci template to run regardless of whether the lockfile is checked in or not
37+
if: hashFiles('Cargo.lock') == ''
38+
run: cargo generate-lockfile
39+
# https://twitter.com/jonhoo/status/1571290371124260865
40+
- name: cargo test --locked
41+
run: cargo test --locked --all-features --all-targets
42+
# https://github.com/rust-lang/cargo/issues/6669
43+
- name: cargo test --doc
44+
run: cargo test --locked --all-features --doc
45+
os-check:
46+
# run cargo test on mac and windows
47+
runs-on: ${{ matrix.os }}
48+
timeout-minutes: 15
49+
name: ${{ matrix.os }} / stable
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
os: [macos-latest, windows-latest]
54+
steps:
55+
- uses: actions/checkout@v4
56+
with:
57+
submodules: true
58+
- name: Install stable
59+
uses: dtolnay/rust-toolchain@stable
60+
- name: cargo generate-lockfile
61+
if: hashFiles('Cargo.lock') == ''
62+
run: cargo generate-lockfile
63+
- name: cargo test
64+
run: cargo test --locked --all-features --all-targets

0 commit comments

Comments
 (0)