Skip to content

Commit

Permalink
(actions) also generate rolling (#687)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsBurgh authored Sep 19, 2023
2 parents 250c3f6 + e249bc5 commit 7e35a2c
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 11 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/cleanup_container_tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,27 @@ name: Cleanup container tags
on: delete

jobs:
organization_containers:
name: Get all containers in the organization
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.organization_containers.outputs.packages }}
steps:
- name: Organization containers
id: organization_containers
uses: tue-robotics/tue-env/ci/organization-packages@master
with:
package-type: container
token: ${{ secrets.READ_PACKAGES_TOKEN }}

delete_container_tag:
name: Delete container tag
runs-on: ubuntu-latest
needs: organization_containers
strategy:
fail-fast: false
matrix:
package_name: ["tue-env-ros-noetic", "tue-env-ros-galactic", "tue-env-ros-humble"]
package_name: ${{ fromJson(needs.organization_containers.outputs.packages) }}
steps:
- name: Generate tag
id: generate-tag
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/cleanup_untagged_containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,27 @@ on:
workflow_dispatch:

jobs:
organization_containers:
name: Get all containers in the organization
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.organization_containers.outputs.packages }}
steps:
- name: Organization containers
id: organization_containers
uses: tue-robotics/tue-env/ci/organization-packages@master
with:
package-type: container
token: ${{ secrets.READ_PACKAGES_TOKEN }}

delete_untagged_containers:
name: Delete untagged containers
runs-on: ubuntu-latest
needs: organization_containers
strategy:
fail-fast: false
matrix:
package_name: ["tue-env-ros-noetic", "tue-env-ros-galactic", "tue-env-ros-humble"]
package_name: ${{ fromJson(needs.organization_containers.outputs.packages) }}
steps:
- uses: actions/delete-package-versions@v4
with:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ jobs:
- ros-distro: noetic
ros-version: 1
platform: "amd64"
- ros-distro: galactic
base-image: "ubuntu:20.04"
- ros-distro: humble
ros-version: 2
platform: "amd64"
- ros-distro: humble
- ros-distro: rolling
ros-version: 2
platform: "amd64"
base-image: "ubuntu:22.04"
flavor: u22
outputs:
key: ${{ steps.artifacts.outputs.key }}
tag: ${{ steps.script.outputs.tag }}
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12.1
1.13.0
2 changes: 1 addition & 1 deletion ci/build-docker-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ echo -e "\e[35;1mCI_TARGETS_REPO = ${CI_TARGETS_REPO}\e[0m"
[[ -z "$CI_DOCKER_LOGIN" ]] && CI_DOCKER_LOGIN="false"
echo -e "\e[35;1mCI_DOCKER_LOGIN = ${CI_DOCKER_LOGIN}\e[0m"

[[ -z "$CI_DOCKER_BASE_IMAGE" ]] && CI_DOCKER_BASE_IMAGE="ubuntu:20.04"
[[ -z "$CI_DOCKER_BASE_IMAGE" ]] && CI_DOCKER_BASE_IMAGE="ubuntu:22.04"
echo -e "\e[35;1mCI_DOCKER_BASE_IMAGE = ${CI_DOCKER_BASE_IMAGE}\e[0m"

echo -e "\e[35;1mCI_DOCKER_REGISTRY = ${CI_DOCKER_REGISTRY}\e[0m"
Expand Down
45 changes: 45 additions & 0 deletions ci/organization-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#! /usr/bin/env bash

for i in "$@"
do
case $i in
-o=* | --organization=* )
ORGANIZATION="${i#*=}"
;;
-t=* | --type=* )
PACKAGE_TYPE="${i#*=}"
;;
--token=* )
TOKEN="${i#*=}"
;;
* )
# unknown option
if [[ -n "${i}" ]] # Ignore empty arguments
then
echo -e "\e[35m\e[1mUnknown input argument '${i}'. Check CI .yml file\e[0m"
exit 1
fi
;;
esac
shift
done

echo -e "\e[35m\e[1mORGANIZATION = ${ORGANIZATION}\e[0m"
echo -e "\e[35m\e[1mPACKAGE_TYPE = ${PACKAGE_TYPE}\e[0m"
echo -e "\e[35m\e[1mTOKEN length = ${#TOKEN}\e[0m"

echo "::group::curl -L -H \"Accept: application/vnd.github+json\" -H \"Authorization: Bearer \${TOKEN}\" -H \"X-GitHub-Api-Version: 2022-11-28\" \"https://api.github.com/orgs/${ORGANIZATION}/packages?package_type=${PACKAGE_TYPE}&per_page=100&page=1\""
echo -e "\e[1mcurl -L -H \"Accept: application/vnd.github+json\" -H \"Authorization: Bearer \${TOKEN}\" -H \"X-GitHub-Api-Version: 2022-11-28\" \"https://api.github.com/orgs/${ORGANIZATION}/packages?package_type=${PACKAGE_TYPE}&per_page=100&page=1\""
output=$(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${TOKEN}" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/orgs/${ORGANIZATION}/packages?package_type=${PACKAGE_TYPE}&per_page=100&page=1")
echo -e "${output}" | jq -C
echo "::endgroup::"

