Skip to content

Commit

Permalink
move slim in github ci to ci.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
lreiher committed Oct 24, 2024
1 parent d5d7533 commit 4c78b3a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci/docker-ros.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ variables:
REGISTRY_PASSWORD: ${CI_REGISTRY_PASSWORD} # Docker registry password
ENABLE_INDUSTRIAL_CI: 'false' # Enable industrial_ci
ENABLE_SLIM: 'true' # Enable an extra slimmed run image via slim (only if run stage is targeted)
SLIM_BUILD_ARGUMENTS: '--sensor-ipc-mode proxy --continue-after=10 --show-clogs --http-probe=false' # Arguments to `slim build` (except for `--target` and `--tag`)
SLIM_BUILD_ARGS: '--sensor-ipc-mode proxy --continue-after=10 --show-clogs --http-probe=false' # Arguments to `slim build` (except for `--target` and `--tag`)
ENABLE_SINGLEARCH_PUSH: 'false' # Enable push of single arch images with [-amd64|-arm64] postfix
ENABLE_PUSH_AS_LATEST: 'false' # Push images with tag `latest`/`latest-dev` in addition to the configured image names
RMW_IMPLEMENTATION: 'rmw_cyclonedds_cpp' # RMW implementation to use (only for ROS 2)
Expand Down Expand Up @@ -250,7 +250,7 @@ Test run-arm64:
- docker login -u ${REGISTRY_USER} -p ${REGISTRY_PASSWORD} ${REGISTRY}
- docker pull ${FAT_IMAGE}
script:
- ./slim build --target ${FAT_IMAGE} --tag ${SLIM_IMAGE} ${SLIM_BUILD_ARGUMENTS}
- ./slim build --target ${FAT_IMAGE} --tag ${SLIM_IMAGE} ${SLIM_BUILD_ARGS}
- docker push ${SLIM_IMAGE}

Slim run-amd64:
Expand Down
20 changes: 7 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ inputs:

dev-image-tag:
description: "Image tag of dev image"
default: latest-dev

slim-image-name:
description: "Image name of slim run image"
default: ghcr.io/${{ github.repository }}

slim-image-tag:
description: "Image tag of slim run image"
default: latest-slim

build-context:
description: "Build context of Docker build process"
Expand Down Expand Up @@ -126,7 +124,7 @@ inputs:
description: "Enable an extra slimmed run image via slim (only if run stage is targeted)"
default: true

slim-build-arguments:
slim-build-args:
description: "Arguments to `slim build` (except for `--target` and `--tag`)"
default: '--sensor-ipc-mode proxy --continue-after=10 --show-clogs --http-probe=false'

Expand Down Expand Up @@ -222,6 +220,10 @@ runs:
IMAGE_TAG: ${{ inputs.image-tag }}
DEV_IMAGE_NAME: ${{ steps.dev-image-name.outputs.lowercase }}
DEV_IMAGE_TAG: ${{ inputs.dev-image-tag }}
SLIM_IMAGE_NAME: ${{ steps.slim-image-name.outputs.lowercase }}
SLIM_IMAGE_TAG: ${{ inputs.slim-image-tag }}
ENABLE_SLIM: ${{ inputs.enable-slim }}
SLIM_BUILD_ARGS: ${{ inputs.slim-build-args }}
RMW_IMPLEMENTATION: ${{ inputs.rmw-implementation }}
ROS_DISTRO: ${{ inputs.ros-distro }}
GIT_HTTPS_SERVER: ${{ inputs.git-https-server }}
Expand Down Expand Up @@ -260,16 +262,6 @@ runs:
DOCKER_IMAGE: ${{ steps.build-images.outputs.INDUSTRIAL_CI_IMAGE }}
DOCKER_PULL: false

