Skip to content

Commit

Permalink
Resolve KASM-5423 "Feature/ named schedules"
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Kuba authored and j-travis committed Feb 6, 2024
1 parent fb8a621 commit f609fe0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
5 changes: 0 additions & 5 deletions ci-scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ if [ ${USE_PRIVATE_IMAGES} -eq 1 ]; then
BASE=${BASE}-private
fi

# Determine if this is a rolling build
if [ "${CI_PIPELINE_SOURCE}" == "schedule" ]; then
BASE_TAG=${BASE_TAG}-rolling
fi

## Build/Push image to cache endpoint by pipeline ID ##
docker build \
-t ${ORG_NAME}/image-cache-private:$(arch)-${NAME}-${SANITIZED_BRANCH}-${CI_PIPELINE_ID} \
Expand Down
6 changes: 6 additions & 0 deletions ci-scripts/gitlab-ci.template
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ test_{{ IMAGE.name }}:
manifest_{{ IMAGE.name }}:
stage: manifest
when: always
variables:
SCHEDULED: "{{ SCHEDULED }}"
SCHEDULE_NAME: "{{ SCHEDULE_NAME }}"
script:
- apk add bash tar
- bash ci-scripts/manifest.sh "{{ IMAGE.name }}" "multi"{% if IMAGE.singleapp %}
Expand All @@ -162,6 +165,9 @@ manifest_{{ IMAGE.name }}:
manifest_{{ IMAGE.name }}:
stage: manifest
when: always
variables:
SCHEDULED: "{{ SCHEDULED }}"
SCHEDULE_NAME: "{{ SCHEDULE_NAME }}"
script:
- apk add bash tar
- bash ci-scripts/manifest.sh "{{ IMAGE.name }}" "single"{% if IMAGE.singleapp %}
Expand Down
24 changes: 16 additions & 8 deletions ci-scripts/manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,31 @@ else
fi

# Determine if this is a rolling build
if [ "${CI_PIPELINE_SOURCE}" == "schedule" ]; then
SANITIZED_BRANCH=${SANITIZED_BRANCH}-rolling
if [[ "${SCHEDULED}" != "NO" ]]; then
if [[ "${SCHEDULE_NAME}" == "NO" ]]; then
SANITIZED_BRANCH=${SANITIZED_BRANCH}-rolling
else
SANITIZED_BRANCH=${SANITIZED_BRANCH}-rolling-${SCHEDULE_NAME}
fi
fi

# Determine if we are doing a reversion
if [ ! -z "${REVERT_PIPELINE_ID}" ]; then
# If we are reverting modify the pipeline ID to the one passed
CI_PIPELINE_ID=${REVERT_PIPELINE_ID}
if [ "${IS_ROLLING}" == "true" ]; then
SANITIZED_BRANCH=${SANITIZED_BRANCH}-rolling
if [[ "${IS_ROLLING}" == "true" ]]; then
if [[ "${SCHEDULE_NAME}" == "NO" ]]; then
SANITIZED_BRANCH=${SANITIZED_BRANCH}-rolling
else
SANITIZED_BRANCH=${SANITIZED_BRANCH}-rolling-${SCHEDULE_NAME}
fi
fi
fi

# Check test output
if [ -z "${REVERT_PIPELINE_ID}" ]; then
if [[ -z "${REVERT_PIPELINE_ID}" ]]; then
apk add curl
if [ "${TYPE}" == "multi" ]; then
if [[ "${TYPE}" == "multi" ]]; then
ARCHES=("x86_64" "aarch64")
else
ARCHES=("x86_64")
Expand All @@ -58,12 +66,12 @@ if [ -z "${REVERT_PIPELINE_ID}" ]; then
fi

# Fail job and go no further if tests did not pass
if [ "${FAILED}" == "true" ]; then
if [[ "${FAILED}" == "true" ]]; then
exit 1
fi

# Manifest for multi pull and push for single arch
if [ "${TYPE}" == "multi" ]; then
if [[ "${TYPE}" == "multi" ]]; then

# Pull images from cache repo
docker pull ${ORG_NAME}/image-cache-private:x86_64-${NAME}-${PULL_BRANCH}-${CI_PIPELINE_ID}
Expand Down
7 changes: 7 additions & 0 deletions ci-scripts/template-gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@

# Determine if this is a feature branch
fileLimits = True
scheduled = 'NO'
scheduleName = 'NO'
if os.getenv('SANITIZED_BRANCH').startswith('release') or os.getenv('SANITIZED_BRANCH') == 'develop':
fileLimits = False
if os.getenv('CI_PIPELINE_SOURCE') == 'schedule':
fileLimits = False
scheduled = 'YES'
if 'SCHEDULE_NAME' in os.environ:
scheduleName = os.getenv('SCHEDULE_NAME')
if os.getenv('USE_PRIVATE_IMAGES') == 1:
fileLimits = False

Expand All @@ -21,6 +26,8 @@
templateVars['USE_PRIVATE_IMAGES'] = os.getenv('USE_PRIVATE_IMAGES')
templateVars['BASE_TAG'] = os.getenv('BASE_TAG')
templateVars['FILE_LIMITS'] = fileLimits
templateVars['SCHEDULED'] = scheduled
templateVars['SCHEDULE_NAME'] = scheduleName

# Read template file
with open("gitlab-ci.template", 'r') as stream:
Expand Down

0 comments on commit f609fe0

Please sign in to comment.