echo -e "\e[1mjq -r '.[].name'\e[0m"
packages=$(jq -r '.[].name' <<< "${output}")
echo -e "\e[35m\e[1mpackages:\e[0m"
for pkg in ${packages}
do
echo -e "\e[35m\e[1m ${pkg}\e[0m"
packages_list="${packages_list:+$packages_list, }'${pkg}'"
done
packages_list="[${packages_list}]"
32 changes: 32 additions & 0 deletions ci/organization-packages/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: 'Organization packages'
description: 'Get the names of the packages in an organization'
inputs:
package-type:
description: 'Type of the packages'
required: true
type: string
default: 'container'
organization:
description: 'Name of the organization'
required: true
type: string
default: ${{ github.repository_owner }}
token:
description: 'GitHub token'
required: true
type: string
default: ${{ github.token }}
outputs:
packages:
description: 'Package names'
value: ${{ steps.packages.outputs.packages }}
runs:
using: "composite"
steps:
- name: Organization packages
id: packages
run: |
source ${{ github.action_path }}/../organization-packages.sh --organization=${{ inputs.organization }} --type=${{ inputs.package-type }} --token=${{ inputs.token }}
echo -e "\e[35m\e[1mpackages=${packages_list} >> \${GITHUB_OUTPUT}\e[0m"
echo "packages=${packages_list}" >> ${GITHUB_OUTPUT}
shell: bash --noprofile --norc -o pipefail {0}
4 changes: 2 additions & 2 deletions dockerfiles/tue-env.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Dockerfile to build working Ubuntu image with tue-env
# ----------------------------------------------------------------

# Set default base image to Ubuntu 20.04
ARG BASE_IMAGE=ubuntu:20.04
# Set default base image to Ubuntu 22.04
ARG BASE_IMAGE=ubuntu:22.04
FROM $BASE_IMAGE as base

# ----------------------------------------------------------------
Expand Down
24 changes: 23 additions & 1 deletion installer/bootstrap.bash
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ case $DISTRIB_RELEASE in
elif [[ "${ros_distro}" == "galactic" ]]
then
TUE_ROS_DISTRO=galactic
elif [[ "${ros_distro}" == "rolling" ]]
then
TUE_ROS_DISTRO=rolling
elif [[ -n "${ros_distro}" ]]
then
echo "[tue-env](bootstrap) Error! ROS ${ros_distro} is unsupported with tue-env."
Expand All @@ -72,8 +75,27 @@ case $DISTRIB_RELEASE in
fi
;;
"22.04")
TUE_ROS_DISTRO=humble
if [[ -n "${ros_version}" ]] && [[ "${ros_version}" -ne 2 ]]
then
echo "[tue-env](bootstrap) Error! Only ROS version 2 is supported with ubuntu 22.04 and newer"
exit 1
fi
TUE_ROS_VERSION=2

if [[ "${ros_distro}" == "humble" ]]
then
TUE_ROS_DISTRO=humble
elif [[ "${ros_distro}" == "rolling" ]]
then
TUE_ROS_DISTRO=rolling
elif [[ -n "${ros_distro}" ]]
then
echo "[tue-env](bootstrap) Error! ROS ${ros_distro} is unsupported with tue-env."
exit 1
else
TUE_ROS_DISTRO=humble
echo "[tue-env](bootstrap) Using default ROS_DISTRO '${TUE_ROS_DISTRO}' with ROS_VERSION '${TUE_ROS_VERSION}'"
fi
;;
*)
echo "[tue-env](bootstrap) Ubuntu $DISTRIB_RELEASE is unsupported. Please use one of Ubuntu 20.04 or 22.04."
Expand Down
5 changes: 3 additions & 2 deletions setup/generate_setup_file.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /usr/bin/env python3

from typing import IO, List
from typing import List

import os
import sys
Expand Down Expand Up @@ -59,7 +59,8 @@ def _generate_setup_file_rec(self, target: str) -> List[str]:

target_setup_file = os.path.join(self._tue_env_targets_dir, target, "setup")
if os.path.isfile(target_setup_file):
lines.append(f"source {target_setup_file}\n")
rel_target_setup_file = os.path.relpath(target_setup_file, self._tue_env_dir)
lines.append(f"source ${{TUE_ENV_DIR}}/{rel_target_setup_file}\n")

return lines

Expand Down

0 comments on commit 7e35a2c

Please sign in to comment.