name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '00 01 * * *'
env:
RUST_BACKTRACE: 1
jobs:
test:
name: Test Rust - ${{ matrix.build }}
runs-on: ${{ matrix.os }}
env:
CARGO: cargo
TARGET: ''
strategy:
fail-fast: false
matrix:
build: [macos, linux, linux32, win64-msvc, win64-gnu, win32-msvc, win32-gnu, msrv, beta, nightly, arm32, arm64, mips32, mips64]
include:
- { build: linux, os: ubuntu-latest, rust: stable }
- { build: macos, os: macos-latest, rust: stable }
- { build: win64-msvc, os: windows-2019, rust: stable }
- { build: win64-gnu, os: windows-2019, rust: stable-x86_64-gnu }
- { build: win32-msvc, os: windows-2019, rust: stable-i686-msvc }
- { build: win32-gnu, os: windows-2019, rust: stable-i686-gnu }
- { build: msrv, os: ubuntu-latest, rust: '1.43.0' }
- { build: beta, os: ubuntu-latest, rust: beta }
- { build: nightly, os: ubuntu-latest, rust: nightly }
- { build: linux32, os: ubuntu-latest, rust: stable, target: i686-unknown-linux-gnu }
- { build: arm32, os: ubuntu-latest, rust: stable, target: armv7-linux-androideabi }
- { build: arm64, os: ubuntu-latest, rust: stable, target: aarch64-linux-android }
- { build: mips32, os: ubuntu-latest, rust: stable, target: mips-unknown-linux-gnu }
- { build: mips64, os: ubuntu-latest, rust: stable, target: mips64-unknown-linux-gnuabi64 }
- { build: riscv, os: ubuntu-latest, rust: stable, target: riscv64gc-unknown-linux-gnu }
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- name: Use Cross
if: matrix.target != ''
run: |
# FIXME: to work around bugs in latest cross release, install master.
# See: https://github.com/rust-embedded/cross/issues/357
cargo install --git https://github.com/rust-embedded/cross
echo "::set-env name=CARGO::cross"
echo "::set-env name=TARGET::--target ${{ matrix.target }}"
- name: Show command used for Cargo
run: |
echo "cargo command is: ${{ env.CARGO }}"
echo "target flag is: ${{ env.TARGET }}"
- name: Test --no-default-features
run: ${{ env.CARGO }} test --no-default-features --verbose ${{ env.TARGET }}
- name: Test default features
run: ${{ env.CARGO }} test --verbose ${{ env.TARGET }}
- name: Test features=serde std substr
run: ${{ env.CARGO }} test --verbose --features="serde substr std" ${{ env.TARGET }}
- name: Test --all-features
run: ${{ env.CARGO }} test --all-features --verbose ${{ env.TARGET }}
loom:
name: Loom tests
runs-on: ubuntu-latest
env:
RUSTFLAGS: --cfg loom -Dwarnings
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: hecrj/setup-rust-action@v1
with:
rust-version: stable
- name: Run tests with loom (all features)
run: cargo test --all-features --lib
- name: Run tests with loom (no default features)
run: cargo test --no-default-features --lib
miri:
name: Miri
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: hecrj/setup-rust-action@v1
with:
rust-version: nightly
components: miri
- name: Run tests (all features)
run: cargo miri test --all-features
- name: Run tests (std serde substr)
run: cargo miri test --features="std serde substr"
- name: Run tests
run: cargo miri test
cargo-clippy:
name: Lint
runs-on: ubuntu-latest
env:
RUSTFLAGS: -Dwarnings
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: hecrj/setup-rust-action@v1
with:
rust-version: stable
- name: Run cargo clippy (default features)
run: cargo clippy --workspace --all-targets --verbose
- name: Run cargo clippy (all features)
run: cargo clippy --workspace --all-targets --verbose --all-features
- name: Run cargo clippy (substr w/o u64 index)
run: cargo clippy --workspace --all-targets --verbose --features="serde std substr"
- name: Run cargo clippy (no features)
run: cargo clippy --workspace --all-targets --verbose --no-default-features
fmt:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: hecrj/setup-rust-action@v1
with:
rust-version: stable
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
doc:
name: Doc check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: hecrj/setup-rust-action@v1
with:
rust-version: nightly
- name: Check docs
run: cargo rustdoc --all-features -- -D warnings
asan:
name: Address Sanitizer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rust-src
- name: Test with Address Sanitizer
env:
RUSTFLAGS: -Zsanitizer=address
RUSTDOCFLAGS: -Zsanitizer=address
ASAN_OPTIONS: 'detect_stack_use_after_return=1'
RUST_BACKTRACE: '0'
run: |
cargo -Z build-std test --features="std serde substr" --target=x86_64-unknown-linux-gnu
cargo -Z build-std test --all-features --target=x86_64-unknown-linux-gnu
cargo -Z build-std test --no-default-features --target=x86_64-unknown-linux-gnu
tsan:
name: Thread Sanitizer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rust-src
- name: Test with Thread Sanitizer
env:
RUSTFLAGS: -Zsanitizer=thread
RUSTDOCFLAGS: -Zsanitizer=thread
RUST_BACKTRACE: '0'
run: |
cargo -Z build-std test --features="std serde substr" --target=x86_64-unknown-linux-gnu
cargo -Z build-std test --all-features --target=x86_64-unknown-linux-gnu
cargo -Z build-std test --no-default-features --target=x86_64-unknown-linux-gnu
msan:
name: Memory Sanitizer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rust-src
- name: Test with Memory Sanitizer
env:
RUSTFLAGS: '-Zsanitizer=memory -Zsanitizer-memory-track-origins'
RUSTDOCFLAGS: '-Zsanitizer=memory -Zsanitizer-memory-track-origins'
RUST_BACKTRACE: '0'
run: |
cargo -Z build-std test --features="std serde substr" --target=x86_64-unknown-linux-gnu
cargo -Z build-std test --all-features --target=x86_64-unknown-linux-gnu
cargo -Z build-std test --no-default-features --target=x86_64-unknown-linux-gnu
codecov:
name: Generate code coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Run cargo-tarpaulin
uses: actions-rs/tarpaulin@v0.1
- name: Upload to codecov.io
uses: codecov/codecov-action@v1