RoboSub 2024 (#555) #1513
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 | |
on: | |
push: | |
# Publish `master` as Docker `latest` image. Run only when the docker subdirectory is modified. | |
branches: | |
- master | |
# Run tests for any PRs that have changed a file in the docker subdirectory. | |
pull_request: | |
jobs: | |
check-docker: | |
runs-on: ubuntu-22.04 | |
outputs: | |
docker: ${{ steps.filter.outputs.docker }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Check if docker directory has changed | |
uses: dorny/paths-filter@v2.11.1 | |
id: filter | |
with: | |
filters: | | |
docker: | |
- 'docker/**' | |
- '.github/workflows/**' | |
core-docker: | |
runs-on: ubuntu-22.04 | |
needs: check-docker | |
if: needs.check-docker.outputs.docker == 'true' | |
strategy: | |
matrix: | |
arch: [arm64, amd64] | |
fail-fast: false | |
env: | |
IMAGE_NAME: 'dukerobotics/robosub-ros:core-${{ matrix.arch }}' | |
TARGETPLATFORM: 'linux/${{ matrix.arch }}' | |
SERVICE_NAME: core | |
BASE_IMAGE: dukerobotics/robosub-ros:base | |
FILE_NAME: '${{ matrix.arch }}-core.tar.gz' | |
CUDA: ${{ matrix.arch == 'arm64' }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup environment and build | |
run: | | |
./.github/workflows/build.sh | |
- name: Push image to dockerhub | |
if: github.event_name == 'push' | |
run: | | |
echo "${{ secrets.DOCKER_BOT_TOKEN }}" | docker login -u dukeroboticsbot --password-stdin | |
docker push ${IMAGE_NAME} | |
- name: Save image | |
run: | | |
docker save ${IMAGE_NAME} | gzip > ${FILE_NAME} | |
- name: Create artifact from image | |
uses: actions/upload-artifact@v3 | |
with: | |
name: core | |
path: ${{ env.FILE_NAME }} | |
onboard-docker: | |
runs-on: ubuntu-22.04 | |
needs: core-docker | |
strategy: | |
matrix: | |
arch: [arm64, amd64] | |
fail-fast: false | |
env: | |
IMAGE_NAME: 'dukerobotics/robosub-ros:onboard-${{ matrix.arch }}' | |
TARGETPLATFORM: 'linux/${{ matrix.arch }}' | |
SERVICE_NAME: onboard | |
BASE_IMAGE: 'dukerobotics/robosub-ros:core-${{ matrix.arch }}' | |
FILE_NAME: '${{ matrix.arch }}-core.tar.gz' | |
CUDA: ${{ matrix.arch == 'arm64' }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get core image | |
uses: actions/download-artifact@v3 | |
with: | |
name: core | |
path: core_im | |
- name: Load core image | |
run: | | |
docker load < ./core_im/${FILE_NAME} | |
rm -rf core_im | |
- name: Setup environment and build docker image | |
run: ./.github/workflows/build.sh | |
- name: Start containers | |
run: | | |
docker tag ${IMAGE_NAME} dukerobotics/robosub-ros:onboard | |
docker compose up -d | |
- name: Test build | |
run: docker exec ${SERVICE_NAME} ./build.sh | |
- name: Test Arduino build | |
if: matrix.arch == 'amd64' | |
run: docker exec ${SERVICE_NAME} ./.github/workflows/test_arduino.sh | |
- name: Test ROS launchfiles | |
if: matrix.arch == 'amd64' | |
run: docker exec -t ${SERVICE_NAME} bash -lc "python ./scripts/test-launch.py" | |
- name: Push image to dockerhub | |
if: github.event_name == 'push' | |
run: | | |
echo "${{ secrets.DOCKER_BOT_TOKEN }}" | docker login -u dukeroboticsbot --password-stdin | |
docker push ${IMAGE_NAME} | |
push-docker: | |
runs-on: ubuntu-22.04 | |
needs: [onboard-docker, landside-docker] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Push images to latest on dockerhub | |
if: github.event_name == 'push' | |
run: | | |
./.github/workflows/setup.sh | |
echo "${{ secrets.DOCKER_BOT_TOKEN }}" | docker login -u dukeroboticsbot --password-stdin | |
docker buildx imagetools create --tag dukerobotics/robosub-ros:core dukerobotics/robosub-ros:core-amd64 dukerobotics/robosub-ros:core-arm64 | |
docker buildx imagetools create --tag dukerobotics/robosub-ros:onboard dukerobotics/robosub-ros:onboard-amd64 dukerobotics/robosub-ros:onboard-arm64 | |
cleanup-docker: | |
runs-on: ubuntu-22.04 | |
needs: [check-docker, push-docker] | |
if: always() && (needs.check-docker.outputs.docker == 'true') | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Cleanup artifacts | |
uses: geekyeggo/delete-artifact@v2 | |
with: | |
name: core | |
landside-docker: | |
runs-on: ubuntu-22.04 | |
needs: core-docker | |
env: | |
IMAGE_NAME: dukerobotics/robosub-ros:landside | |
BASE_IMAGE: dukerobotics/robosub-ros:core-amd64 | |
SERVICE_NAME: landside | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get core image | |
uses: actions/download-artifact@v3 | |
with: | |
name: core | |
path: core_im | |
- name: Load core image | |
run: | | |
docker load < ./core_im/amd64-core.tar.gz | |
rm -rf core_im | |
- name: Setup environment and build docker image | |
run: | | |
cd docker/${SERVICE_NAME} | |
docker build --build-arg BASE_IMAGE=${BASE_IMAGE} -t ${IMAGE_NAME} . | |
- name: Start containers | |
run: docker compose up -d | |
- name: Test build | |
run: docker exec ${SERVICE_NAME} ./build.sh | |
- name: Test ROS launchfiles | |
run: docker exec -t ${SERVICE_NAME} bash -lc "python ./scripts/test-launch.py" | |
- name: Push image to dockerhub | |
if: github.event_name == 'push' | |
run: | | |
echo "${{ secrets.DOCKER_BOT_TOKEN }}" | docker login -u dukeroboticsbot --password-stdin | |
docker push ${IMAGE_NAME} | |
build-without-docker: | |
runs-on: ubuntu-22.04 | |
needs: check-docker | |
if: needs.check-docker.outputs.docker == 'false' | |
strategy: | |
matrix: | |
workspace: [onboard, landside] | |
fail-fast: false | |
container: dukerobotics/robosub-ros:${{ matrix.workspace }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Test build | |
run: ./build.sh | |
- name: Test Arduino build | |
if: matrix.workspace == 'onboard' | |
run: ./.github/workflows/test_arduino.sh | |
- name: Test ROS launchfiles | |
shell: bash -elo pipefail {0} | |
run: | | |
source ${{ matrix.workspace }}/catkin_ws/devel/setup.bash | |
./scripts/test-launch.py | |
build-foxglove: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build all Foxglove extensions | |
run: | | |
cd foxglove | |
./foxglove.py install -e |