-
Notifications
You must be signed in to change notification settings - Fork 609
130 lines (123 loc) · 4.8 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
119
120
121
122
123
124
125
126
127
128
129
130
name: Build and Test
on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main/*'
- 'main'
workflow_dispatch:
env:
ROS_WORKSPACE_PATH: workspace/src
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=()
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: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install policykit-1 libgtk2.0-common screen uml-utilities libc6-dev libicu-dev gcc python3 python3-pip
mkdir renode_portable
wget https://builds.renode.io/renode-latest.linux-portable.tar.gz
tar xf renode-latest.linux-portable.tar.gz -C renode_portable --strip-components=1
- name: Setup Directories
run: mkdir -p $ROS_WORKSPACE_PATH
- name: checkout
uses: actions/checkout@v4
with:
path: $ROS_WORKSPACE_PATH/usb_cam
- name: Build and Test
id: build_and_test_step
uses: ros-tooling/action-ros-ci@master
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
# Compile again, this time enabling integration tests
- name: Build integration tests
shell: bash
run: |
source /opt/ros/${{ matrix.ros_distro }}/setup.bash
cd $ROS_WORKSPACE_PATH
colcon build --packages-select usb_cam --cmake-args -DSANITIZE=1 -DINTEGRATION_TESTS=1
- name: Run integration tests
shell: bash
run: |
renode_portable/renode --disable-gui --version
- uses: actions/upload-artifact@v4
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@v4
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