Skip to content

Build

Build #16

# This is a workflow for the VxWorks ROS 2 build.
# It builds a ROS 2 VxWorks port against the VxWorks SDK
name: 'VxWorks ROS 2 build'
run-name: Build ${{ inputs.ros_distro }} ${{ inputs.vxworks }} ${{ inputs.sdk }}
on:
workflow_dispatch:
inputs:
ros_distro:
description: 'ROS 2 Distribution'
required: true
default: 'humble'
vxworks:
description: 'VxWorks Release'
required: true
default: '24.03'
sdk:
description: 'SDK Name'
required: true
default: 'qemu'
test:
description: 'Run tests'
required: false
default: false
debug:
description: 'Debug'
required: false
default: false
schedule:
- cron: '0 0 * * 0' # Runs at 00:00 UTC every Sunday
jobs:
build:
runs-on: ubuntu-22.04
services:
registry:
image: registry:2
ports:
- 5000:5000
outputs:
sdk: ${{ steps.set_outputs.outputs.sdk }}
ros_distro: ${{ steps.set_outputs.outputs.ros_distro }}
env:
# Check if input variables exist, otherwise set defaults for scheduled runs
ros_distro: ${{ github.event.inputs.ros_distro || 'humble' }}
vxworks: ${{ github.event.inputs.vxworks || '24.03' }}
sdk: ${{ github.event.inputs.sdk || 'qemu' }}
debug: ${{ github.event.inputs.debug || 'false' }}
steps:
- name: Checks-out a branch ${{ github.ref }}
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Use Download SDK action
uses: ./.github/actions/setup-wrsdk
with:
sdks_list: wrsdks.json
sdk: ${{ env.sdk }}
vxworks: ${{ env.vxworks }}
directory: /tmp
sdkenv: false
- name: store runners uid and gid
run: |
echo "`id -u`" > /tmp/wrsdk/uid
echo "`id -g`" > /tmp/wrsdk/gid
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Build vxbuild docker image
uses: docker/build-push-action@v6
with:
context: Docker/22.04/vxbuild/.
push: true
tags: localhost:5000/local/vxbuild:22.04
cache-from: type=gha
cache-to: type=gha,mode=max
env:
DOCKER_BUILD_SUMMARY: false
DOCKER_BUILD_RECORD_UPLOAD: false
- name: Inspect
run: |
docker buildx imagetools inspect localhost:5000/local/vxbuild:22.04
- name: Build vxros2build docker image
uses: docker/build-push-action@v6
with:
context: Docker/22.04/vxros2build/.
push: false
load: true
build-args: |
ROS_DISTRO=${{ env.ros_distro }}
BASE_IMAGE=localhost:5000/local/vxbuild:22.04
tags: vxros2build:${{ env.ros_distro }}
cache-from: type=gha
cache-to: type=gha,mode=max
env:
DOCKER_BUILD_SUMMARY: false
DOCKER_BUILD_RECORD_UPLOAD: false
- name: Verify Docker vxros2build:${{ env.ros_distro }} image
run: |
docker images vxros2build:${{ env.ros_distro }}
- name: Build ROS 2 ${{ env.ros_distro }} against VxWorks ${{ env.vxworks }} ${{ env.sdk }}
uses: addnab/docker-run-action@v3
with:
image: vxros2build:${{ env.ros_distro }}
options: -v ${{ github.workspace }}:/work -v /tmp/wrsdk:/wrsdk
run: |
groupadd -g "`cat /wrsdk/gid`" wruser
useradd -u "`cat /wrsdk/uid`" -m wruser -g wruser
su wruser -c 'source /wrsdk/sdkenv.sh && make -C /work'
- name: Create an SROS2 script
run: |
cat << 'EOF' > /tmp/sros2_script.sh
#!/bin/bash
. /opt/ros/humble/setup.sh
ros2 security create_keystore demo_keystore
ros2 security create_enclave demo_keystore /talker_listener/talker
ros2 security create_enclave demo_keystore /talker_listener/listener
EOF
chmod +x /tmp/sros2_script.sh
- name: Generate a keystore, keys, and certificates for the talker and listener nodes
uses: addnab/docker-run-action@v3
with:
image: vxros2build:${{ env.ros_distro }}
options: -v ${{ github.workspace }}:/work -v /tmp/sros2_script.sh:/tmp/sros2_script.sh
run: |
cd /tmp
/tmp/sros2_script.sh
mv /tmp/demo_keystore /work/output/export/deploy/.
- name: Create an HDD image
run: |
sudo apt-get update
sudo apt-get install -y dosfstools
cd ${{ github.workspace }}
dd if=/dev/zero of=ros2.img count=2048 bs=1M
mkfs.vfat -F 32 ./ros2.img
mkdir -p /tmp/mount
sudo mount -o loop -t vfat ./ros2.img /tmp/mount
sudo cp -r -L ./output/export/deploy/* /tmp/mount/.
df -h /tmp/mount/
sudo umount /tmp/mount
- name: Copy VxWorks image
run: |
cp /tmp/wrsdk/vxsdk/bsps/*/*xWorks* ${{ github.workspace }}
- name: Upload VxWorks and the HDD image
uses: actions/upload-artifact@v4
with:
name: HDD image ${{ env.sdk }} ${{ env.ros_distro }}
path: |
${{ github.workspace }}/ros2.img
${{ github.workspace }}/*xWorks*
- name: Setup tmate session
if: ${{ env.debug == 'true' }}
uses: mxschmitt/action-tmate@v3
- name: Set outputs for sdk and ros_distro
id: set_outputs
run: |
echo "sdk=${{ env.sdk }}" >> $GITHUB_OUTPUT
echo "ros_distro=${{ env.ros_distro }}" >> $GITHUB_OUTPUT
test:
runs-on: ubuntu-22.04
needs: build
if: ${{ github.event.inputs.test != 'false' && (github.event.inputs.test || 'false') == 'true' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Use SDK and ROS Distro from build job
run: |
echo "SDK: ${{ needs.build.outputs.sdk }}"
echo "ROS Distro: ${{ needs.build.outputs.ros_distro }}"
- name: Download HDD image and VxWorks artifacts
uses: actions/download-artifact@v4
with:
name: HDD image ${{ needs.build.outputs.sdk }} ${{ needs.build.outputs.ros_distro }}
- name: Install QEMU and expect
run: |
# Update apt and install dependencies
sudo apt-get update
sudo apt-get install -y qemu-system-x86 expect
# Add user to kvm group
sudo usermod -aG kvm $USER
# Setup tun
sudo apt-get install uml-utilities
sudo tunctl -u $USER -t tap0
sudo ifconfig tap0 192.168.200.254 up
- name: Run Tests with QEMU and expect
run: |
# Change directory to GitHub workspace
cd ${{ github.workspace }}
# Run tests
echo "Running tests..."
./tests/main_script.exp