2021-10-06 01:12:36 +05:30
|
|
|
name: Test Rust project
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_call:
|
2022-02-15 10:07:00 +05:30
|
|
|
inputs:
|
|
|
|
apt_packages:
|
|
|
|
required: false
|
|
|
|
type: string
|
2022-05-11 20:49:56 +05:30
|
|
|
msrv:
|
|
|
|
required: false
|
|
|
|
type: string
|
|
|
|
default: "1.57.0"
|
2021-10-06 01:12:36 +05:30
|
|
|
secrets:
|
|
|
|
github-token:
|
|
|
|
required: false
|
|
|
|
|
2022-01-03 09:58:08 +05:30
|
|
|
env:
|
|
|
|
RUSTFLAGS: '-Dwarnings'
|
2022-05-08 23:48:27 +05:30
|
|
|
# disable incremental compilation.
|
|
|
|
#
|
|
|
|
# incremental compilation is useful as part of an edit-build-test-edit cycle,
|
|
|
|
# as it lets the compiler avoid recompiling code that hasn't changed. however,
|
|
|
|
# on CI, we're not making small edits; we're almost always building the entire
|
|
|
|
# project from scratch. thus, incremental compilation on CI actually
|
|
|
|
# introduces *additional* overhead to support making future builds
|
|
|
|
# faster...but no future builds will ever occur in any given CI environment.
|
|
|
|
#
|
|
|
|
# see https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
|
|
|
|
# for details.
|
|
|
|
CARGO_INCREMENTAL: 0
|
|
|
|
# allow more retries for network requests in cargo (downloading crates) and
|
|
|
|
# rustup (installing toolchains). this should help to reduce flaky CI failures
|
|
|
|
# from transient network timeouts or other issues.
|
|
|
|
CARGO_NET_RETRY: 10
|
|
|
|
RUSTUP_MAX_RETRIES: 10
|
|
|
|
# don't emit giant backtraces in the CI logs.
|
|
|
|
RUST_BACKTRACE: short
|
2022-01-03 09:58:08 +05:30
|
|
|
|
2021-10-06 01:12:36 +05:30
|
|
|
jobs:
|
2022-05-11 20:49:56 +05:30
|
|
|
check-msrv:
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
fail-fast: true
|
|
|
|
matrix:
|
|
|
|
os:
|
|
|
|
- macos-11
|
|
|
|
- ubuntu-20.04
|
|
|
|
- windows-2022
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2022-07-25 15:51:33 +05:30
|
|
|
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag = v3
|
2022-05-11 20:49:56 +05:30
|
|
|
|
2022-07-25 15:51:33 +05:30
|
|
|
- name: Install Rust
|
2022-07-25 23:53:55 +05:30
|
|
|
uses: dtolnay/rust-toolchain@1ce4a7352a1efe5dede2e52c75512b34256e4f44 # tag=v1
|
2022-07-25 15:51:33 +05:30
|
|
|
with:
|
|
|
|
toolchain: ${{ inputs.msrv }}
|
2022-05-11 20:49:56 +05:30
|
|
|
|
2022-05-23 17:35:45 +05:30
|
|
|
- uses: Swatinem/rust-cache@v1
|
2022-06-27 21:31:35 +05:30
|
|
|
with:
|
|
|
|
key: cargo-cache-${{ hashFiles('Cargo.lock', 'Cargo.toml') }}-${{ matrix.os }}
|
2022-05-11 20:49:56 +05:30
|
|
|
|
|
|
|
- name: Test compilation
|
2022-07-25 15:51:33 +05:30
|
|
|
run: cargo check
|
2022-05-11 20:49:56 +05:30
|
|
|
|
2021-10-06 01:12:36 +05:30
|
|
|
test:
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
os:
|
|
|
|
- macos-11
|
2022-01-08 19:16:12 +05:30
|
|
|
- ubuntu-20.04
|
|
|
|
- windows-2022
|
2021-10-06 01:12:36 +05:30
|
|
|
rust:
|
|
|
|
- beta
|
|
|
|
- nightly
|
|
|
|
- stable
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2022-07-25 23:53:55 +05:30
|
|
|
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
|
2021-10-06 01:12:36 +05:30
|
|
|
|
2022-08-05 11:26:11 +05:30
|
|
|
- uses: rui314/setup-mold@6dde38252affb567c951f891790da82dc6f23e6b # tag=v1
|
2022-05-06 08:57:03 +05:30
|
|
|
if: runner.os == 'Linux'
|
|
|
|
with:
|
|
|
|
make-default: true
|
|
|
|
|
2022-07-25 15:51:33 +05:30
|
|
|
- name: Install Rust
|
2022-07-25 23:53:55 +05:30
|
|
|
uses: dtolnay/rust-toolchain@1ce4a7352a1efe5dede2e52c75512b34256e4f44 # tag=v1
|
2022-07-25 15:51:33 +05:30
|
|
|
with:
|
|
|
|
toolchain: ${{ matrix.rust }}
|
2022-08-10 15:56:36 +05:30
|
|
|
components: clippy, rustfmt
|
2021-10-25 14:12:03 +05:30
|
|
|
|
2022-07-25 15:51:33 +05:30
|
|
|
- name: Install cargo-nextest
|
|
|
|
uses: baptiste0928/cargo-install@bf6758885262d0e6f61089a9d8c8790d3ac3368f # tag=v1
|
|
|
|
with:
|
|
|
|
crate: cargo-nextest
|
2021-10-06 01:12:36 +05:30
|
|
|
|
2022-07-25 15:51:33 +05:30
|
|
|
- name: Install cargo-deny
|
|
|
|
uses: baptiste0928/cargo-install@bf6758885262d0e6f61089a9d8c8790d3ac3368f # tag=v1
|
2022-06-27 21:31:35 +05:30
|
|
|
with:
|
2022-07-25 15:51:33 +05:30
|
|
|
crate: cargo-deny
|
2021-10-06 01:12:36 +05:30
|
|
|
|
2022-07-25 15:51:33 +05:30
|
|
|
- uses: Swatinem/rust-cache@v1
|
2021-10-06 01:12:36 +05:30
|
|
|
with:
|
2022-07-25 15:51:33 +05:30
|
|
|
key: cargo-cache-${{ hashFiles('Cargo.lock', 'Cargo.toml') }}-${{ matrix.os }}-${{ matrix.rust }}
|
2021-10-06 01:12:36 +05:30
|
|
|
|
2022-02-15 10:07:00 +05:30
|
|
|
- name: Install required packages (Linux)
|
|
|
|
if: ${{ inputs.apt_packages != '' && runner.os == 'Linux' }}
|
|
|
|
shell: bash
|
|
|
|
env:
|
|
|
|
PACKAGES: ${{ inputs.apt_packages }}
|
|
|
|
run: |
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install -y ${PACKAGES}
|
|
|
|
|
2022-07-25 15:51:33 +05:30
|
|
|
- name: Check formatting
|
|
|
|
shell: bash
|
|
|
|
run: cargo fmt -- --check
|
2022-02-15 00:52:14 +05:30
|
|
|
|
2022-07-25 15:51:33 +05:30
|
|
|
- name: Run cargo-deny
|
2021-11-06 21:36:05 +05:30
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
if [ -f deny.toml ]; then
|
|
|
|
cargo deny check
|
|
|
|
fi
|
2022-05-09 00:08:30 +05:30
|
|
|
- name: Clippy
|
2022-07-25 15:51:33 +05:30
|
|
|
shell: bash
|
|
|
|
run: cargo clippy -- -Wclippy::pedantic
|
2022-05-09 00:08:30 +05:30
|
|
|
|
|
|
|
- name: Run tests
|
2022-07-25 15:51:33 +05:30
|
|
|
shell: bash
|
|
|
|
run: cargo nextest run --all-features
|