Merge pull request #530 from flatcar/krnowak/keep-building

ci-automation: Add an environment variable to skip build shortcuts
This commit is contained in:
Krzesimir Nowak 2022-11-03 12:04:37 +01:00 committed by GitHub
commit 10687c3298
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 2 deletions

View File

@ -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
#

View File

@ -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
}
# --

View File

@ -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

View File

@ -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