Rust #961
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: Rust | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
schedule: | |
- cron: '0 0 * * *' | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build: | |
strategy: | |
matrix: | |
ros_distribution: | |
- foxy | |
- humble | |
- rolling | |
include: | |
# Foxy Fitzroy (June 2020 - May 2023) | |
- docker_image: rostooling/setup-ros-docker:ubuntu-focal-ros-foxy-ros-base-latest | |
ros_distribution: foxy | |
ros_version: 2 | |
# Humble Hawksbill (May 2022 - May 2027) | |
- docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-humble-ros-base-latest | |
ros_distribution: humble | |
ros_version: 2 | |
# Rolling Ridley (June 2020 - Present) | |
- docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-rolling-ros-base-latest | |
ros_distribution: rolling | |
ros_version: 2 | |
runs-on: ubuntu-latest | |
continue-on-error: ${{ matrix.ros_distribution == 'rolling' }} | |
container: | |
image: ${{ matrix.docker_image }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Search packages in this repository | |
id: list_packages | |
run: | | |
echo ::set-output name=package_list::$(colcon list --names-only) | |
- name: Setup ROS environment | |
uses: ros-tooling/setup-ros@v0.6 | |
with: | |
required-ros-distributions: ${{ matrix.ros_distribution }} | |
use-ros2-testing: ${{ matrix.ros_distribution == 'rolling' }} | |
- name: Downgrade pydocstyle as a workaround for https://github.com/ament/ament_lint/issues/434 | |
run: | | |
sudo pip install pydocstyle==6.1.1 | |
- name: Setup Rust | |
uses: dtolnay/rust-toolchain@1.63.0 | |
with: | |
components: clippy, rustfmt | |
- name: Install colcon-cargo and colcon-ros-cargo | |
run: | | |
sudo pip3 install git+https://github.com/colcon/colcon-cargo.git | |
sudo pip3 install git+https://github.com/colcon/colcon-ros-cargo.git | |
- name: Check formatting of Rust packages | |
run: | | |
for path in $(colcon list | awk '$3 == "(ament_cargo)" { print $2 }'); do | |
cd $path | |
cargo fmt -- --check | |
cd - | |
done | |
- name: Install cargo-ament-build | |
run: | | |
cargo install --debug cargo-ament-build | |
- name: Build and test | |
id: build | |
uses: ros-tooling/action-ros-ci@v0.2 | |
with: | |
package-name: ${{ steps.list_packages.outputs.package_list }} | |
target-ros2-distro: ${{ matrix.ros_distribution }} | |
vcs-repo-file-url: ros2_rust_${{ matrix.ros_distribution }}.repos | |
- name: Run clippy on Rust packages | |
run: | | |
cd ${{ steps.build.outputs.ros-workspace-directory-name }} | |
. /opt/ros/${{ matrix.ros_distribution }}/setup.sh | |
for path in $(colcon list | awk '$3 == "(ament_cargo)" { print $2 }'); do | |
cd $path | |
echo "Running clippy in $path" | |
cargo clippy --all-targets --all-features -- -D warnings | |
cd - | |
done | |
- name: Run cargo test on Rust packages | |
run: | | |
cd ${{ steps.build.outputs.ros-workspace-directory-name }} | |
. install/setup.sh | |
for path in $(colcon list | awk '$3 == "(ament_cargo)" && $1 != "examples_rclrs_minimal_pub_sub" && $1 != "examples_rclrs_minimal_client_service" { print $2 }'); do | |
cd $path | |
echo "Running cargo test in $path" | |
cargo test --all-features | |
cd - | |
done | |
- name: Rustdoc check | |
run: | | |
cd ${{ steps.build.outputs.ros-workspace-directory-name }} | |
. /opt/ros/${{ matrix.ros_distribution }}/setup.sh | |
for path in $(colcon list | awk '$3 == "(ament_cargo)" && $1 != "examples_rclrs_minimal_pub_sub" && $1 != "examples_rclrs_minimal_client_service" { print $2 }'); do | |
cd $path | |
echo "Running rustdoc check in $path" | |
cargo rustdoc -- -D warnings | |
cd - | |
done |