rust-workflow.sh update cargo test command #97
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
# rust.yml | |
# | |
# github workflows action file for si_trace_print | |
--- | |
name: Rust | |
on: | |
push: | |
pull_request: | |
env: | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: 1 | |
jobs: | |
# MSRV check | |
job_msrv: | |
name: build on ${{ matrix.msrv }} on ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
# first `msrv` value should match Cargo.toml:[package]:rust-version | |
msrv: [1.56.0, 1.58.1, 1.60.0, 1.62.1, 1.64.0, 1.66.1, 1.68.2, 1.70.0] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: moonrepo/setup-rust@v1 | |
with: | |
channel: ${{ matrix.msrv }} | |
- name: Build using rust ${{ matrix.msrv }} on ${{ matrix.os }} | |
shell: bash | |
run: | | |
set -eux | |
cargo --version | |
rustc --print cfg | |
cargo build --lib --verbose --locked | |
- name: Test using rust ${{ matrix.msrv }} on ${{ matrix.os }} | |
shell: bash | |
run: | | |
set -eux | |
cargo --version | |
cargo test --lib --locked | |
# do all the basic rust stuff | |
job_fmt_clippy_build_buildrelease_test_doc: | |
name: fmt clippy build test doc | |
needs: [job_msrv] | |
runs-on: ubuntu-latest | |
steps: | |
- name: git checkout | |
uses: actions/checkout@v3 | |
- name: Check rustfmt | |
shell: bash | |
run: | | |
cargo --version | |
cargo fmt --version | |
cargo fmt --verbose --check | |
- name: Check clippy | |
shell: bash | |
run: | | |
cargo --version | |
cargo clippy --version | |
cargo clippy --no-deps --verbose --all-targets --all-features -- \ | |
-D warnings | |
- name: Build Debug and Release | |
run: | | |
set -eux | |
cargo --version | |
cargo build --verbose | |
cargo build --verbose --release | |
- name: Run All Tests Single-threaded | |
run: | | |
set -eux | |
cargo --version | |
cargo test -j1 --verbose \ | |
--all-features \ | |
--future-incompat-report \ | |
-- \ | |
--test-threads=1 | |
- name: Run Lib Tests Multi-threaded | |
run: | | |
set -eux | |
cargo --version | |
cargo test -j2 --lib --verbose -- --test-threads=2 | |
cargo test -j4 --lib --verbose -- --test-threads=4 | |
cargo test -j8 --lib --verbose -- --test-threads=8 | |
cargo test -j8 --lib --verbose -- --test-threads=16 | |
- name: Build Documentation | |
run: cargo doc --locked --release --frozen --no-deps -v | |
job_yamllint: | |
# this job install Python PIP packages | |
name: yamllint | |
needs: [job_msrv] | |
runs-on: ubuntu-latest | |
steps: | |
- name: git checkout | |
uses: actions/checkout@v3 | |
- name: Use Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
run: | | |
set -eux | |
python --version | |
python -m pip \ | |
--disable-pip-version-check \ | |
--no-python-version-warning \ | |
--version | |
python -m pip install \ | |
--disable-pip-version-check \ | |
--no-python-version-warning \ | |
--no-color \ | |
yamllint | |
python -m pip list \ | |
--disable-pip-version-check \ | |
--no-python-version-warning \ | |
-v -v | |
- name: Run yamllint.sh | |
run: | | |
# XXX: ignore yamllint.sh errors, see Issue #120 | |
PYTHON=python3 ./tools/yamllint.sh || true | |
# run code coverage with rust "stable" then upload to codecov.io | |
# help from | |
# - https://github.com/marketplace/actions/rust-grcov | |
# - https://eipi.xyz/blog/rust-code-coverage-with-github-workflows/ | |
# - https://github.com/mozilla/grcov/blob/v0.8.18/README.md#example-how-to-generate-gcda-files-for-a-rust-project | |
# - https://github.com/mozilla/grcov/blob/v0.8.18/README.md#lcov-output | |
job_grcov: | |
name: grcov | |
runs-on: ubuntu-latest | |
needs: [job_msrv, job_fmt_clippy_build_buildrelease_test_doc] | |
steps: | |
- name: git checkout | |
uses: actions/checkout@v3 | |
- name: get toolchain stable | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
- name: cargo install | |
uses: actions-rs/cargo@v1 | |
with: | |
command: install | |
args: --verbose -- rustfilt grcov | |
- name: cargo build with special profiling | |
uses: actions-rs/cargo@v1 | |
env: | |
CARGO_INCREMENTAL: 0 | |
RUSTC_BOOTSTRAP: 1 | |
RUSTDOCFLAGS: -Cpanic=abort | |
RUSTFLAGS: -Zprofile | |
-Ccodegen-units=1 | |
-Copt-level=0 | |
-Clink-dead-code | |
-Coverflow-checks=off | |
-Zpanic_abort_tests | |
-Cpanic=abort | |
with: | |
command: build | |
args: --verbose | |
- name: cargo test with special profiling | |
uses: actions-rs/cargo@v1 | |
env: | |
CARGO_INCREMENTAL: 0 | |
RUSTC_BOOTSTRAP: 1 | |
RUSTDOCFLAGS: -Cpanic=abort | |
RUSTFLAGS: -Zprofile | |
-Ccodegen-units=1 | |
-Copt-level=0 | |
-Clink-dead-code | |
-Coverflow-checks=off | |
-Zpanic_abort_tests | |
-Cpanic=abort | |
with: | |
command: test | |
args: --lib --no-fail-fast | |
- name: grcov | |
env: | |
CARGO_INCREMENTAL: 0 | |
RUSTC_BOOTSTRAP: 1 | |
RUSTDOCFLAGS: -Cpanic=abort | |
RUSTFLAGS: -Zprofile | |
-Ccodegen-units=1 | |
-Copt-level=0 | |
-Clink-dead-code | |
-Coverflow-checks=off | |
-Zpanic_abort_tests | |
-Cpanic=abort | |
run: | | |
set -eux | |
grcov --version | |
grcov \ | |
. \ | |
--source-dir ./src \ | |
--log-level DEBUG \ | |
--llvm \ | |
--binary-path ./target/debug/ \ | |
--branch \ | |
--ignore-not-existing \ | |
--output-type lcov \ | |
--output-path lcov.info | |
ls -l | |
head lcov.info | |
# action from https://github.com/codecov/codecov-action | |
- name: upload codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
files: lcov.info | |
verbose: true | |
fail_ci_if_error: true | |
# public repository does not need secret section `with: token` | |
# see | |
# https://about.codecov.io/blog/javascript-code-coverage-using-github-actions-and-codecov/ | |
# | |
# list of acceptable formats | |
# https://docs.codecov.com/docs/supported-report-formats |