From 6c14beab496692e83617a74248d0a9d128571507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Str=C3=B8m?= <48532094+chrstrom@users.noreply.github.com> Date: Mon, 15 Jul 2024 18:33:13 +0200 Subject: [PATCH 1/9] Create build-workspace.yml --- .github/workflows/build-workspace.yml | 50 +++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/build-workspace.yml diff --git a/.github/workflows/build-workspace.yml b/.github/workflows/build-workspace.yml new file mode 100644 index 00000000..b43b284c --- /dev/null +++ b/.github/workflows/build-workspace.yml @@ -0,0 +1,50 @@ +name: Build ROS 2 Package + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup ROS 2 + uses: ros-tooling/setup-ros@v0.6 + with: + required-ros-distributions: humble + + - name: Clone vortex-msgs + run: | + git clone https://github.com/vortexntnu/vortex-msgs.git + + - name: Create workspace + run: | + mkdir -p ~/ros2_ws/src + cp -R $GITHUB_WORKSPACE ~/ros2_ws/src/ + cp -R vortex-msgs ~/ros2_ws/src/ + + - name: Install dependencies + run: | + cd ~/ros2_ws + rosdep update + rosdep install --from-paths src --ignore-src -r -y + + - name: Build with colcon + run: | + cd ~/ros2_ws + . /opt/ros/humble/setup.sh + colcon build --symlink-install + + - name: Run tests + run: | + cd ~/ros2_ws + . /opt/ros/humble/setup.sh + colcon test + colcon test-result --verbose From 24dae1de9ab730c805233997d70eb3c099a28418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Str=C3=B8m?= <48532094+chrstrom@users.noreply.github.com> Date: Mon, 15 Jul 2024 18:35:58 +0200 Subject: [PATCH 2/9] Add on workflow dispatch trigger --- .github/workflows/build-workspace.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-workspace.yml b/.github/workflows/build-workspace.yml index b43b284c..5e517b98 100644 --- a/.github/workflows/build-workspace.yml +++ b/.github/workflows/build-workspace.yml @@ -1,6 +1,7 @@ name: Build ROS 2 Package on: + workflow_dispatch: push: branches: [ main ] pull_request: From 363cf957982b8b0e3d9f488ea2e8415e57ae41a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Str=C3=B8m?= <48532094+chrstrom@users.noreply.github.com> Date: Mon, 15 Jul 2024 18:37:20 +0200 Subject: [PATCH 3/9] Try hijacking docker publish action that is already set up --- .github/workflows/docker-publish.yml | 77 ++++++++++++++++------------ 1 file changed, 43 insertions(+), 34 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 977fb4d5..5e517b98 100755 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,42 +1,51 @@ -name: Publish Docker image to ghcr +name: Build ROS 2 Package on: + workflow_dispatch: push: branches: [ main ] + pull_request: + branches: [ main ] +jobs: + build: + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + - name: Setup ROS 2 + uses: ros-tooling/setup-ros@v0.6 + with: + required-ros-distributions: humble -jobs: - build-and-push-image: - runs-on: ubuntu-20.04 - permissions: - contents: read - packages: write + - name: Clone vortex-msgs + run: | + git clone https://github.com/vortexntnu/vortex-msgs.git - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Log in to the Container registry - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - - name: Build and push Docker image - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + - name: Create workspace + run: | + mkdir -p ~/ros2_ws/src + cp -R $GITHUB_WORKSPACE ~/ros2_ws/src/ + cp -R vortex-msgs ~/ros2_ws/src/ + + - name: Install dependencies + run: | + cd ~/ros2_ws + rosdep update + rosdep install --from-paths src --ignore-src -r -y + + - name: Build with colcon + run: | + cd ~/ros2_ws + . /opt/ros/humble/setup.sh + colcon build --symlink-install + + - name: Run tests + run: | + cd ~/ros2_ws + . /opt/ros/humble/setup.sh + colcon test + colcon test-result --verbose From b1a484079716c36abe2b0d314904e9559b94ba1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Str=C3=B8m?= <48532094+chrstrom@users.noreply.github.com> Date: Mon, 15 Jul 2024 18:38:11 +0200 Subject: [PATCH 4/9] Revert docker publish test hijack --- .github/workflows/docker-publish.yml | 77 ++++++++++++---------------- 1 file changed, 34 insertions(+), 43 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 5e517b98..977fb4d5 100755 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,51 +1,42 @@ -name: Build ROS 2 Package +name: Publish Docker image to ghcr on: - workflow_dispatch: push: branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - build: - runs-on: ubuntu-22.04 - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Setup ROS 2 - uses: ros-tooling/setup-ros@v0.6 - with: - required-ros-distributions: humble - - name: Clone vortex-msgs - run: | - git clone https://github.com/vortexntnu/vortex-msgs.git +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} - - name: Create workspace - run: | - mkdir -p ~/ros2_ws/src - cp -R $GITHUB_WORKSPACE ~/ros2_ws/src/ - cp -R vortex-msgs ~/ros2_ws/src/ - - - name: Install dependencies - run: | - cd ~/ros2_ws - rosdep update - rosdep install --from-paths src --ignore-src -r -y - - - name: Build with colcon - run: | - cd ~/ros2_ws - . /opt/ros/humble/setup.sh - colcon build --symlink-install +jobs: + build-and-push-image: + runs-on: ubuntu-20.04 + permissions: + contents: read + packages: write - - name: Run tests - run: | - cd ~/ros2_ws - . /opt/ros/humble/setup.sh - colcon test - colcon test-result --verbose + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From fde5228cefee631d0ac7852281e387dbd4bbdcbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Str=C3=B8m?= <48532094+chrstrom@users.noreply.github.com> Date: Mon, 15 Jul 2024 18:41:39 +0200 Subject: [PATCH 5/9] Trigger run on development as well as main --- .github/workflows/build-workspace.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-workspace.yml b/.github/workflows/build-workspace.yml index 5e517b98..1800cb5c 100644 --- a/.github/workflows/build-workspace.yml +++ b/.github/workflows/build-workspace.yml @@ -1,11 +1,11 @@ name: Build ROS 2 Package on: - workflow_dispatch: push: - branches: [ main ] + branches: [ main, development ] pull_request: - branches: [ main ] + branches: [ main, development ] + workflow_dispatch: jobs: build: From 0c8184660ad99d7412a59cdfb1b818667a1adb34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Str=C3=B8m?= <48532094+chrstrom@users.noreply.github.com> Date: Mon, 15 Jul 2024 19:08:15 +0200 Subject: [PATCH 6/9] Move cloned files instead of copy --- .github/workflows/build-workspace.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-workspace.yml b/.github/workflows/build-workspace.yml index 1800cb5c..04292af4 100644 --- a/.github/workflows/build-workspace.yml +++ b/.github/workflows/build-workspace.yml @@ -28,8 +28,8 @@ jobs: - name: Create workspace run: | mkdir -p ~/ros2_ws/src - cp -R $GITHUB_WORKSPACE ~/ros2_ws/src/ - cp -R vortex-msgs ~/ros2_ws/src/ + mv $GITHUB_WORKSPACE ~/ros2_ws/src/ + mv vortex-msgs ~/ros2_ws/src/ - name: Install dependencies run: | From ee37ea44739a7c6a5f3248ef33c738630af52afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Str=C3=B8m?= <48532094+chrstrom@users.noreply.github.com> Date: Mon, 15 Jul 2024 19:18:58 +0200 Subject: [PATCH 7/9] Copy self to avoid losing workspace files --- .github/workflows/build-workspace.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-workspace.yml b/.github/workflows/build-workspace.yml index 04292af4..7f4eede2 100644 --- a/.github/workflows/build-workspace.yml +++ b/.github/workflows/build-workspace.yml @@ -28,7 +28,7 @@ jobs: - name: Create workspace run: | mkdir -p ~/ros2_ws/src - mv $GITHUB_WORKSPACE ~/ros2_ws/src/ + cp -R $GITHUB_WORKSPACE ~/ros2_ws/src/ mv vortex-msgs ~/ros2_ws/src/ - name: Install dependencies From 013d8396da8074fa6d00757994348b15a38bdabc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Str=C3=B8m?= <48532094+chrstrom@users.noreply.github.com> Date: Mon, 15 Jul 2024 19:29:19 +0200 Subject: [PATCH 8/9] Try remove vortex-msgs from clone list --- .github/workflows/build-workspace.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/build-workspace.yml b/.github/workflows/build-workspace.yml index 7f4eede2..b0aa7277 100644 --- a/.github/workflows/build-workspace.yml +++ b/.github/workflows/build-workspace.yml @@ -21,15 +21,10 @@ jobs: with: required-ros-distributions: humble - - name: Clone vortex-msgs - run: | - git clone https://github.com/vortexntnu/vortex-msgs.git - - name: Create workspace run: | mkdir -p ~/ros2_ws/src cp -R $GITHUB_WORKSPACE ~/ros2_ws/src/ - mv vortex-msgs ~/ros2_ws/src/ - name: Install dependencies run: | From 3e1ea89a3412181416f0f602f6b3ddd99f96ca00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Str=C3=B8m?= <48532094+chrstrom@users.noreply.github.com> Date: Mon, 15 Jul 2024 19:51:05 +0200 Subject: [PATCH 9/9] Readd vortex msgs clone --- .github/workflows/build-workspace.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-workspace.yml b/.github/workflows/build-workspace.yml index b0aa7277..b92980ac 100644 --- a/.github/workflows/build-workspace.yml +++ b/.github/workflows/build-workspace.yml @@ -1,12 +1,10 @@ name: Build ROS 2 Package - on: push: branches: [ main, development ] pull_request: branches: [ main, development ] workflow_dispatch: - jobs: build: runs-on: ubuntu-22.04 @@ -15,32 +13,32 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Setup ROS 2 uses: ros-tooling/setup-ros@v0.6 with: required-ros-distributions: humble - - name: Create workspace run: | mkdir -p ~/ros2_ws/src cp -R $GITHUB_WORKSPACE ~/ros2_ws/src/ - + - name: Clone vortex-msgs + run: | + cd ~/ros2_ws/src + git clone https://github.com/vortexntnu/vortex-msgs.git - name: Install dependencies run: | cd ~/ros2_ws rosdep update rosdep install --from-paths src --ignore-src -r -y - - - name: Build with colcon + - name: Build run: | cd ~/ros2_ws . /opt/ros/humble/setup.sh colcon build --symlink-install - - name: Run tests run: | cd ~/ros2_ws . /opt/ros/humble/setup.sh + . install/setup.sh colcon test colcon test-result --verbose