This action runs quality checks and tests on your cargo crate. It runs the following:
- format check using
cargo fmt
- linting using
cargo clippy
- tests using
cargo test
, orcargo llvm-cov test
if coverage is enabled.
Note that the build-cache generated in previous runs of this action becomes
invalid if any input parameter is changed. In such cases, please delete the old
build cache [OS]-cargo-build-test-[hash]
manually. It will be regenerated in
the next run.
Whether to enable generating a test coverage report or not. If yes, uses
cargo-llvm-cov
for generating the report.
Default: true
Whether to enable caching the build artifacts or not. If yes, caches the build
using a hash generated from the Cargo.lock
file if it exists, otherwise uses
the Cargo.toml
file.
Rust libraries may choose to set this to false
if they are not using any
dependencies that take a long time to build. This ensures the latest versions of
the dependencies being fetched on each run.
Default: true
Additional parameters to pass to the cargo clippy
call.
Default: "-W clippy::unwrap_used -W clippy::expect_used -W clippy::panic"
Parameters to pass to the cargo test
command.
Default: ""
jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: Fetch sources
uses: actions/checkout@v4
with:
submodules: recursive
- name: Run tests
uses: frequenz-floss/gh-action-cargo-test@v1.0.0
This project is licensed under the MIT License - see the LICENSE file for details.