Skip to content

Commit 43bccb6

Browse files
jonhoowfxr
authored andcommitted
ci: setup
Merge another codecov Merge another codecov Merge another codecov Merge another codecov Place codecov config under .github Add (only) ASAN workflow Add first coverage workflow Merge another coverage.yml Merge another coverage.yml Add first features workflow Merge another features workflow Merge another features workflow Merge another features workflow Add (only) loom workflow Add (only) LSAN workflow Add first minial workflow Add (only) miri workflow Add first msrv workflow Merge another msrv workflow Merge another msrv workflow Merge another msrv workflow Add (only) no-std workflow Add first os-check workflow Merge another os-check workflow Add first style workflow Merge another style workflow Merge another style workflow Add first test workflow Merge another test workflow Merge another test workflow Merge another test workflow Make everything use checkout@v3 Standardize on 'main' as branch name Missed a submodule checkout Add TODOs from twitter thread Practice what you preach mv github .github This should make it possible to have rust-ci-conf as a remote you merge from. Merge safety workflows Catch upcoming deprecations More concise name for scheduled jobs Allow examples and binaries to require features Use dependabot, but only for major versions ignore is a list Notify if actions themselves are outdated Bump codecov/codecov-action from 2 to 3 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 2 to 3. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](codecov/codecov-action@v2...v3) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Move to maintained rust installer See actions-rs/toolchain#216 Fix install message for msrv Get rid of most actions-rs bits Given that that project is unmaintained. actions-rs/toolchain#216 Minimal token permissions See tokio-rs/tokio#5072 Remove -Zmiri-tag-raw-pointers as it's now default Unbreak cargo hack for non-libraries (#4) Add action to run doctest. (#3) `cargo test --all-features` does not run doc-tests. For more information see rust-lang/cargo#6669. chore: automatically cancel superseded Actions runs (#5) [sanity] More robust injection of opt-level 1 (#9) Fixes #8 Quote MSRV version to avoid float parsing (#11) Put 1.70 in there (for instance if you want to pin against OnceLock stabilizing) and it will actually test 1.7 as it appears github auto converts this to a float? Putting in quotes seems to do the right thing here Install Openssl for Windows (#12) Don't install OpenSSL on Windows by default Bump actions/checkout from 3 to 4 (#13) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> docs: Add documentation based on the youtube video (#10) Nit: Selecting direct minimal versions flag is -Zdirect-minimal-versions (#16) chore: fix typos (#17) Remove stray trailing whitespace replace actions-rs/clippy-check with giraffate/clippy-action (#19) Co-authored-by: rtkay123 <[email protected]> Semi-breaking: update codecov action Note: this requires adding `CODECOV_TOKEN` to your GitHub repository's secrets! See associated comment in the commit content. Uniform capitalization
1 parent f345461 commit 43bccb6

File tree

8 files changed

+504
-0
lines changed

8 files changed

+504
-0
lines changed

.github/DOCS.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Github config and workflows
2+
3+
In this folder there is configuration for codecoverage, dependabot, and ci
4+
workflows that check the library more deeply than the default configurations.
5+
6+
This folder can be or was merged using a --allow-unrelated-histories merge
7+
strategy from <https://github.com/jonhoo/rust-ci-conf/> which provides a
8+
reasonably sensible base for writing your own ci on. By using this strategy
9+
the history of the CI repo is included in your repo, and future updates to
10+
the CI can be merged later.
11+
12+
To perform this merge run:
13+
14+
```shell
15+
git remote add ci https://github.com/jonhoo/rust-ci-conf.git
16+
git fetch ci
17+
git merge --allow-unrelated-histories ci/main
18+
```
19+
20+
An overview of the files in this project is available at:
21+
<https://www.youtube.com/watch?v=xUH-4y92jPg&t=491s>, which contains some
22+
rationale for decisions and runs through an example of solving minimal version
23+
and OpenSSL issues.

.github/codecov.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# ref: https://docs.codecov.com/docs/codecovyml-reference
2+
coverage:
3+
# Hold ourselves to a high bar
4+
range: 85..100
5+
round: down
6+
precision: 1
7+
status:
8+
# ref: https://docs.codecov.com/docs/commit-status
9+
project:
10+
default:
11+
# Avoid false negatives
12+
threshold: 1%
13+
14+
# Test files aren't important for coverage
15+
ignore:
16+
- "tests"
17+
18+
# Make comments less noisy
19+
comment:
20+
layout: "files"
21+
require_changes: true

