Skip to content

CI

CI #1581

Workflow file for this run

# the "if" flag with event.json is for running the workflow locally with `act`.
name: CI
on:
push:
pull_request:
branches:
- ros2
- master
schedule: # Trigger a job on master at midnight UTC every day
- cron: '0 0 * * *'
env:
PACKAGES_TO_TEST: # This limits the packages that are checked in CI. This is to avoid testing upstream packages passed in via .repos files.
uwrt_mars_rover
uwrt_mars_rover_drivetrain
uwrt_mars_rover_drivetrain_description
uwrt_mars_rover_drivetrain_hw
ROS_DISTRO: galactic
IMAGE: "rostooling/setup-ros-docker:ubuntu-focal-ros-galactic-desktop-latest"
jobs:
prepare-actions-environment:
if: ${{ !github.event.act }}
# workaround to use variable for IMAGE. Based off of: https://github.community/t/how-to-use-env-with-container-image/17252/25
runs-on: ubuntu-latest
outputs:
image: ${{ steps.export_variable.outputs.image }}
steps:
- id: export_variable
run: echo "::set-output name=image::${{ env.IMAGE }}"
linters:
if: ${{ !github.event.act }}
name: ament-${{ matrix.linter }}
needs: prepare-actions-environment
runs-on: ubuntu-latest
container:
image: ${{ needs.prepare-actions-environment.outputs.image }}
options: -u root
strategy:
fail-fast: false # We want all the linters to run even if one fails
matrix:
linter: [ cppcheck, xmllint ]
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: ROS2 Linter - [ament-${{ matrix.linter }}]
uses: ros-tooling/action-ros-lint@master
with:
distribution: ${{ env.ROS_DISTRO }}
linter: ${{ matrix.linter }}
package-name: ${{ env.PACKAGES_TO_TEST }}
linters-clang-format:
if: ${{ !github.event.act }}
name: ament-clang-format
needs: prepare-actions-environment
runs-on: ubuntu-latest
container:
image: ${{ needs.prepare-actions-environment.outputs.image }}
options: -u root
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: ROS2 Linter - [ament-clang-format]
uses: ros-tooling/action-ros-lint@master
with:
distribution: ${{ env.ROS_DISTRO }}
linter: clang-format
arguments: "--config .clang-format"
package-name: ${{ env.PACKAGES_TO_TEST }}
linters-flake8:
if: ${{ !github.event.act }}
name: ament-flake8
needs: prepare-actions-environment
runs-on: ubuntu-latest
container:
image: ${{ needs.prepare-actions-environment.outputs.image }}
options: -u root
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: ROS2 Linter - [ament-flake8]
uses: ros-tooling/action-ros-lint@master
with:
distribution: ${{ env.ROS_DISTRO }}
linter: flake8
arguments: "--config .flake8"
package-name: ${{ env.PACKAGES_TO_TEST }}
linux-amd64-build-and-test:
needs: prepare-actions-environment
runs-on: ubuntu-latest
container:
image: ${{ needs.prepare-actions-environment.outputs.image }}
steps:
- name: Build ROS2 Packages and Run Tests
uses: ros-tooling/[email protected]
with:
colcon-defaults: |
{
"build": {
"mixin": ["asan-gcc"]
}
}
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/3e627e0fa30db85aea05a50e2c61a9832664d236/index.yaml
target-ros2-distro: ${{ env.ROS_DISTRO }}
vcs-repo-file-url: |
https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/common_upstream_dependencies.repos
package-name: ${{ env.PACKAGES_TO_TEST }}
linux-arm64-build-and-test:
runs-on: ubuntu-latest
# Cannot use action-ros-ci since cant trigger action steps from within the docker container. Must use `docker exec`
# to run actions within docker container since we cannot directly use arm64v8/ros:${{ env.ROS_DISTRO }} container because there
# exists no way of setting up Docker to work with Qemu before loading a docker image onto the Github Action runner.
# Possibly resolveable with https://github.com/actions/runner/issues/320
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install Docker/QEMU dependencies
id: qemu
uses: docker/setup-qemu-action@v2
with:
image: tonistiigi/binfmt:latest
platforms: arm64
- name: Setup Docker to Run ARM64 Containers in QEMU
run: |
docker run --privileged --rm multiarch/qemu-user-static --reset --credential yes --persistent yes
- name: Start ARM64 ROS2 Container
run: |
docker run --name arm64-ros --mount type=bind,source=$(pwd),target=/rosws/src/$(basename $(pwd)) --workdir /rosws --detach -i --rm arm64v8/ros:${{ env.ROS_DISTRO }}
- name: Download ROS Source Dependencies
run: |
docker exec --workdir /rosws/src arm64-ros vcs import --input uwrt_mars_rover/common_upstream_dependencies.repos
# TODO: add linux_arm64_upstream_dependencies.repos
- name: Install ROS Binary Package Dependencies
run: |
docker exec arm64-ros sudo apt update
docker exec arm64-ros rosdep install -r --from-paths . --ignore-src --rosdistro ${{ env.ROS_DISTRO }} -y
- name: Build ROS2 Packages and Run Tests
run: >
docker exec arm64-ros bash -c "source /opt/ros/${{ env.ROS_DISTRO }}/setup.bash &&
colcon build --event-handlers console_cohesion+ &&
colcon test --packages-select ${{ env.PACKAGES_TO_TEST }} --return-code-on-test-failure --event-handlers console_cohesion+"