Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/clean-old-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Clean Old Docker Image

on:
workflow_dispatch:

jobs:
cleanup-old-images:
runs-on: ubuntu-latest
permissions:
packages: write
deployments: write
statuses: write

steps:
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Purge untagged images
uses: dataaxiom/ghcr-cleanup-action@v1
with:
keep-n-untagged: 0
dry-run: false
34 changes: 27 additions & 7 deletions .github/workflows/colcon-test-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ on:
workflow_dispatch:

jobs:
build-and-push:
spin-up-and-test:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
checks: write
id-token: write

environment:
name: docker-image
Expand All @@ -27,24 +29,42 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v5

- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create Folder for Binding Results
run: mkdir -m 777 -p $GITHUB_WORKSPACE/log

- name: Pull Docker Image
run: |
docker pull ghcr.io/ref-ras/ros2:latest

# spin up docker compose service ros2 and execute colcon test
- name: Execute Colcon Tests
run: |
docker compose run --rm ros2-test bash -c "
source /opt/ros/\$ROS_DISTRO/setup.bash &&
sudo uv pip install pytest-github-actions-annotate-failures &&
cd /workspace/ros2_ws &&
colcon build &&
source install/setup.bash &&
colcon test --event-handlers console_cohesion+ &&
colcon test-result --all
colcon test-result --all &&
sudo cp /workspace/ros2_ws/build/rviz_marker_publisher/pytest.xml /workspace/ros2_ws/src/rviz_marker_publisher
"
# publish test report
- name: Publish Test Report Dashboard
uses: mikepenz/action-junit-report@v4
if: always() # ensures the UI loads even if tests fail
uses: mikepenz/action-junit-report@v6
if: success() || failure() # always run even if the previous step fails
with:
report_paths: 'build/**/test_results/**/*.xml' # path where colcon stores pytest XML reports
# report_paths: '**/build/test-results/test/TEST-*.xml'
report_paths: '**/pytest.xml'

# clean up resources to prevent leaks
- name: Tear Down Containers
if: always()
run: docker compose down --volumes
run: |
docker compose down --volumes
29 changes: 11 additions & 18 deletions .github/workflows/docker-build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ name: Docker Compose Build and Push
on:
workflow_dispatch:
inputs:
environment:
description: 'Target Environment'
docker_image:
type: choice
description: 'Docker Image'
required: true
default: 'docker-image'
default: 'ros2'
options:
- ros2
- moveit2

jobs:
build-and-push:
Expand Down Expand Up @@ -34,11 +38,11 @@ jobs:

# compile the Docker images
- name: Build Docker Compose Images
run: docker compose build moveit2 ros2
run: docker compose build ${{ inputs.docker_image }}

# spin up the containers to ensure they start up successfully
- name: Test Start Containers
run: docker compose up moveit2 ros2 -d --wait
run: docker compose up ${{ inputs.docker_image }} -d --wait

# check container statuses and ensure none have exited with errors
- name: Verify Container Statuses
Expand Down Expand Up @@ -66,17 +70,6 @@ jobs:

# push using the image name defined in docker-compose.yml, only runs when code is merged to main
- name: Push image with Docker Compose to GHCR
if: ${{ github.ref == 'refs/heads/main' && github.event_name != 'pull_request' }}
run: docker compose push moveit2 ros2
# if: ${{ github.ref == 'refs/heads/main' && github.event_name != 'pull_request' }}
run: docker compose push ${{ inputs.docker_image }}

cleanup-old-images:
needs: build-and-push
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Purge untagged images
uses: dataaxiom/ghcr-cleanup-action@v1
with:
keep-n-untagged: 0
dry-run: false
19 changes: 10 additions & 9 deletions .github/workflows/remove-deployments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ jobs:
- name: Inactivaate and delete deployments
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
run: |
# 1. Fetch all deployment IDs for the current repository
echo "Fetching deployments..."
DEPLOYMENTS=$(gh api repos/${{ github.repository }}/deployments --paginate -q '.[].id')
DEPLOYMENTS=$(gh api repos/$OWNER/$REPO/deployments --paginate -q '.[].id')

