291 add renode test #259
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test | ||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
pull_request: | ||
branches: | ||
- 'main/*' | ||
- 'main' | ||
workflow_dispatch: | ||
env: | ||
ROS_WORKSPACE_PATH: colcon_ws/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: Setup Directories | ||
run: mkdir -p $ROS_WORKSPACE_PATH | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
path: $ROS_WORKSPACE_PATH | ||
- name: build | ||
shell: bash | ||
run: | | ||
source /opt/ros/${{ matrix.ros_distro }}/setup.bash | ||
cd $ROS_WORKSPACE_PATH | ||
colcon build --packages-select usb_cam | ||
- name: unit tests | ||
shell: bash | ||
run: | | ||
source /opt/ros/${{ matrix.ros_distro }}/setup.bash | ||
cd $ROS_WORKSPACE_PATH | ||
colcon test --pacakges-select usb_cam | ||
# 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 | ||
uses: antmicro/renode-linux-runner-action@v1 | ||
with: | ||
shared-dirs: | | ||
$ROS_WORKSPACE_PATH/build/usb_cam | ||
renode-run: ./test_usb_cam_lib | ||
Check failure on line 109 in .github/workflows/build_test.yml GitHub Actions / Build and TestInvalid workflow file
|
||
devices: vivid | ||
- 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 |