Bdds #139
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
name: build | |
# This should ensure that the workflow won't run on `dev-*` branches, but will | |
# otherwise execute on any other branch and any pull request (including PRs | |
# from dev branches). | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- '*' | |
env: | |
# A fixed version used for testing, so that the builds don't | |
# spontaneously break after a few years. | |
# Make sure to update this from time to time. | |
RUST_VERSION: "1.77.0" | |
PYTHON_VERSION: "3.12" | |
jobs: | |
# Checks syntax formatting. | |
fmt: | |
name: Rustfmt | |
runs-on: ubuntu-latest | |
env: | |
RUSTFLAGS: "-D warnings" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ env.RUST_VERSION }} | |
components: rustfmt | |
- run: cargo fmt --all -- --check | |
# Run basic code validity check. | |
check: | |
needs: fmt | |
name: Check | |
runs-on: ubuntu-latest | |
env: | |
RUSTFLAGS: "-D warnings" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ env.RUST_VERSION }} | |
- run: cargo check --all-features | |
# Run tests. | |
test: | |
needs: check | |
name: Test Suite (linux) | |
runs-on: ubuntu-latest | |
env: | |
RUSTFLAGS: "-D warnings" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ env.RUST_VERSION }} | |
components: rustfmt | |
- run: cargo test --all-features | |
# Checks code style. | |
clippy: | |
needs: check | |
name: Clippy | |
runs-on: ubuntu-latest | |
env: | |
RUSTFLAGS: "-D warnings" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ env.RUST_VERSION }} | |
components: clippy | |
- run: cargo clippy --all-features | |
# Compute code coverage | |
codecov: | |
needs: test | |
name: Rust code coverage | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ env.RUST_VERSION }} | |
# Install action using cargo-binstall, which is faster because we don't have to compile tarpaulin every time. | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-tarpaulin | |
# In PyO3 projects, `--no-dead-code` and `--engine llvm` are preferred. Might be a bug, might | |
# just be some weirdness in low-level build toolchains. See the discussion at: | |
# https://github.com/xd009642/tarpaulin/issues/1092 | |
- run: cargo tarpaulin --no-dead-code --engine llvm --verbose --lib --examples --all-features --out xml | |
- name: Upload to codecov.io | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: true | |
- name: Archive code coverage results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: code-coverage-report | |
path: cobertura.xml | |
# Build the python package (the Python part is untested for now). | |
maturin: | |
needs: check | |
name: Maturin build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ env.RUST_VERSION }} | |
- name: Setup Python. | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
architecture: x64 | |
- name: Run tests. | |
run: | | |
python3 -m venv venv | |
source ./venv/bin/activate | |
./venv/bin/pip3 install -r ./scripts/dev_requirements.txt | |
maturin develop |