From fbb962c7f69aa54a31c041fb4d5abcf112e97ac2 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Thu, 13 Oct 2022 16:01:20 +0200 Subject: [PATCH] ci-automation: Add an environment variable to skip build shortcuts This will be used for the "run all tests" days in Jenkins. --- ci-automation/ci-config.env | 4 ++++ ci-automation/ci_automation_common.sh | 14 ++++++++++++++ ci-automation/packages-tag.sh | 12 +++++++++++- ci-automation/sdk_bootstrap.sh | 12 +++++++++++- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/ci-automation/ci-config.env b/ci-automation/ci-config.env index f19e49fc2e..5c5eaf188b 100644 --- a/ci-automation/ci-config.env +++ b/ci-automation/ci-config.env @@ -31,6 +31,10 @@ CI_GIT_EMAIL="infra+ci@flatcar-linux.org" CONTAINER_TORCX_ROOT="/home/sdk/build/torcx" CONTAINER_IMAGE_ROOT="/home/sdk/build/images" +# Set it to "1" or "true" or "t" or "y" or "yes" to always run a full +# nightly build. Any other value will allow build shortcuts. +: ${AVOID_NIGHTLY_BUILD_SHORTCUTS:=0} + # # Image / vendor tests settings # diff --git a/ci-automation/ci_automation_common.sh b/ci-automation/ci_automation_common.sh index e65816086f..355a52ce27 100644 --- a/ci-automation/ci_automation_common.sh +++ b/ci-automation/ci_automation_common.sh @@ -507,3 +507,17 @@ function apply_local_patches() { done } # -- + +# Returns 0 if passed value is either "1" or "true" or "t", otherwise +# returns 1. +function bool_is_true() { + case "${1}" in + 1|true|t|yes|y) + return 0 + ;; + *) + return 1 + ;; + esac +} +# -- diff --git a/ci-automation/packages-tag.sh b/ci-automation/packages-tag.sh index 15d1c7d501..1aedb530e5 100644 --- a/ci-automation/packages-tag.sh +++ b/ci-automation/packages-tag.sh @@ -48,6 +48,9 @@ # # 6. A file ../portage.patch to apply with "git am -3" for the portage-stable sub-module. # +# 7. AVOID_NIGHTLY_BUILD_SHORTCUTS. Environment variable. Tells the script to build the SDK even if nothing has changed since last nightly build. +# See the description in ci-config.env. +# # OUTPUT: # # 1. Updated scripts repository @@ -98,7 +101,14 @@ function _packages_tag_impl() { && [[ "$(git -C sdk_container/src/third_party/portage-stable/ rev-parse --abbrev-ref HEAD)" =~ ^flatcar-[0-9]+$ ]] ; then push_branch="true" local existing_tag="" - existing_tag=$(git tag --points-at HEAD) # exit code is always 0, output may be empty + # Check for the existing tag only when we allow shortcutting + # the builds. That way we can skip the checks for build + # shortcutting. + if bool_is_true "${AVOID_NIGHTLY_BUILD_SHORTCUTS}"; then + echo "Continuing the build because AVOID_NIGHTLY_BUILD_SHORTCUTS is bool true (${AVOID_NIGHTLY_BUILD_SHORTCUTS})" >&2 + else + existing_tag=$(git tag --points-at HEAD) # exit code is always 0, output may be empty + fi # If the found tag is a release or nightly tag, we stop this build if there are no changes if [[ "${existing_tag}" =~ ^(stable|alpha|beta|lts)-[0-9.]+(|-nightly-[-0-9]+)$ ]]; then local ret=0 diff --git a/ci-automation/sdk_bootstrap.sh b/ci-automation/sdk_bootstrap.sh index c793b268c4..38199f24a0 100644 --- a/ci-automation/sdk_bootstrap.sh +++ b/ci-automation/sdk_bootstrap.sh @@ -53,6 +53,9 @@ # # 10. A file ../portage.patch to apply with "git am -3" for the portage-stable sub-module. # +# 11. AVOID_NIGHTLY_BUILD_SHORTCUTS. Environment variable. Tells the script to build the SDK even if nothing has changed since last nightly build. +# See the description in ci-config.env. +# # OUTPUT: # # 1. SDK tarball (gentoo catalyst output) of the new SDK, pushed to buildcache. @@ -106,7 +109,14 @@ function _sdk_bootstrap_impl() { && [ "$(git -C sdk_container/src/third_party/portage-stable/ rev-parse --abbrev-ref HEAD)" = "main" ] ; then push_branch="true" local existing_tag="" - existing_tag=$(git tag --points-at HEAD) # exit code is always 0, output may be empty + # Check for the existing tag only when we allow shortcutting + # the builds. That way we can skip the checks for build + # shortcutting. + if bool_is_true "${AVOID_NIGHTLY_BUILD_SHORTCUTS}"; then + echo "Continuing the build because AVOID_NIGHTLY_BUILD_SHORTCUTS is bool true (${AVOID_NIGHTLY_BUILD_SHORTCUTS})" >&2 + else + existing_tag=$(git tag --points-at HEAD) # exit code is always 0, output may be empty + fi # If the found tag is a nightly tag, we stop this build if there are no changes if [[ "${existing_tag}" =~ ^main-[0-9.]+-nightly-[-0-9]+$ ]]; then local ret=0