Port to the Linebender lint set #88
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
env: | |
# We aim to always test with the latest stable Rust toolchain, however we pin to a specific | |
# version like 1.70. Note that we only specify MAJOR.MINOR and not PATCH so that bugfixes still | |
# come automatically. If the version specified here is no longer the latest stable version, | |
# then please feel free to submit a PR that adjusts it along with the potential clippy fixes. | |
# When updating this, also update RUST_DOCS_COMPILE_VER below to the same version | |
RUST_STABLE_VER: "1.82" # In quotes because otherwise (e.g.) 1.70 would be interpreted as 1.7 | |
# The version of rustc we use to test that doc examples compile. | |
# This is required because we depend on the unstable `-Zdoctest-xcompile`. | |
# See https://github.com/rust-lang/rust/issues/64245 | |
# This should be the same version of Rust which the above stable was branched from. | |
# To get the correct date, use `cargo --version`. E.g for 1.77, this prints | |
# cargo 1.77.0 (3fe68eabf 2024-02-29) | |
# So the date used when we depended on 1.77 was 2024-02-29. | |
RUST_DOCS_COMPILE_VER: "nightly-2024-10-15" | |
# The purpose of checking with the minimum supported Rust toolchain is to detect its staleness. | |
# If the compilation fails, then the version specified here needs to be bumped up to reality. | |
# Be sure to also update the rust-version property in the workspace Cargo.toml file, | |
# plus all the README.md files of the affected packages. | |
RUST_MIN_VER: "1.77" | |
# List of packages that will be checked with the minimum supported Rust version. | |
# This should be limited to packages that are intended for publishing. | |
RUST_MIN_VER_PKGS: "-p android_trace -p tracing_android_trace" | |
# Rationale | |
# | |
# We don't run clippy with --all-targets because then even --lib and --bins are compiled with | |
# dev dependencies enabled, which does not match how they would be compiled by users. | |
# A dev dependency might enable a feature that we need for a regular dependency, | |
# and checking with --all-targets would not find our feature requirements lacking. | |
# This problem still applies to cargo resolver version 2. | |
# Thus we split all the targets into two steps, one with --lib --bins | |
# and another with --tests --benches --examples. | |
# Also, we can't give --lib --bins explicitly because then cargo will error on binary-only packages. | |
# Luckily the default behavior of cargo with no explicit targets is the same but without the error. | |
# | |
# We use cargo-hack for a similar reason. Cargo's --workspace will do feature unification across | |
# the whole workspace. While cargo-hack will instead check each workspace package separately. | |
# | |
# Using cargo-hack also allows us to more easily test the feature matrix of our packages. | |
# We use --each-feature & --optional-deps which will run a separate check for every feature. | |
# | |
# The MSRV jobs run only cargo check because different clippy versions can disagree on goals and | |
# running tests introduces dev dependencies which may require a higher MSRV than the bare package. | |
# | |
# We don't save caches in the merge-group cases, because those caches will never be re-used (apart | |
# from the very rare cases where there are multiple PRs in the merge queue). | |
# This is because GitHub doesn't share caches between merge queues and the main branch. | |
name: CI | |
on: | |
pull_request: | |
merge_group: | |
# We run on push, even though the commit is the same as when we ran in merge_group. | |
# This allows the cache to be primed. | |
# See https://github.com/orgs/community/discussions/66430 | |
push: | |
branches: | |
- main | |
jobs: | |
fmt: | |
name: formatting | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: install stable toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.RUST_STABLE_VER }} | |
components: rustfmt | |
- name: cargo fmt | |
run: cargo fmt --all --check | |
- name: install ripgrep | |
run: | | |
sudo apt update | |
sudo apt install ripgrep | |
- name: check copyright headers | |
run: bash .github/copyright.sh | |
clippy-stable: | |
name: cargo clippy | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
# We don't have any ABI specific code, but it's best to double check anyway | |
android_target: [armv7-linux-androideabi, aarch64-linux-android, x86_64-linux-android] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: install stable toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.RUST_STABLE_VER }} | |
components: clippy | |
targets: ${{ matrix.android_target }} | |
- name: install cargo-hack | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-hack | |
- name: restore cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
save-if: ${{ github.event_name != 'merge_group' }} | |
key: ${{ matrix.android_target }} | |
- name: cargo clippy | |
run: cargo hack clippy --workspace --locked --target ${{ matrix.android_target }} --optional-deps --each-feature -- -D warnings | |
- name: cargo clippy (auxiliary) | |
run: cargo hack clippy --workspace --locked --target ${{ matrix.android_target }} --optional-deps --each-feature --tests --benches --examples -- -D warnings | |
# TODO: Find a way to run tests | |
# test-stable: | |
# name: cargo test | |
# runs-on: ubuntu-latest | |
# strategy: | |
# matrix: | |
# android_target: [armv7-linux-androideabi, aarch64-linux-android, x86_64-linux-android] | |
# steps: | |
# - uses: actions/checkout@v4 | |
# | |
# - name: install stable toolchain | |
# uses: dtolnay/rust-toolchain@master | |
# with: | |
# toolchain: ${{ env.RUST_STABLE_VER }} | |
# | |
# - name: restore cache | |
# uses: Swatinem/rust-cache@v2 | |
# with: | |
# save-if: ${{ github.event_name != 'merge_group' }} | |
# key: ${{ matrix.android_target }} | |
# | |
# - name: cargo test | |
# run: cargo test --workspace --locked --target ${{ matrix.android_target }} --all-features | |
check-msrv: | |
name: cargo check (msrv) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: install stable toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.RUST_MIN_VER }} | |
# Only check MSRV on aarch64-linux-android | |
targets: aarch64-linux-android | |
- name: install cargo-hack | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-hack | |
- name: restore cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
save-if: ${{ github.event_name != 'merge_group' }} | |
- name: cargo check | |
run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} --locked --target aarch64-linux-android --optional-deps --each-feature | |
doc: | |
name: cargo doc | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: install nightly toolchain | |
uses: dtolnay/rust-toolchain@nightly | |
with: | |
targets: aarch64-linux-android | |
- name: restore cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
save-if: ${{ github.event_name != 'merge_group' }} | |
# We test documentation using nightly to match docs.rs. | |
- name: cargo doc | |
run: cargo doc --workspace --locked --target aarch64-linux-android --all-features --no-deps --document-private-items | |
env: | |
RUSTDOCFLAGS: '--cfg docsrs -D warnings' | |
docs-compile: | |
name: cargo test --doc | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: install nightly toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.RUST_DOCS_COMPILE_VER }} | |
# We expect our docs to be arch-independent | |
targets: aarch64-linux-android | |
- name: restore cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
save-if: ${{ github.event_name != 'merge_group' }} | |
# We test that the code examples in our docs compile, which requires nightly. | |
# See the docs on RUST_DOCS_COMPILE_VER, above. | |
# Even though there could be doctests on conditionally compiled out private items, | |
# we don't expect those to exist, so we don't use cargo hack. | |
# It is a shame that we can't detect those, though. | |
- name: cargo test --doc | |
run: cargo test --doc --workspace --locked --target aarch64-linux-android --all-features -Zdoctest-xcompile | |
# If this fails, consider changing your text or adding something to .typos.toml. | |
typos: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: check typos | |
uses: crate-ci/[email protected] |