|
| 1 | +name: Rust Stable |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + schedule: |
| 9 | + # Run the CI at 02:22 UTC every Tuesday |
| 10 | + # We pick an arbitrary time outside of most of the world's work hours |
| 11 | + # to minimize the likelihood of running alongside a heavy workload. |
| 12 | + - cron: '22 2 * * 2' |
| 13 | + |
| 14 | +env: |
| 15 | + CARGO_TERM_COLOR: always |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + ros_distribution: |
| 22 | + - humble |
| 23 | + - iron |
| 24 | + - rolling |
| 25 | + include: |
| 26 | + # Humble Hawksbill (May 2022 - May 2027) |
| 27 | + - docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-humble-ros-base-latest |
| 28 | + ros_distribution: humble |
| 29 | + ros_version: 2 |
| 30 | + # Iron Irwini (May 2023 - November 2024) |
| 31 | + - docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-iron-ros-base-latest |
| 32 | + ros_distribution: iron |
| 33 | + ros_version: 2 |
| 34 | + # Rolling Ridley (June 2020 - Present) |
| 35 | + - docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-rolling-ros-base-latest |
| 36 | + ros_distribution: rolling |
| 37 | + ros_version: 2 |
| 38 | + runs-on: ubuntu-latest |
| 39 | + continue-on-error: ${{ matrix.ros_distribution == 'rolling' }} |
| 40 | + container: |
| 41 | + image: ${{ matrix.docker_image }} |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - name: Search packages in this repository |
| 46 | + id: list_packages |
| 47 | + run: | |
| 48 | + echo ::set-output name=package_list::$(colcon list --names-only) |
| 49 | +
|
| 50 | + - name: Setup ROS environment |
| 51 | + uses: ros-tooling/[email protected] |
| 52 | + with: |
| 53 | + required-ros-distributions: ${{ matrix.ros_distribution }} |
| 54 | + use-ros2-testing: ${{ matrix.ros_distribution == 'rolling' }} |
| 55 | + |
| 56 | + - name: Setup Rust |
| 57 | + uses: dtolnay/rust-toolchain@stable |
| 58 | + with: |
| 59 | + components: clippy, rustfmt |
| 60 | + |
| 61 | + - name: Install colcon-cargo and colcon-ros-cargo |
| 62 | + run: | |
| 63 | + sudo pip3 install git+https://github.com/colcon/colcon-cargo.git |
| 64 | + sudo pip3 install git+https://github.com/colcon/colcon-ros-cargo.git |
| 65 | +
|
| 66 | + - name: Check formatting of Rust packages |
| 67 | + run: | |
| 68 | + for path in $(colcon list | awk '$3 == "(ament_cargo)" { print $2 }'); do |
| 69 | + cd $path |
| 70 | + rustup toolchain install nightly |
| 71 | + cargo +nightly fmt -- --check |
| 72 | + cd - |
| 73 | + done |
| 74 | +
|
| 75 | + - name: Install cargo-ament-build |
| 76 | + run: | |
| 77 | + cargo install --debug cargo-ament-build |
| 78 | +
|
| 79 | + - name: Build and test |
| 80 | + id: build |
| 81 | + uses: ros-tooling/[email protected] |
| 82 | + with: |
| 83 | + package-name: ${{ steps.list_packages.outputs.package_list }} |
| 84 | + target-ros2-distro: ${{ matrix.ros_distribution }} |
| 85 | + vcs-repo-file-url: ros2_rust_${{ matrix.ros_distribution }}.repos |
| 86 | + |
| 87 | + - name: Run clippy on Rust packages |
| 88 | + run: | |
| 89 | + cd ${{ steps.build.outputs.ros-workspace-directory-name }} |
| 90 | + . /opt/ros/${{ matrix.ros_distribution }}/setup.sh |
| 91 | + for path in $(colcon list | awk '$3 == "(ament_cargo)" { print $2 }'); do |
| 92 | + cd $path |
| 93 | + echo "Running clippy in $path" |
| 94 | + # Run clippy for all features except generate_docs (needed for docs.rs) |
| 95 | + if [ "$(basename $path)" = "rclrs" ]; then |
| 96 | + cargo clippy --all-targets -F default,dyn_msg -- -D warnings |
| 97 | + else |
| 98 | + cargo clippy --all-targets --all-features -- -D warnings |
| 99 | + fi |
| 100 | + cd - |
| 101 | + done |
| 102 | +
|
| 103 | + - name: Run cargo test on Rust packages |
| 104 | + run: | |
| 105 | + cd ${{ steps.build.outputs.ros-workspace-directory-name }} |
| 106 | + . install/setup.sh |
| 107 | + for path in $(colcon list | awk '$3 == "(ament_cargo)" && $1 != "examples_rclrs_minimal_pub_sub" && $1 != "examples_rclrs_minimal_client_service" && $1 != "rust_pubsub" { print $2 }'); do |
| 108 | + cd $path |
| 109 | + echo "Running cargo test in $path" |
| 110 | + # Run cargo test for all features except generate_docs (needed for docs.rs) |
| 111 | + if [ "$(basename $path)" = "rclrs" ]; then |
| 112 | + cargo test -F default,dyn_msg |
| 113 | + elif [ "$(basename $path)" = "rosidl_runtime_rs" ]; then |
| 114 | + cargo test -F default |
| 115 | + else |
| 116 | + cargo test --all-features |
| 117 | + fi |
| 118 | + cd - |
| 119 | + done |
| 120 | +
|
| 121 | + - name: Rustdoc check |
| 122 | + run: | |
| 123 | + cd ${{ steps.build.outputs.ros-workspace-directory-name }} |
| 124 | + . /opt/ros/${{ matrix.ros_distribution }}/setup.sh |
| 125 | + for path in $(colcon list | awk '$3 == "(ament_cargo)" && $1 != "examples_rclrs_minimal_pub_sub" && $1 != "examples_rclrs_minimal_client_service" && $1 != "rust_pubsub" { print $2 }'); do |
| 126 | + cd $path |
| 127 | + echo "Running rustdoc check in $path" |
| 128 | + cargo rustdoc -- -D warnings |
| 129 | + cd - |
| 130 | + done |
0 commit comments