if [ -z "$DEPLOYMENTS" ]; then
echo "No deployments found."
Expand All @@ -35,18 +37,17 @@ jobs:
for DEPLOYMENT_ID in $DEPLOYMENTS; do
echo "Processing Deployment ID: $DEPLOYMENT_ID"

# Formulate the API URL for this specific deployment
API_URL="repos/${{ github.repository }}/deployments/$DEPLOYMENT_ID"

# Step A: Inactivate the deployment by setting its status to 'inactive'
# (GitHub requires a deployment to be inactive or have no active statuses before deletion)
gh api repos/$API_URL/deployments/$id/statuses \
-X POST -H "Accept: application/vnd.github.ant-man-preview+json" -f state='inactive' \
--silent || true;
# Note: The gh api command automatically fills in the domain, just start with /repos
gh api "/repos/$OWNER/$REPO/deployments/$DEPLOYMENT_ID/statuses" \
-X POST \
-H "Accept: application/vnd.github.ant-man-preview+json" \
-F state="inactive" \
--silent || true

# Step B: Delete the deployment record
echo "Deleting Deployment ID: $DEPLOYMENT_ID..."
gh api repos/$API_URL/deployments/$id -X DELETE;
gh api "/repos/$OWNER/$REPO/deployments/$DEPLOYMENT_ID" -X DELETE
done

echo "Cleanup complete!"
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
![Visualization Topic](https://badgen.net/badge/topic/Visualization/orange?icon=github)
[![License: BSD NON-AI](https://badgen.net/badge/license/BSD-3%20NON-AI?icon=github)](https://github.com/non-ai-licenses/non-ai-licenses/blob/main/NON-AI-BSD3)

[![Docker Compose Build and Deploy](https://github.com/REF-RAS/rviz_marker_tools/actions/workflows/docker-build.yml/badge.svg)](https://github.com/REF-RAS/rviz_marker_tools/actions/workflows/docker-build.yml)
[![Build Sphinx and Deploy](https://github.com/REF-RAS/rviz_marker_tools/actions/workflows/sphinx.yml/badge.svg)](https://github.com/REF-RAS/rviz_marker_tools/actions/workflows/sphinx.yml)
[![Docker Compose Build and Push](https://github.com/REF-RAS/rviz_marker_publisher/actions/workflows/docker-build-and-push.yml/badge.svg)](https://github.com/REF-RAS/rviz_marker_publisher/actions/workflows/docker-build-and-push.yml)
[![Colcon Test Package in Container](https://github.com/REF-RAS/rviz_marker_publisher/actions/workflows/colcon-test-docker.yml/badge.svg)](https://github.com/REF-RAS/rviz_marker_publisher/actions/workflows/colcon-test-docker.yml)
[![Build Sphinx and Deploy](https://github.com/REF-RAS/rviz_marker_publisher/actions/workflows/sphinx.yml/badge.svg)](https://github.com/REF-RAS/rviz_marker_publisher/actions/workflows/sphinx.yml)

## Introduction

Expand Down
6 changes: 4 additions & 2 deletions docker/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ services:
ros2-test:
extends:
service: ros2
working_dir: ~/ros2_ws
container_name: ros2-test
working_dir: /workspace/ros2_ws
environment:
- GITHUB_ACTIONS=true
volumes:
- .:/workspace/ros2_ws/src/rviz_marker_publisher:rw
# the working directory is docker, so .. going back to the repository root
- ${GITHUB_WORKSPACE}:/workspace/ros2_ws/src/rviz_marker_publisher:rw

# service: moveit2 image is based on FROM moveit/moveit2:jazzy-release
moveit2:
Expand Down