.github/dependabot.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: daily
7+
- package-ecosystem: cargo
8+
directory: /
9+
schedule:
10+
interval: daily
11+
ignore:
12+
- dependency-name: "*"
13+
# patch and minor updates don't matter for libraries as consumers of this library build
14+
# with their own lockfile, rather than the version specified in this library's lockfile
15+
# remove this ignore rule if your package has binaries to ensure that the binaries are
16+
# built with the exact set of dependencies and those are up to date.
17+
update-types:
18+
- "version-update:semver-patch"
19+
- "version-update:semver-minor"

.github/workflows/check.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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: [main]
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+
doc:
63+
# run docs generation on nightly rather than stable. This enables features like
64+
# https://doc.rust-lang.org/beta/unstable-book/language-features/doc-cfg.html which allows an
65+
# API be documented as only available in some specific platforms.
66+
runs-on: ubuntu-latest
67+
name: nightly / doc
68+
steps:
69+
- uses: actions/checkout@v4
70+
with:
71+
submodules: true
72+
- name: Install nightly
73+
uses: dtolnay/rust-toolchain@nightly
74+
- name: cargo doc
75+
run: cargo doc --no-deps --all-features
76+
env:
77+
RUSTDOCFLAGS: --cfg docsrs
78+
hack:
79+
# cargo-hack checks combinations of feature flags to ensure that features are all additive
80+
# which is required for feature unification
81+
runs-on: ubuntu-latest
82+
name: ubuntu / stable / features
83+
steps:
84+
- uses: actions/checkout@v4
85+
with:
86+
submodules: true
87+
- name: Install stable
88+
uses: dtolnay/rust-toolchain@stable
89+
- name: cargo install cargo-hack
90+
uses: taiki-e/install-action@cargo-hack
91+
# intentionally no target specifier; see https://github.com/jonhoo/rust-ci-conf/pull/4
92+
# --feature-powerset runs for every combination of features
93+
- name: cargo hack
94+
run: cargo hack --feature-powerset check
95+
msrv:
96+
# check that we can build using the minimal rust version that is specified by this crate
97+
runs-on: ubuntu-latest
98+
# we use a matrix here just because env can't be used in job names
99+
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
100+
strategy:
101+
matrix:
102+
msrv: ["1.56.1"] # 2021 edition requires 1.56
103+
name: ubuntu / ${{ matrix.msrv }}
104+
steps:
105+
- uses: actions/checkout@v4
106+
with:
107+
submodules: true
108+
- name: Install ${{ matrix.msrv }}
109+
uses: dtolnay/rust-toolchain@master
110+
with:
111+
toolchain: ${{ matrix.msrv }}
112+
- name: cargo +${{ matrix.msrv }} check
113+
run: cargo check

.github/workflows/nostd.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This workflow checks whether the library is able to run without the std library (e.g., embedded).
2+
# This entire file should be removed if this crate does not support no-std. See check.yml for
3+
# information about how the concurrency cancellation and workflow triggering works
4+
permissions:
5+
contents: read
6+
on:
7+
push:
8+
branches: [main]
9+
pull_request:
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
12+
cancel-in-progress: true
13+
name: no-std
14+
jobs:
15+
nostd:
16+
runs-on: ubuntu-latest
17+
name: ${{ matrix.target }}
18+
strategy:
19+
matrix:
20+
target: [thumbv7m-none-eabi, aarch64-unknown-none]
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
submodules: true
25+
- name: Install stable
26+
uses: dtolnay/rust-toolchain@stable
27+
- name: rustup target add ${{ matrix.target }}
28+
run: rustup target add ${{ matrix.target }}
29+
- name: cargo check
30+
run: cargo check --target ${{ matrix.target }} --no-default-features

