Skip to content

CI: Build Python package with uv #105

CI: Build Python package with uv

CI: Build Python package with uv #105

Workflow file for this run

name: Rust
on:
push:
branches:
- main
paths-ignore:
- "docs/**"
pull_request:
release:
types: [published]
workflow_dispatch:
concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true
env:
MSRV: "1.82"
ROS_DISTRO: "jazzy"
CARGO_TERM_COLOR: always
CRATE_NAME_SYS: srb_sys
CRATE_NAME_LIB: srb
CRATE_NAME_PY: srb_py
CRATE_NAME_GUI: srb_gui
jobs:
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
## cargo fmt
- name: cargo fmt
run: cargo fmt --all --check --verbose
cargo:
needs: rustfmt
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain:
- MSRV
- stable
- beta
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name == 'push'}}
- uses: dtolnay/rust-toolchain@master
if: ${{ matrix.toolchain != 'MSRV' && matrix.toolchain != 'stable' }}
with:
toolchain: ${{ matrix.toolchain }}
- uses: dtolnay/rust-toolchain@master
if: ${{ matrix.toolchain == 'MSRV' }}
with:
toolchain: ${{ env.MSRV }}
- uses: dtolnay/rust-toolchain@master
if: ${{ matrix.toolchain == 'stable' }}
with:
toolchain: ${{ matrix.toolchain }}
components: clippy
- uses: ros-tooling/setup-ros@v0.7
with:
required-ros-distributions: ${{ env.ROS_DISTRO }}
## cargo check
- name: cargo check
run: source /opt/ros/${{ env.ROS_DISTRO }}/setup.bash && cargo check --workspace --all-targets --verbose
- name: cargo check --no-default-features
run: source /opt/ros/${{ env.ROS_DISTRO }}/setup.bash && cargo check --workspace --all-targets --no-default-features --verbose
- name: cargo check --all-features
run: source /opt/ros/${{ env.ROS_DISTRO }}/setup.bash && cargo check --workspace --all-targets --all-features --verbose
## cargo test
- name: cargo test
run: source /opt/ros/${{ env.ROS_DISTRO }}/setup.bash && cargo test --workspace --all-targets --verbose
- name: cargo test --no-default-features
run: source /opt/ros/${{ env.ROS_DISTRO }}/setup.bash && cargo test --workspace --all-targets --no-default-features --verbose
- name: cargo test --all-features
run: source /opt/ros/${{ env.ROS_DISTRO }}/setup.bash && cargo test --workspace --all-targets --all-features --verbose
## cargo test --doc
- name: cargo test --doc
run: source /opt/ros/${{ env.ROS_DISTRO }}/setup.bash && cargo test --workspace --doc --verbose
- name: cargo test --doc --no-default-features
run: source /opt/ros/${{ env.ROS_DISTRO }}/setup.bash && cargo test --workspace --doc --no-default-features --verbose
- name: cargo test --doc --all-features
run: source /opt/ros/${{ env.ROS_DISTRO }}/setup.bash && cargo test --workspace --doc --all-features --verbose
## [stable] cargo clippy
- name: stable | cargo clippy
if: ${{ matrix.toolchain == 'stable' }}
run: source /opt/ros/${{ env.ROS_DISTRO }}/setup.bash && cargo clippy --workspace --all-targets --all-features --no-deps --verbose -- --deny warnings
## [stable] cargo doc
- name: stable | cargo doc --document-private-items
if: ${{ matrix.toolchain == 'stable' }}
run: source /opt/ros/${{ env.ROS_DISTRO }}/setup.bash && cargo doc --workspace --all-features --no-deps --document-private-items --verbose
# Note: There are currently no tests in the workspace
# ## [stable] Code coverage
# - name: stable | Install cargo llvm-cov for code coverage
# uses: taiki-e/install-action@cargo-llvm-cov
# if: ${{ matrix.toolchain == 'stable' }}
# ## [stable] Generate coverage with cargo llvm-cov
# - name: stable | Generate coverage
# if: ${{ matrix.toolchain == 'stable' }}
# run: source /opt/ros/${{ env.ROS_DISTRO }}/setup.bash && cargo llvm-cov --workspace --exclude ${{ env.CRATE_NAME_GUI }} --all-features --lcov --output-path lcov.info
# ## [stable] Upload coverage to codecov.io
# - name: stable | Upload coverage
# if: ${{ matrix.toolchain == 'stable' }}
# uses: codecov/codecov-action@v5
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# files: lcov.info
# fail_ci_if_error: false
deny:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v2
with:
command: check bans licenses sources
publish:
if: ${{ github.event_name == 'release' }}
needs:
- cargo
- deny
runs-on: ubuntu-latest
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
## Publish to crates.io
- name: Publish crate (sys)
if: ${{ env.CARGO_REGISTRY_TOKEN != '' }}
run: cargo publish --no-verify --package ${{ env.CRATE_NAME_SYS }} --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Publish crate (lib)
if: ${{ env.CARGO_REGISTRY_TOKEN != '' }}
run: cargo publish --no-verify --package ${{ env.CRATE_NAME_LIB }} --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Publish crate (py)
if: ${{ env.CARGO_REGISTRY_TOKEN != '' }}
run: cargo publish --no-verify --package ${{ env.CRATE_NAME_PY }} --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Publish crate (gui)
if: ${{ env.CARGO_REGISTRY_TOKEN != '' }}
run: cargo publish --no-verify --package ${{ env.CRATE_NAME_GUI }} --token ${{ secrets.CARGO_REGISTRY_TOKEN }}