Build humble 24.03 qemu #13
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
# 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 | |
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' }} | |
test: ${{ github.event.inputs.test || 'false' }} | |
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 | |
- 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 | |
- 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: Build ROS 2 ${{ env.ros_distro }} against VxWorks ${{ env.sdk }} | |
# env: | |
# UID: ${{ env.uid }} | |
# GID: ${{ env.gid }} | |
# uses: docker://razr/vxros2build:${{ env.ros_distro }} | |
# with: | |
# args: source /github/home/wrsdk/${{ env.script }} && make -C /github/workspace | |
- 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@v3 | |
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: Run Tests with QEMU and expect | |
if: ${{ env.test == 'true' }} | |
run: | | |
# Change directory to GitHub workspace | |
cd ${{ github.workspace }} | |
# 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 | |
# Run tests | |
echo "Running tests..." | |
./tests/main_script.exp |