name: Test
on:
pull_request:
push:
workflow_call:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: '-C debuginfo=0'
jobs:
build:
name: Build [${{ matrix.rust }}, ${{ matrix.release }}]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [stable]
release: ["", "--release"]
args: ["--lib --tests --examples"]
include:
- rust: 1.63.0
args: "--lib"
release: ""
- rust: 1.63.0
args: "--lib"
release: "--release"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Build
run: |
sudo apt-get install --yes --no-install-recommends libreadline-dev
cargo build ${{ matrix.release }} ${{ matrix.args }}
build-static:
name: Build static
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Build
run: |
sudo apt-get install --yes --no-install-recommends libreadline-dev
cargo build --lib --tests --examples --features=static
cargo build --lib --tests --examples --features=static --release
test:
name: Test and coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Test and gather coverage
run: |
sudo apt-get install --yes --no-install-recommends libreadline-dev
cargo llvm-cov --all-targets --lcov --output-path lcov.info --ignore-filename-regex=/dev/null
- name: Upload code coverage results
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: lcov.info
test-sanitizers:
name: Test with ${{ matrix.sanitizer }} sanitizer
strategy:
fail-fast: false
matrix:
sanitizer: [address, leak]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: Enable debug symbols
run: |
# to get the symbolizer for debug symbol resolution
sudo apt-get install --yes --no-install-recommends llvm-14
# to fix buggy leak analyzer:
# https://github.com/japaric/rust-san#unrealiable-leaksanitizer
sed -i '/\[features\]/i [profile.dev]' Cargo.toml
sed -i '/profile.dev/a opt-level = 1' Cargo.toml
cat Cargo.toml
- name: cargo test -Zsanitizer=${{ matrix.sanitizer }}
env:
CFLAGS: "-fsanitize=${{ matrix.sanitizer }}"
CXXFLAGS: "-fsanitize=${{ matrix.sanitizer }}"
RUSTFLAGS: "-Zsanitizer=${{ matrix.sanitizer }}"
ASAN_OPTIONS: "detect_odr_violation=0:detect_leaks=0"
LSAN_OPTIONS: ""
run: |
sudo apt-get install --yes --no-install-recommends libreadline-dev
cargo test --workspace --lib --tests --target x86_64-unknown-linux-gnu
clippy:
name: Lint with clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo clippy --no-deps --all-targets --all-features -- -A unknown_lints -A deprecated -D warnings
cargo-doc:
name: Generate documentation
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: '-D warnings'
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo doc --no-deps