CI #606
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
name: CI | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
schedule: | |
# Force a run every day at 0005 UTC | |
- cron: '00 05 * * *' | |
env: | |
CI: '1' | |
CARGO_TERM_COLOR: 'always' | |
# Emit backtraces on panics (though these may be worthless without debug info). | |
RUST_BACKTRACE: '1' | |
# Disable incremental builds; see https://matklad.github.io/2021/09/04/fast-rust-builds.html: | |
# | |
# CI builds often are closer to from-scratch builds, as changes are typically much bigger than from a local edit-compile cycle. | |
# For from-scratch builds, incremental adds an extra dependency-tracking overhead. | |
# It also significantly increases the amount of IO and the size of ./target, which make caching less effective. | |
CARGO_INCREMENTAL: '0' | |
# Explicitly disable LTO in release builds here, even though Nosey Parker | |
# explicitly sets it. For actual release builds that get distributed we want | |
# it, but for builds used only for testing, it adds significant time to the | |
# build. | |
# | |
# https://doc.rust-lang.org/cargo/reference/profiles.html#lto | |
CARGO_PROFILE_RELEASE_LTO: 'false' | |
# Disable debug info in CI; speeds up builds and shrinks Actions caches a bit | |
CARGO_PROFILE_RELEASE_DEBUG: '0' | |
CARGO_PROFILE_DEV_DEBUG: '0' | |
CARGO_PROFILE_TEST_DEBUG: '0' | |
# Use Cargo 1.68's new "sparse" checkout mode, which is much faster at getting crates.io index information | |
# https://blog.rust-lang.org/inside-rust/2023/01/30/cargo-sparse-protocol.html | |
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: 'sparse' | |
jobs: | |
tests: | |
name: CI | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
build: | |
- macos-12.stable.test | |
- ubuntu-20.04.stable.release | |
- ubuntu-22.04.stable.test | |
include: | |
- build: ubuntu-20.04.stable.release | |
os: ubuntu-20.04 | |
rust: stable | |
profile: release | |
features: release | |
install_dependencies: | | |
true | |
check_docs: false | |
check_rules: false | |
run_tests: true | |
- build: ubuntu-22.04.stable.test | |
os: ubuntu-22.04 | |
rust: stable | |
profile: test | |
features: | |
install_dependencies: | | |
true | |
check_docs: true | |
check_rules: true | |
run_tests: true | |
- build: macos-12.stable.test | |
os: macos-12 | |
rust: stable | |
profile: test | |
features: | |
install_dependencies: | | |
true | |
check_docs: false | |
check_rules: false | |
run_tests: true | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: ${{ matrix.install_dependencies }} | |
- name: Install Rust toolchain | |
id: install-rust-toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust }} | |
- name: Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Build tests | |
if: ${{ matrix.run_tests }} | |
run: cargo test --no-run --locked --verbose --profile=${{ matrix.profile }} --features=${{ matrix.features }} --timings | |
- name: Run tests | |
if: ${{ matrix.run_tests }} | |
env: | |
# We use the GitHub Actions automatic token when running tests, to avoid | |
# spurious failures from rate limiting when testing Nosey Parker's github | |
# enumeration capabilities. | |
NP_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: cargo test --locked --verbose --profile=${{ matrix.profile }} --features=${{ matrix.features }} --timings | |
- name: Build | |
# We only `cargo build` separately if we are running the rule checker. | |
# Otherwise this seems to just be wasted compute time! | |
if: ${{ matrix.check_rules }} | |
run: cargo build --locked --verbose --profile=${{ matrix.profile }} --features=${{ matrix.features }} --timings | |
- name: Check rules | |
if: ${{ matrix.check_rules }} | |
run: cargo run --locked --verbose --profile=${{ matrix.profile }} --features=${{ matrix.features }} --timings -- rules check crates/noseyparker/data/default/rules --warnings-as-errors | |
- name: Check documentation | |
if: ${{ matrix.check_docs }} | |
env: | |
RUSTDOCFLAGS: -D warnings | |
run: cargo doc --locked --verbose --profile=${{ matrix.profile }} --features=${{ matrix.features }} --timings --no-deps --document-private-items | |
# See https://doc.rust-lang.org/nightly/cargo/reference/timings.html for details | |
- name: Upload build timings | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-timings.${{ matrix.build }} | |
path: target/cargo-timings | |
if-no-files-found: error |