.github/workflows/safety.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# This workflow runs checks for unsafe code. In crates that don't have any unsafe code, this can be
2+
# removed. Runs:
3+
# - miri - detects undefined behavior and memory leaks
4+
# - address sanitizer - detects memory errors
5+
# - leak sanitizer - detects memory leaks
6+
# - loom - Permutation testing for concurrent code https://crates.io/crates/loom
7+
# See check.yml for information about how the concurrency cancellation and workflow triggering works
8+
permissions:
9+
contents: read
10+
on:
11+
push:
12+
branches: [main]
13+
pull_request:
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
16+
cancel-in-progress: true
17+
name: safety
18+
jobs:
19+
sanitizers:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
submodules: true
25+
- name: Install nightly
26+
uses: dtolnay/rust-toolchain@nightly
27+
- run: |
28+
# to get the symbolizer for debug symbol resolution
29+
sudo apt install llvm
30+
# to fix buggy leak analyzer:
31+
# https://github.com/japaric/rust-san#unrealiable-leaksanitizer
32+
# ensure there's a profile.dev section
33+
if ! grep -qE '^[ \t]*[profile.dev]' Cargo.toml; then
34+
echo >> Cargo.toml
35+
echo '[profile.dev]' >> Cargo.toml
36+
fi
37+
# remove pre-existing opt-levels in profile.dev
38+
sed -i '/^\s*\[profile.dev\]/,/^\s*\[/ {/^\s*opt-level/d}' Cargo.toml
39+
# now set opt-level to 1
40+
sed -i '/^\s*\[profile.dev\]/a opt-level = 1' Cargo.toml
41+
cat Cargo.toml
42+
name: Enable debug symbols
43+
- name: cargo test -Zsanitizer=address
44+
# only --lib --tests b/c of https://github.com/rust-lang/rust/issues/53945
45+
run: cargo test --lib --tests --all-features --target x86_64-unknown-linux-gnu
46+
env:
47+
ASAN_OPTIONS: "detect_odr_violation=0:detect_leaks=0"
48+
RUSTFLAGS: "-Z sanitizer=address"
49+
- name: cargo test -Zsanitizer=leak
50+
if: always()
51+
run: cargo test --all-features --target x86_64-unknown-linux-gnu
52+
env:
53+
LSAN_OPTIONS: "suppressions=lsan-suppressions.txt"
54+
RUSTFLAGS: "-Z sanitizer=leak"
55+
miri:
56+
runs-on: ubuntu-latest
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
70+
env:
71+
MIRIFLAGS: ""
72+
loom:
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@v4
76+
with:
77+
submodules: true
78+
- name: Install stable
79+
uses: dtolnay/rust-toolchain@stable
80+
- name: cargo test --test loom
81+
run: cargo test --release --test loom
82+
env:
83+
LOOM_MAX_PREEMPTIONS: 2
84+
RUSTFLAGS: "--cfg loom"

.github/workflows/scheduled.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Run scheduled (rolling) jobs on a nightly basis, as your crate may break independently of any
2+
# given PR. E.g., updates to rust nightly and updates to this crates dependencies. See check.yml for
3+
# information about how the concurrency cancellation and workflow triggering works
4+
permissions:
5+
contents: read
6+
on:
7+
push:
8+
branches: [main]
9+
pull_request:
10+
schedule:
11+
- cron: '7 7 * * *'
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
14+
cancel-in-progress: true
15+
name: rolling
16+
jobs:
17+
# https://twitter.com/mycoliza/status/1571295690063753218
18+
nightly:
19+
runs-on: ubuntu-latest
20+
name: ubuntu / nightly
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
submodules: true
25+
- name: Install nightly
26+
uses: dtolnay/rust-toolchain@nightly
27+
- name: cargo generate-lockfile
28+
if: hashFiles('Cargo.lock') == ''
29+
run: cargo generate-lockfile
30+
- name: cargo test --locked
31+
run: cargo test --locked --all-features --all-targets
32+
# https://twitter.com/alcuadrado/status/1571291687837732873
33+
update:
34+
# This action checks that updating the dependencies of this crate to the latest available that
35+
# satisfy the versions in Cargo.toml does not break this crate. This is important as consumers
36+
# of this crate will generally use the latest available crates. This is subject to the standard
37+
# Cargo semver rules (i.e cargo does not update to a new major version unless explicitly told
38+
# to).
39+
runs-on: ubuntu-latest
40+
name: ubuntu / beta / updated
41+
# There's no point running this if no Cargo.lock was checked in in the first place, since we'd
42+
# just redo what happened in the regular test job. Unfortunately, hashFiles only works in if on
43+
# steps, so we repeat it.
44+
steps:
45+
- uses: actions/checkout@v4
46+
with:
47+
submodules: true
48+
- name: Install beta
49+
if: hashFiles('Cargo.lock') != ''
50+
uses: dtolnay/rust-toolchain@beta
51+
- name: cargo update
52+
if: hashFiles('Cargo.lock') != ''
53+
run: cargo update
54+
- name: cargo test
55+
if: hashFiles('Cargo.lock') != ''
56+
run: cargo test --locked --all-features --all-targets
57+
env:
58+
RUSTFLAGS: -D deprecated

0 commit comments

Comments
 (0)