Skip to content

Commit

Permalink
Update CI to automatically generate distro matrix
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Flynn <[email protected]>
  • Loading branch information
evan-flynn-apexai authored and flynneva committed Nov 5, 2023
1 parent a6dfa06 commit a34f2aa
Showing 1 changed file with 68 additions and 27 deletions.
95 changes: 68 additions & 27 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,89 @@
name: ROS2 CI
name: Build and Test

on:
workflow_dispatch:
pull_request:
branches:
- 'ros2/*'
- 'ros2'
- '*'

jobs:
test_environment:
get_ros_distros:
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install curl jq
- name: Get active distributions
run: |
wget https://raw.githubusercontent.com/flynneva/active_ros_distros/main/main.py -O active_ros_distros.py
python3 -m pip install rosdistro
python3 active_ros_distros.py --distribution-type ros2
- name: Generate actions matrix
id: set-matrix
run: |
ACTIVE_ROS_DISTROS=()
DOCKER_DISTRO_MATRIX=()
RAW_DOCKER_JSON=$(curl -s "https://hub.docker.com/v2/repositories/rostooling/setup-ros-docker/tags?page_size=1000")
while read distro; do
ACTIVE_ROS_DISTROS+=( $distro )
done < "/tmp/active_ros_distros.txt"
DISTRO_STR="["
MATRIX_STR="["
for distro in ${ACTIVE_ROS_DISTROS[@]}; do
docker_image=$(echo $RAW_DOCKER_JSON |
jq -r --arg DISTRO "$distro" '.results[] | select(.tag_status=="active") | select(.name | contains("ros-base-latest")) | select(.name | contains($DISTRO)) | .name' |
sort -u)
DISTRO_STR+="\"${distro}\", "
MATRIX_STR+="{docker_image:\"${docker_image}\",ros_distro:\"${distro}\"}, "
done
# Remove trailing , at end
DISTRO_STR=${DISTRO_STR%??}
MATRIX_STR=${MATRIX_STR%??}
# Close up brackets
DISTRO_STR+="]"
MATRIX_STR+="]"
echo "DISTRO_STR: ${DISTRO_STR}"
echo "MATRIX_STR: ${MATRIX_STR}"
echo "series=$DISTRO_STR" >> $GITHUB_OUTPUT
echo "matrix=$MATRIX_STR" >> $GITHUB_OUTPUT
outputs:
series: ${{ steps.set-matrix.outputs.series }}
matrix: ${{ steps.set-matrix.outputs.matrix }}

build_and_test:
runs-on: [ubuntu-latest]
needs: get_ros_distros
strategy:
fail-fast: false
matrix:
ros_distribution:
- humble
- iron
- rolling
ros_distro: ${{ fromJson(needs.get_ros_distros.outputs.series) }}
include:
# Humble Hawksbill (May 2022 - 2027
- docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-humble-ros-base-latest
ros_distribution: humble
ros_version: 2
# Iron Irwini (May 2023 - Nov 2024)
- docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-iron-ros-base-latest
ros_distribution: iron
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
${{ fromJson(needs.get_ros_distros.outputs.matrix) }}
container:
image: ${{ matrix.docker_image }}
image: rostooling/setup-ros-docker:${{ matrix.docker_image }}
steps:
- name: setup directories
- name: Setup Directories
run: mkdir -p ros_ws/src
- name: checkout
uses: actions/checkout@v2
with:
path: ros_ws/src
- name: build and test
- name: Build and Test ROS 1
uses: ros-tooling/action-ros-ci@master
if: ${{ contains('["melodic", "noetic"]', matrix.ros_distro) }}
with:
package-name: usb_cam
target-ros1-distro: ${{ matrix.ros_distro }}
vcs-repo-file-url: ""
- name: Build and Test ROS 2
id: build_and_test_step
uses: ros-tooling/action-ros-ci@master
if: ${{ contains('["melodic", "noetic"]', matrix.ros_distro) == false }}
with:
package-name: usb_cam
target-ros2-distro: ${{ matrix.ros_distribution }}
target-ros2-distro: ${{ matrix.ros_distro }}
vcs-repo-file-url: ""
colcon-defaults: |
{
Expand All @@ -57,11 +96,13 @@ jobs:
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/1ddb69bedfd1f04c2f000e95452f7c24a4d6176b/index.yaml
- uses: actions/upload-artifact@v1
with:
name: colcon-logs-${{ matrix.ros_distribution }}
name: colcon-logs-${{ matrix.ros_distro }}
path: ${{ steps.build_and_test_step.outputs.ros-workspace-directory-name }}/log
if: always()
continue-on-error: true
- uses: actions/upload-artifact@v1
with:
name: lcov-logs-${{ matrix.ros_distribution }}
name: lcov-logs-${{ matrix.ros_distro }}
path: ${{ steps.build_and_test_step.outputs.ros-workspace-directory-name }}/lcov
if: always()
if: always()
continue-on-error: true

0 comments on commit a34f2aa

Please sign in to comment.