Skip to content

Commit

Permalink
ci: only build ros2-ws and ros2-control (#97)
Browse files Browse the repository at this point in the history
* ci: delete upstream checking workflows

* feat: use most recent tags

* ci: update workflows

* fix: workflow
  • Loading branch information
domire8 committed Sep 11, 2023
1 parent 9b165a1 commit aaaafdd
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 351 deletions.
86 changes: 16 additions & 70 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,85 +7,31 @@ on:
- main
workflow_dispatch:

env:
CI_BRANCH: 'ci'

jobs:
build-ws:
strategy:
matrix:
ros2_distro: [ humble, iron ]

create-new-ci-branch:
runs-on: ubuntu-latest
name: Create new ci branch from main
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Recreate ci branch
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git checkout -b ${{ env.CI_BRANCH }} origin/main && git push -f -u origin ${{ env.CI_BRANCH }}
build-publish-humble-workspace:
needs: create-new-ci-branch
name: Build and publish ROS2 humble workspace image
name: Build and publish ros2-ws:${{ matrix.ros2_distro }}
uses: ./.github/workflows/reusable-build-push.yml
with:
workspace: ros2-ws
base_tag: humble
base_tag: ${{ matrix.ros2_distro }}
secrets:
token: ${{ secrets.GITHUB_TOKEN }}

build-publish-humble-control:
needs: [ create-new-ci-branch, build-publish-humble-workspace ]
name: Build and publish ROS2 humble workspace image with ros2 control installed
uses: ./.github/workflows/reusable-build-push.yml
with:
workspace: ros2-control
base_tag: humble
dockerfile_extension: .humble
secrets:
token: ${{ secrets.GITHUB_TOKEN }}

build-publish-humble-control-libraries-devel:
needs: [ create-new-ci-branch, build-publish-humble-control ]
name: Build and publish development ROS2 humble ros2 control image with control libraries installed
uses: ./.github/workflows/reusable-build-push.yml
with:
workspace: ros2-control-libraries
base_tag: humble
output_tag: humble-devel
cl_branch: develop
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
build-control:
needs: build-ws
strategy:
matrix:
ros2_distro: [ humble, iron ]

build-publish-humble-control-libraries:
needs: [ create-new-ci-branch, build-publish-humble-control ]
name: Build and publish ROS2 humble ros2 control image with control libraries installed
name: Build and publish ros2-control:${{ matrix.ros2_distro }}
uses: ./.github/workflows/reusable-build-push.yml
with:
workspace: ros2-control-libraries
base_tag: humble
cl_branch: main
secrets:
token: ${{ secrets.GITHUB_TOKEN }}

build-publish-humble-modulo-devel:
needs: [ create-new-ci-branch, build-publish-humble-control-libraries-devel ]
name: Build and publish development ROS2 humble ros2 control image with modulo installed
uses: ./.github/workflows/reusable-build-push.yml
with:
workspace: ros2-modulo-control
base_tag: humble-devel
modulo_branch: develop
secrets:
token: ${{ secrets.GITHUB_TOKEN }}

build-publish-humble-modulo:
needs: [ create-new-ci-branch, build-publish-humble-control-libraries ]
name: Build and publish ROS2 humble ros2 control image with modulo installed
uses: ./.github/workflows/reusable-build-push.yml
with:
workspace: ros2-modulo-control
base_tag: humble
workspace: ros2-control
base_tag: ${{ matrix.ros2_distro }}
dockerfile_extension: .${{ matrix.ros2_distro }}
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
15 changes: 0 additions & 15 deletions .github/workflows/check-upstream-devel.yml

This file was deleted.

15 changes: 0 additions & 15 deletions .github/workflows/check-upstream-main.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/manual-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ on:
options:
- ros2-ws
- ros2-control
- ros2-control-libraries
- ros2-modulo-control
platforms:
description: 'The desired build platform(s) as comma-separated list (for example "linux/amd64,linux/arm64")'
required: true
default: 'linux/amd64'
base_tag:
description: 'The tag of the base image to use'
required: false
Expand All @@ -25,23 +19,10 @@ on:
description: 'The tag for the output image (if left empty, the base tag is used)'
required: false
default: ''
cl_branch:
description: 'The branch of control libraries'
required: false
default: 'main'
modulo_branch:
description: 'The branch of modulo'
required: false
default: 'main'
dockerfile_extension:
description: 'The optional extension of the Dockerfile for variant images'
required: false
default: ''
write_hashes:
description: 'Write image SHA256 and library dependency hashes to file (set to false for temporary or test images)'
required: false
default: true
type: boolean

jobs:
build-push:
Expand All @@ -50,10 +31,6 @@ jobs:
workspace: ${{ inputs.workspace }}
base_tag: ${{ inputs.base_tag }}
output_tag: ${{ inputs.output_tag }}
cl_branch: ${{ inputs.cl_branch }}
modulo_branch: ${{ inputs.modulo_branch }}
dockerfile_extension: ${{ inputs.dockerfile_extension }}
platforms: ${{ inputs.platforms }}
write_hashes: ${{ inputs.write_hashes }}
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
163 changes: 34 additions & 129 deletions .github/workflows/reusable-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,16 @@ on:
output_tag:
required: false
type: string
cl_branch:
required: false
type: string
default: 'main'
modulo_branch:
required: false
type: string
default: 'main'
dockerfile_extension:
required: false
type: string
platforms:
required: false
type: string
default: 'linux/amd64,linux/arm64'
write_hashes:
required: false
type: string
default: 'true'
secrets:
token:
description: 'The GitHub token passed from the caller workflow'
required: true

env:
CI_BRANCH: 'ci'
ARTI_NAME: 'artifact'

jobs:
parse-inputs:
metadata:
runs-on: ubuntu-latest
name: Parse inputs
outputs:
Expand All @@ -51,24 +31,14 @@ jobs:
path: ${{ steps.parse.outputs.path }}
file: ${{ steps.parse.outputs.file }}
build_flags: ${{ steps.parse.outputs.build_flags }}
ci_branch: ${{ steps.parse.outputs.ci_branch }}
steps:
- name: Parse inputs
id: parse
run: |
BUILD_FLAGS=()
# parse base tag
BASE_TAG=${{ inputs.base_tag }}
if [[ "${BASE_TAG}" == *"noetic"* || "${BASE_TAG}" == *"galactic"* ]]; then
UBUNTU_VERSION=focal-fossa
elif [[ "${BASE_TAG}" == *"humble"* || "${BASE_TAG}" == *"iron"* ]]; then
UBUNTU_VERSION=jammy-jellyfish
else
echo "::error::Invalid base tag. Base tag needs to contain either 'noetic', 'galactic', 'humble' or 'iron'."
exit 1
fi
BUILD_FLAGS+=(--build-arg BASE_TAG=${BASE_TAG})
BUILD_FLAGS+=(--build-arg UBUNTU_VERSION=${UBUNTU_VERSION})
echo "::debug::Using base image tag ${BASE_TAG}"
# parse output tag
OUTPUT_TAG=${{ inputs.output_tag }}
Expand All @@ -90,112 +60,47 @@ jobs:
echo "path=${WS_PATH}" >> $GITHUB_OUTPUT
FILE=${WS_PATH}/Dockerfile${{ inputs.dockerfile_extension }}
echo "file=${FILE}" >> $GITHUB_OUTPUT
# add branches to build flags
BUILD_FLAGS+=(--build-arg CL_BRANCH=${{ inputs.cl_branch }})
BUILD_FLAGS+=(--build-arg MODULO_BRANCH=${{ inputs.modulo_branch }})
echo "build_flags=${BUILD_FLAGS[@]}" >> $GITHUB_OUTPUT
# convert env to output
echo "ci_branch=${{ env.CI_BRANCH }}" >> $GITHUB_OUTPUT
prepare-workspace:
needs: parse-inputs
runs-on: ubuntu-latest
name: Prepare workspace
outputs:
artifact_name: ${{ steps.prepare.outputs.artifact_name }}
artifact_path: ${{ steps.prepare.outputs.artifact_path }}
build:
needs: metadata
strategy:
matrix:
arch: [ amd64, arm64 ]
include:
- image: ubuntu-latest
- image: buildjet-2vcpu-ubuntu-2204-arm
arch: arm64

runs-on: ${{ matrix.image }}
name: Build and publish (${{ matrix.arch }})
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Prepare workspace
id: prepare
if: needs.parse-inputs.outputs.path == 'ros2_ws' || needs.parse-inputs.outputs.path == 'ros_ws'
- if: needs.metadata.outputs.path == 'ros2_ws' || needs.metadata.outputs.path == 'ros_ws'
run: |
CONFIG_PATH=${{ needs.parse-inputs.outputs.path }}/config
CONFIG_PATH=${{ needs.metadata.outputs.path }}/config
mkdir -p ${CONFIG_PATH}
cp common/sshd_entrypoint.sh ${CONFIG_PATH}/
echo "artifact_name=${{ env.ARTI_NAME }}" >> $GITHUB_OUTPUT
echo "artifact_path=${CONFIG_PATH}" >> $GITHUB_OUTPUT
shell: bash

- name: Upload artifacts
if: needs.parse-inputs.outputs.path == 'ros2_ws' || needs.parse-inputs.outputs.path == 'ros_ws'
uses: actions/upload-artifact@v3
- uses: aica-technology/.github/.github/actions/ghcr-build@v0.6.1
with:
name: ${{ steps.prepare.outputs.artifact_name }}
path: ${{ steps.prepare.outputs.artifact_path }}
retention-days: 1

build-push:
needs: [ parse-inputs, prepare-workspace ]
name: Build and push
uses: aica-technology/.github/.github/workflows/build-push-multi-arch.yml@v0.1
with:
image_name: ${{ needs.parse-inputs.outputs.image_name }}
image_tags: ${{ needs.parse-inputs.outputs.output_tag }}
platforms: ${{ inputs.platforms }}
build_context_path: ${{ needs.parse-inputs.outputs.path }}
dockerfile_path: ${{ needs.parse-inputs.outputs.file }}
build_flags: ${{ needs.parse-inputs.outputs.build_flags }}
artifact_name: ${{ needs.prepare-workspace.outputs.artifact_name }}
artifact_path: ${{ needs.prepare-workspace.outputs.artifact_path }}
secrets:
token: ${{ secrets.GITHUB_TOKEN }}

write-image-hash:
needs: [ parse-inputs, build-push ]
if: inputs.write_hashes == 'true'
name: Write image hash
uses: aica-technology/.github/.github/workflows/write-file.yml@v0.1
with:
content: ${{ needs.build-push.outputs.image_hash }}
filepath: ./${{ needs.parse-inputs.outputs.path }}/${{ needs.parse-inputs.outputs.output_tag }}-hash
branch: ${{ needs.parse-inputs.outputs.ci_branch }}

get-dependency-hash:
needs: [ write-image-hash ]
if: inputs.workspace == 'ros2-control-libraries' || inputs.workspace == 'ros2-modulo-control'
image_name: ${{ needs.metadata.outputs.image_name }}
image_tags: ${{ needs.metadata.outputs.output_tag }}-${{ matrix.arch }}
build_context_path: ${{ needs.metadata.outputs.path }}
dockerfile_path: ${{ needs.metadata.outputs.file }}
build_flags: ${{ needs.metadata.outputs.build_flags }}
token: ${{ secrets.GITHUB_TOKEN }}

multi-arch:
runs-on: ubuntu-latest
name: Get hash of installed library
outputs:
hash: ${{ steps.get-hash.outputs.hash }}
hash_filename: ${{ steps.get-hash.outputs.hash_filename }}
name: Merge into a multi-arch image
needs: [ metadata, build ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: aica-technology/.github/.github/actions/ghcr-manifest-merge@v0.6.1
with:
ref: ${{ env.CI_BRANCH }}

- name: Get hash
id: get-hash
run: |
HASH=""
HASH_FILENAME=""
if [[ "${{ inputs.workspace }}" == "ros2-control-libraries" ]]; then
BRANCH=${{ inputs.cl_branch }}
HASH_FILENAME="./control-libraries-${BRANCH}-hash"
HASH=$(git ls-remote https://github.com/aica-technology/control-libraries.git ${BRANCH} | awk '{ print $1 }')
elif [[ "${{ inputs.workspace }}" == "ros2-modulo-control" ]]; then
BRANCH=${{ inputs.modulo_branch }}
HASH_FILENAME="./modulo-${BRANCH}-hash"
HASH=$(git ls-remote https://github.com/aica-technology/modulo.git ${BRANCH} | awk '{ print $1 }')
fi
OLD_HASH=$(cat ${HASH_FILENAME} || echo '')
if [ "${OLD_HASH}" != "${HASH}" ]; then
echo "hash_filename=${HASH_FILENAME}" >> $GITHUB_OUTPUT
echo "hash=${HASH}" >> $GITHUB_OUTPUT
fi
shell: bash

write-dependency-hash:
needs: [ parse-inputs, get-dependency-hash ]
if: needs.get-dependency-hash.outputs.hash
name: Write dependency hash
uses: aica-technology/.github/.github/workflows/write-file.yml@v0.1
with:
content: ${{ needs.get-dependency-hash.outputs.hash }}
filepath: ${{ needs.get-dependency-hash.outputs.hash_filename }}
branch: ${{ needs.parse-inputs.outputs.ci_branch }}
image_name: ${{ needs.metadata.outputs.image_name }}
image_tags: ${{ needs.metadata.outputs.output_tag }}
archs: amd64,arm64
token: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit aaaafdd

Please sign in to comment.