ci: Enable MC/DC coverage #514
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
name: Check | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
merge_group: | |
schedule: | |
- cron: "26 3 * * *" # 03:26 UTC | |
env: | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: 1 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref_name }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
toolchains: | |
runs-on: ubuntu-latest | |
outputs: | |
toolchains: ${{ steps.toolchains.outputs.toolchains }} | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
sparse-checkout: Cargo.toml | |
- id: toolchains | |
run: | | |
msrv="$(grep rust-version Cargo.toml | tr -d '"' | cut -f3 -d\ )" | |
echo "toolchains=[\"$msrv\", \"stable\", \"nightly\"]" >> "$GITHUB_OUTPUT" | |
check: | |
needs: toolchains | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
rust-toolchain: ${{ fromJSON(needs.toolchains.outputs.toolchains) }} | |
type: [debug] | |
include: | |
# Also do some release builds on the latest OS versions. | |
- os: ubuntu-latest | |
rust-toolchain: stable | |
type: release | |
- os: macos-latest | |
rust-toolchain: stable | |
type: release | |
- os: windows-latest | |
rust-toolchain: stable | |
type: release | |
# Also do some debug builds on the oldest OS versions. | |
- os: ubuntu-20.04 | |
rust-toolchain: stable | |
type: debug | |
- os: macos-12 | |
rust-toolchain: stable | |
type: debug | |
- os: windows-2019 | |
rust-toolchain: stable | |
type: debug | |
env: | |
BUILD_TYPE: ${{ matrix.type == 'release' && '--release' || '' }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
repository: mozilla/neqo | |
sparse-checkout: | | |
.github/actions/rust | |
path: neqo | |
- uses: ./neqo/.github/actions/rust | |
with: | |
version: ${{ matrix.rust-toolchain }} | |
components: ${{ matrix.rust-toolchain == 'stable' && 'llvm-tools' || '' }} ${{ matrix.rust-toolchain == 'nightly' && 'rust-src' || '' }} | |
tools: ${{ matrix.rust-toolchain == 'stable' && 'cargo-llvm-cov, ' || '' }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check | |
run: | | |
OPTIONS=(--all-targets) | |
if [ "$BUILD_TYPE" ]; then | |
OPTIONS+=("$BUILD_TYPE") | |
fi | |
cargo +${{ matrix.rust-toolchain }} check "${OPTIONS[@]}" | |
- name: Run tests and determine coverage | |
env: | |
RUST_LOG: trace | |
run: | | |
OPTIONS=(--no-fail-fast) | |
if [ "$BUILD_TYPE" ]; then | |
OPTIONS+=("$BUILD_TYPE") | |
fi | |
if [ "${{ matrix.rust-toolchain }}" == "stable" ] && [ "${{ matrix.type }}" == "debug" ] && [ "${{endsWith(matrix.os, '-latest') && 'latest' || '' }}" == "latest" ]; then | |
cargo +${{ matrix.rust-toolchain }} llvm-cov test --mcdc "${OPTIONS[@]}" --lcov --output-path lcov.info | |
else | |
if [ "${{ startsWith(matrix.os, 'windows') && 'windows' || '' }}" == "windows" ]; then | |
# The codegen_windows_bindings test only succeeds when run via llvm-cov?! | |
OPTIONS+=(-- --skip codegen_windows_bindings) | |
fi | |
cargo +${{ matrix.rust-toolchain }} test "${OPTIONS[@]}" | |
fi | |
cargo +${{ matrix.rust-toolchain }} bench --no-run | |
- uses: codecov/codecov-action@7f8b4b4bde536c465e797be725718b88c5d95e0e # v5.1.1 | |
with: | |
files: lcov.info | |
fail_ci_if_error: false | |
token: ${{ secrets.CODECOV_TOKEN }} | |
verbose: true | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
if: matrix.type == 'debug' && matrix.rust-toolchain == 'stable' && endsWith(matrix.os, '-latest') | |
- name: Run tests with sanitizers | |
if: (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest') && matrix.rust-toolchain == 'nightly' | |
env: | |
RUST_LOG: trace | |
ASAN_OPTIONS: detect_leaks=1:detect_stack_use_after_return=1 | |
run: | | |
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then | |
sudo apt-get install -y --no-install-recommends llvm | |
TARGET="x86_64-unknown-linux-gnu" | |
SANITIZERS="address thread leak memory" | |
elif [ "${{ matrix.os }}" = "macos-latest" ]; then | |
# llvm-symbolizer (as part of llvm) is installed by default on macOS runners | |
TARGET="aarch64-apple-darwin" | |
# no memory and leak sanitizer support yet | |
SANITIZERS="address thread" | |
# Suppress non-mtu leaks on macOS. TODO: Check occasionally if these are still needed. | |
{ | |
echo "leak:dyld4::RuntimeState" | |
echo "leak:fetchInitializingClassList" | |
} > suppressions.txt | |
# shellcheck disable=SC2155 | |
export LSAN_OPTIONS="suppressions=$(pwd)/suppressions.txt" | |
fi | |
for sanitizer in $SANITIZERS; do | |
echo "Running tests with $sanitizer sanitizer..." | |
export RUSTFLAGS="-Z sanitizer=$sanitizer" | |
export RUSTDOCFLAGS="$RUSTFLAGS" | |
cargo +nightly test -Z build-std --target "$TARGET" | |
done | |
clippy: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
repository: mozilla/neqo | |
sparse-checkout: | | |
.github/actions/rust | |
path: neqo | |
- uses: ./neqo/.github/actions/rust | |
with: | |
components: clippy | |
tools: cargo-hack | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- run: cargo hack clippy --all-targets --feature-powerset --exclude-features gecko -- -D warnings | |
- run: cargo doc --workspace --no-deps --document-private-items | |
env: | |
RUSTDOCFLAGS: "--deny rustdoc::broken_intra_doc_links --deny warnings" | |
machete: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
repository: mozilla/neqo | |
sparse-checkout: | | |
.github/actions/rust | |
path: neqo | |
- uses: ./neqo/.github/actions/rust | |
with: | |
tools: cargo-machete | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# --with-metadata has false positives, see https://github.com/bnjbvr/cargo-machete/issues/127 | |
- run: cargo machete | |
format: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
repository: mozilla/neqo | |
sparse-checkout: | | |
.github/actions/rust | |
path: neqo | |
- uses: ./neqo/.github/actions/rust | |
with: | |
version: nightly | |
components: rustfmt | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- run: cargo fmt --all -- --check | |
semver: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
repository: mozilla/neqo | |
sparse-checkout: | | |
.github/actions/rust | |
path: neqo | |
- uses: ./neqo/.github/actions/rust | |
with: | |
tools: cargo-semver-checks | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- run: cargo semver-checks --default-features | |
readme: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
repository: mozilla/neqo | |
sparse-checkout: | | |
.github/actions/rust | |
path: neqo | |
- uses: ./neqo/.github/actions/rust | |
with: | |
tools: cargo-readme | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- run: | | |
cargo readme -o /tmp/README.md | |
diff -u README.md /tmp/README.md | |
check-vm: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [freebsd, openbsd, netbsd] # rust on solaris is too old | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- run: curl -o rustup.sh --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | |
- if: matrix.os == 'freebsd' | |
uses: vmactions/freebsd-vm@debf37ca7b7fa40e19c542ef7ba30d6054a706a4 | |
with: | |
usesh: true | |
envs: "CARGO_TERM_COLOR RUST_BACKTRACE GITHUB_ACTIONS" | |
prepare: | | |
pkg install -y curl llvm | |
run: | | |
sh rustup.sh --default-toolchain stable --component llvm-tools -y | |
. "$HOME/.cargo/env" | |
export RUST_LOG=trace | |
cargo install cargo-llvm-cov --locked | |
cargo check --all-targets | |
cargo clippy | |
cargo llvm-cov test --mcdc --no-fail-fast --lcov --output-path lcov.info | |
cargo test --no-fail-fast --release | |
- if: matrix.os == 'openbsd' | |
uses: vmactions/openbsd-vm@0cfe06e734a0ea3a546fca7ebf200b984b94d58a | |
with: | |
usesh: true | |
envs: "CARGO_TERM_COLOR RUST_BACKTRACE GITHUB_ACTIONS" | |
prepare: | | |
pkg_add rust llvm-16.0.6p30 # rustup doesn't support OpenBSD at all | |
run: | | |
export LIBCLANG_PATH=/usr/local/llvm16/lib | |
export RUST_LOG=trace | |
cargo check --all-targets | |
cargo clippy | |
cargo test --no-fail-fast | |
cargo test --no-fail-fast --release | |
- if: matrix.os == 'netbsd' | |
uses: vmactions/netbsd-vm@7c9086fdb4cc1aa814cda6e305390c2b966551a9 | |
with: | |
usesh: true | |
envs: "CARGO_TERM_COLOR RUST_BACKTRACE GITHUB_ACTIONS" | |
prepare: | | |
/usr/sbin/pkg_add pkgin | |
pkgin -y install curl clang | |
run: | | |
sh rustup.sh --default-toolchain stable --component llvm-tools -y | |
. "$HOME/.cargo/env" | |
export LIBCLANG_PATH=/usr/pkg/lib | |
export RUST_LOG=trace | |
cargo install cargo-llvm-cov --locked | |
cargo check --all-targets | |
cargo clippy | |
cargo test --no-fail-fast | |
# FIXME: error[E0463]: can't find crate for `profiler_builtins`, | |
# so don't fail the workflow when that happens. | |
cargo llvm-cov test --mcdc --no-fail-fast --lcov --output-path lcov.info || true | |
cargo test --no-fail-fast --release | |
- if: matrix.os == 'solaris' | |
uses: vmactions/solaris-vm@a89b9438868c70db27e41625f0a5de6ff5e90809 | |
with: | |
usesh: true | |
envs: "CARGO_TERM_COLOR RUST_BACKTRACE GITHUB_ACTIONS" | |
run: | | |
sh rustup.sh --default-toolchain stable --component llvm-tools -y | |
. "$HOME/.cargo/env" | |
export RUST_LOG=trace | |
cargo install cargo-llvm-cov --locked | |
cargo check --all-targets | |
cargo clippy | |
cargo llvm-cov test --mcdc --no-fail-fast --lcov --output-path lcov.info | |
cargo test --no-fail-fast --release | |
- uses: codecov/codecov-action@7f8b4b4bde536c465e797be725718b88c5d95e0e # v5.1.1 | |
with: | |
files: lcov.info | |
fail_ci_if_error: false | |
token: ${{ secrets.CODECOV_TOKEN }} | |
verbose: true | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
check-cargo-lock: | |
name: Ensure `Cargo.lock` contains all required dependencies | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
repository: mozilla/neqo | |
sparse-checkout: | | |
.github/actions/rust | |
path: neqo | |
- uses: ./neqo/.github/actions/rust | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- run: cargo update -w --locked |