-
Notifications
You must be signed in to change notification settings - Fork 596
118 lines (112 loc) · 4.29 KB
/
build_test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Build and Test
on:
push:
branches:
- 'ros2'
pull_request:
branches:
- 'ros2/*'
- 'ros2'
workflow_dispatch:
jobs:
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/0.1.0/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=(noetic)
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)
# Handle the case if two docker images were declared for one distro
# e.g. rolling moving from one Ubuntu Jammy to Ubuntu Noble
docker_image_arr=($docker_image)
DISTRO_STR+="\"${distro}\", "
MATRIX_STR+="{docker_image:\"${docker_image_arr[-1]}\",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_distro: ${{ fromJson(needs.get_ros_distros.outputs.series) }}
include:
${{ fromJson(needs.get_ros_distros.outputs.matrix) }}
container:
image: rostooling/setup-ros-docker:${{ matrix.docker_image }}
steps:
- name: Setup Directories
run: mkdir -p ros_ws/src
- name: checkout
uses: actions/checkout@v4
with:
path: ros_ws/src
- name: Build and Test ROS 1
uses: ros-tooling/action-ros-ci@master
if: ${{ contains('["melodic", "noetic"]', matrix.ros_distro) }}
continue-on-error: true
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_distro }}
vcs-repo-file-url: ""
colcon-defaults: |
{
"build": {
"mixin": ["coverage-gcc"]
}
}
# If possible, pin the repository in the workflow to a specific commit to avoid
# changes in colcon-mixin-repository from breaking your tests.
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_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_distro }}
path: ${{ steps.build_and_test_step.outputs.ros-workspace-directory-name }}/lcov
if: always()
continue-on-error: true