- name: Slim images
if: ${{ inputs.enable-slim == 'true' && contains(inputs.target, 'run') }}
shell: bash
working-directory: ${{ inputs.build-context }}
run: |
curl -L -o ds.tar.gz https://github.com/slimtoolkit/slim/releases/download/1.40.11/dist_linux.tar.gz
tar -xvf ds.tar.gz
cd dist_linux*
./slim build --target ${{ steps.image-name.outputs.lowercase }}:${{ inputs.image-tag }} --tag ${{ steps.slim-image-name.outputs.lowercase }}:${{ inputs.slim-image-tag }} ${{ inputs.slim-build-arguments }}
- name: Slugify ref name
id: slugify-ref-name
uses: gacts/github-slug@v1
Expand All @@ -292,6 +284,7 @@ runs:
SLIM_IMAGE_NAME: ${{ steps.slim-image-name.outputs.lowercase }}
SLIM_IMAGE_TAG: ${{ inputs.slim-image-tag }}
ENABLE_SLIM: ${{ inputs.enable-slim }}
SLIM_BUILD_ARGS: ${{ inputs.slim-build-args }}
ENABLE_SINGLEARCH_PUSH: ${{ inputs.enable-singlearch-push }}
RMW_IMPLEMENTATION: ${{ inputs.rmw-implementation }}
ROS_DISTRO: ${{ inputs.ros-distro }}
Expand Down Expand Up @@ -331,6 +324,7 @@ runs:
SLIM_IMAGE_NAME: ${{ steps.slim-image-name.outputs.lowercase }}
SLIM_IMAGE_TAG: latest-slim
ENABLE_SLIM: ${{ inputs.enable-slim }}
SLIM_BUILD_ARGS: ${{ inputs.slim-build-args }}
ENABLE_SINGLEARCH_PUSH: ${{ inputs.enable-singlearch-push }}
RMW_IMPLEMENTATION: ${{ inputs.rmw-implementation }}
ROS_DISTRO: ${{ inputs.ros-distro }}
Expand Down
31 changes: 24 additions & 7 deletions scripts/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ IMAGE="${IMAGE_NAME}:${IMAGE_TAG}"
DEV_IMAGE="${DEV_IMAGE_NAME}:${DEV_IMAGE_TAG}"
SLIM_IMAGE="${SLIM_IMAGE_NAME}:${SLIM_IMAGE_TAG}"
ENABLE_SLIM="${ENABLE_SLIM:-true}"
SLIM_BUILD_ARGS="${SLIM_BUILD_ARGS:-'--sensor-ipc-mode proxy --continue-after=10 --show-clogs --http-probe=false'}"
ENABLE_SINGLEARCH_PUSH="${ENABLE_SINGLEARCH_PUSH:-false}"
RMW_IMPLEMENTATION="${RMW_IMPLEMENTATION:-}"
ROS_DISTRO="${ROS_DISTRO:-}"
Expand Down Expand Up @@ -68,6 +69,10 @@ fi
unset TARGET
unset PLATFORM

# prepare slim
curl -L -o ds.tar.gz https://github.com/slimtoolkit/slim/releases/download/1.40.11/dist_linux.tar.gz
tar -xvf ds.tar.gz

# loop over targets and platforms to build images
for PLATFORM in "${PLATFORMS[@]}"; do
for TARGET in "${TARGETS[@]}"; do
Expand All @@ -79,11 +84,23 @@ for PLATFORM in "${PLATFORMS[@]}"; do
IMAGE="${image}" build_image
close_log_group
done
done

# push slim images
if [[ "${ENABLE_SLIM}" == "true" && "${_ENABLE_IMAGE_PUSH}" == "true" && "${TARGET}" == *"run"* ]]; then
open_log_group "Push slim image"
docker push "${SLIM_IMAGE}"
close_log_group
fi
# slim image
if [[ "${ENABLE_SLIM}" == "true" && "${TARGET}" == "run" ]]; then
open_log_group "Slim image (${PLATFORM})"
image="${IMAGE}"
slim_image="${SLIM_IMAGE}"
[[ -n "${_IMAGE_POSTFIX}" ]] && image="${image}${_IMAGE_POSTFIX}"
[[ -n "${_IMAGE_POSTFIX}" ]] && slim_image="${slim_image}${_IMAGE_POSTFIX}"
[[ "${_ENABLE_IMAGE_PUSH}" != "true" || "${ENABLE_SINGLEARCH_PUSH}" == "true" ]] && image="${image}-${PLATFORM}"
# TODO: not yet working; builds image with suffix, pushed without? [[ "${_ENABLE_IMAGE_PUSH}" != "true" || "${ENABLE_SINGLEARCH_PUSH}" == "true" ]] && slim_image="${slim_image}-${PLATFORM}"
if [[ "${_ENABLE_IMAGE_PUSH}" == "true" || "${ENABLE_SINGLEARCH_PUSH}" == "true" ]]; then
docker push "${slim_image}"
else
cd dist_linux*
./slim build --target "${image}" --tag "${slim_image}" ${SLIM_BUILD_ARGS}
cd -
fi
close_log_group
fi
done

0 comments on commit 4c78b3a

Please sign in to comment.