ROS - Build/Publish Docker Image and Run Tests #29
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: ROS - Build/Publish Docker Image and Run Tests | |
on: | |
workflow_dispatch: | |
release: | |
types: [published] | |
jobs: | |
build_push_testing: | |
runs-on: ubuntu-20.04 | |
outputs: | |
random1: ${{ steps.random1.outputs.random }} | |
random2: ${{ steps.random2.outputs.random }} | |
random3: ${{ steps.random3.outputs.random }} | |
steps: | |
- id: random1 | |
run: echo "random=$RANDOM" >> $GITHUB_OUTPUT | |
- id: random2 | |
run: echo "random=$RANDOM" >> $GITHUB_OUTPUT | |
- id: random3 | |
run: echo "random=$RANDOM" >> $GITHUB_OUTPUT | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
with: | |
version: latest | |
- name: Login to Docker Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: docker.io | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push (latest only) | |
if: github.ref_name == 'main' | |
uses: docker/build-push-action@v2 | |
with: | |
platforms: "linux/amd64" | |
file: Dockerfile.ros | |
push: true | |
build-args: | | |
ROS_DISTRO=iron | |
TAG=core | |
tags: husarnet/ros:iron-ros-core-testing | |
- name: sleep | |
run: sleep 2 | |
# Without Husarnet | |
test_no_husarnet: | |
name: Test no-Husarnet setup | |
needs: build_push_testing | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: run test for ${{ matrix.hostname }} | |
continue-on-error: true | |
timeout-minutes: 2 | |
run: | | |
cd demo-ros | |
export ROS_DISTRO=iron | |
export CHATTER_ROLE=talker | |
docker compose -f compose.no-husarnet.yaml up | |
- name: tree | |
run: cd demo-ros && docker compose logs chatter | tee output.txt | |
- name: tree | |
run: tree | |
- name: show demo-ros/output.txt content | |
run: cat demo-ros/output.txt | |
- name: "Check if the log contains 'Hello World' string" | |
run: "if [[ $(grep 'Hello World' demo-ros/output.txt | wc -l) -eq 0 ]]; then exit 1; fi" | |
# Fast DDS simple | |
test_fastdds_simple: | |
name: Test Fast DDS simple | |
needs: build_push_testing | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
ros-distro: [iron] | |
chatter-role: [talker, listener] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: run test for ${{ matrix.chatter-role }} | |
continue-on-error: true | |
timeout-minutes: 2 | |
run: | | |
cd demo-ros | |
export ROS_DISTRO=${{ matrix.ros-distro }} | |
export CHATTER_ROLE=${{ matrix.chatter-role }} | |
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp | |
export FASTRTPS_DEFAULT_PROFILES_FILE=/husarnet-fastdds-simple.xml | |
export WAIT_HOSTNAMES=talker-${{needs.build_push_testing.outputs.random1}},listener-${{needs.build_push_testing.outputs.random1}} | |
export JOINCODE=${{ secrets.JOINCODE }} | |
export HOSTNAME=${{ matrix.chatter-role }}-${{needs.build_push_testing.outputs.random1}} | |
export HUSARNET_DDS_DEBUG=TRUE | |
docker compose up husarnet chatter | |
- name: tree | |
run: cd demo-ros && docker compose logs chatter | tee output.txt | |
- name: tree | |
run: tree | |
- name: show demo-ros/output.txt content | |
run: cat demo-ros/output.txt | |
- name: "Check if the log contains 'Hello World' string" | |
run: "if [[ $(grep 'Hello World' demo-ros/output.txt | wc -l) -eq 0 ]]; then exit 1; fi" | |
# Fast DDS discovery server | |
test_fastdds_ds: | |
name: Test Fast DDS Discovery Server | |
needs: build_push_testing | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- chatter-role: talker | |
dds-xml: /husarnet-fastdds-ds.xml | |
hostname: talker | |
services: husarnet chatter | |
- chatter-role: listener | |
dds-xml: /husarnet-fastdds-ds.xml | |
hostname: listener | |
services: husarnet chatter | |
- chatter-role: "listener" | |
dds-xml: "/husarnet-fastdds-ds.xml" | |
hostname: ds | |
services: husarnet chatter discovery-server | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: run test for ${{ matrix.hostname }} | |
continue-on-error: true | |
timeout-minutes: 2 | |
run: | | |
cd demo-ros | |
export ROS_DISTRO=iron | |
export CHATTER_ROLE=${{ matrix.chatter-role }} | |
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp | |
export FASTRTPS_DEFAULT_PROFILES_FILE=${{ matrix.dds-xml }} | |
export WAIT_HOSTNAMES=ds-${{needs.build_push_testing.outputs.random2}} | |
export ROS_DISCOVERY_SERVER=ds-${{needs.build_push_testing.outputs.random2}}:11811 | |
export JOINCODE=${{ secrets.JOINCODE }} | |
export HOSTNAME=${{ matrix.hostname }}-${{needs.build_push_testing.outputs.random2}} | |
export HUSARNET_DDS_DEBUG=TRUE | |
docker compose up ${{ matrix.services }} | |
- name: tree | |
run: cd demo-ros && docker compose logs chatter | tee output.txt | |
- name: tree | |
run: tree | |
- name: show demo-ros/output.txt content | |
run: cat demo-ros/output.txt | |
- name: "Check if the log contains 'Hello World' string" | |
run: "if [[ $(grep 'Hello World' demo-ros/output.txt | wc -l) -eq 0 ]]; then exit 1; fi" | |
# Cyclone DDS simple | |
test_cyclonedds_simple: | |
name: Test Cyclone DDS simple | |
needs: build_push_testing | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
ros-distro: [iron] | |
chatter-role: [talker, listener] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: run test for ${{ matrix.chatter-role }} | |
continue-on-error: true | |
timeout-minutes: 2 | |
run: | | |
cd demo-ros | |
export ROS_DISTRO=${{ matrix.ros-distro }} | |
export CHATTER_ROLE=${{ matrix.chatter-role }} | |
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp | |
export CYCLONEDDS_URI=file:///husarnet-cyclonedds-simple.xml | |
export WAIT_HOSTNAMES=talker-${{needs.build_push_testing.outputs.random2}},listener-${{needs.build_push_testing.outputs.random3}} | |
export JOINCODE=${{ secrets.JOINCODE }} | |
export HOSTNAME=${{ matrix.chatter-role }}-${{needs.build_push_testing.outputs.random3}} | |
export HUSARNET_DDS_DEBUG=TRUE | |
docker compose up husarnet chatter | |
- name: tree | |
run: cd demo-ros && docker compose logs chatter | tee output.txt | |
- name: tree | |
run: tree | |
- name: show demo-ros/output.txt content | |
run: cat demo-ros/output.txt | |
- name: "Check if the log contains 'Hello World' string" | |
run: "if [[ $(grep 'Hello World' demo-ros/output.txt | wc -l) -eq 0 ]]; then exit 1; fi" | |
# Push on Docker Hub if tests were finished positively | |
build_push_production: | |
runs-on: ubuntu-20.04 | |
needs: | |
- test_no_husarnet | |
- test_fastdds_simple | |
- test_fastdds_ds | |
- test_cyclonedds_simple | |
strategy: | |
fail-fast: false | |
matrix: | |
ros-distro: [iron, humble] | |
tag: [core, base] | |
steps: | |
- name: Print event name and ref name | |
run: echo "Event name - ${{ github.event_name }}, ref name - ${{ github.ref_name}}" | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
with: | |
version: latest | |
- name: Login to Docker Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: docker.io | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push (latest only) | |
if: github.ref_name == 'main' && github.event_name != 'release' | |
uses: docker/build-push-action@v2 | |
with: | |
platforms: "linux/amd64, linux/arm64" | |
file: Dockerfile.ros | |
push: true | |
build-args: | | |
ROS_DISTRO=${{ matrix.ros-distro }} | |
TAG=${{ matrix.tag }} | |
tags: husarnet/ros:${{ matrix.ros-distro }}-ros-${{ matrix.tag }} | |
- name: Build and push (release) | |
if: github.event_name == 'release' | |
uses: docker/build-push-action@v2 | |
with: | |
platforms: "linux/amd64, linux/arm64" | |
file: Dockerfile.ros | |
push: true | |
build-args: | | |
ROS_DISTRO=${{ matrix.ros-distro }} | |
TAG=${{ matrix.tag }} | |
tags: | | |
husarnet/ros:${{ matrix.ros-distro }}-ros-${{ matrix.tag }} | |
husarnet/ros:${{ matrix.ros-distro }}-ros-${{ matrix.tag }}-${{ github.ref_name}} |