diff --git a/ci-automation/ci_automation_common.sh b/ci-automation/ci_automation_common.sh index a0745b25ec..64f675226e 100644 --- a/ci-automation/ci_automation_common.sh +++ b/ci-automation/ci_automation_common.sh @@ -72,6 +72,16 @@ function update_and_push_version() { } # -- +function check_bincache_images_existence() { + case ${CIA_DEBUGIMAGESEXIST:-} in + 'yes') return 0;; + 'no' ) return 1;; + '') curl --head --fail --fail-early --silent --show-error --location "${@}" || return 1;; + *) echo "Invalid CIA_DEBUGIMAGESEXIST value (${CIA_DEBUGIMAGESEXIST@Q})" >&2; exit 1;; + esac +} +# -- + function copy_from_buildcache() { local what="$1" local where_to="$2" diff --git a/ci-automation/packages-tag.sh b/ci-automation/packages-tag.sh index 053f893546..8a6fe93769 100644 --- a/ci-automation/packages-tag.sh +++ b/ci-automation/packages-tag.sh @@ -66,14 +66,17 @@ function _packages_tag_impl() { source sdk_container/.repo/manifests/version.txt local sdk_version="${FLATCAR_SDK_VERSION}" + if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then + set -x + fi # Create new tag in scripts repo w/ updated versionfile # Also push the changes to the branch ONLY IF we're doing a nightly # build of the 'flatcar-MAJOR' branch AND we're definitely ON the respective branch local target_branch='' # These variables are here to make it easier to test nightly # builds without messing with actual release branches. - local flatcar_branch_prefix='flatcar' - local nightly='nightly' + local flatcar_branch_prefix=${CIA_DEBUGFLATCARBRANCHPREFIX:-flatcar} + local nightly=${CIA_DEBUGNIGHTLY:-nightly} # Patterns used below. local nightly_pattern_1='^(stable|alpha|beta|lts)-[0-9.]+-'"${nightly}"'-[-0-9]+$' local nightly_pattern_2='^(stable|alpha|beta|lts)-[0-9.]+(|-'"${nightly}"'-[-0-9]+)$' @@ -95,8 +98,9 @@ function _packages_tag_impl() { local ret=0 git diff --exit-code "${existing_tag}" || ret=$? if [[ ret -eq 0 ]]; then - if curl --head --fail --silent --show-error --location "https://${BUILDCACHE_SERVER}/images/amd64/${FLATCAR_VERSION}/flatcar_production_image.bin.bz2" \ - && curl --head --fail --silent --show-error --location "https://${BUILDCACHE_SERVER}/images/arm64/${FLATCAR_VERSION}/flatcar_production_image.bin.bz2"; then + if check_bincache_images_existence \ + "https://${BUILDCACHE_SERVER}/images/amd64/${FLATCAR_VERSION}/flatcar_production_image.bin.bz2" \ + "https://${BUILDCACHE_SERVER}/images/arm64/${FLATCAR_VERSION}/flatcar_production_image.bin.bz2"; then touch ./skip-build echo "Creating ./skip-build flag file, indicating that the build must not to continue because no new tag got created as there are no changes since tag ${existing_tag} and the Flatcar images exist" >&2 return 0 @@ -110,13 +114,22 @@ function _packages_tag_impl() { fi fi fi + if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then + set +x + fi # Create version file ( source sdk_lib/sdk_container_common.sh create_versionfile "$sdk_version" "$version" ) + if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then + set -x + fi update_and_push_version "${version}" "${target_branch}" + if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then + exit 0 + fi apply_local_patches } # -- diff --git a/ci-automation/sdk_bootstrap.sh b/ci-automation/sdk_bootstrap.sh index 3540ec9023..708e5927b2 100644 --- a/ci-automation/sdk_bootstrap.sh +++ b/ci-automation/sdk_bootstrap.sh @@ -74,6 +74,9 @@ function _sdk_bootstrap_impl() { check_version_string "${version}" + if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then + set -x + fi # Create new tag in scripts repo w/ updated versionfile. # Also push the changes to the branch ONLY IF we're doing a nightly # build of the 'main' branch AND we're definitely ON the main branch. @@ -81,8 +84,8 @@ function _sdk_bootstrap_impl() { local target_branch='' # These variables are here to make it easier to test nightly # builds without messing with actual release branches. - local main_branch='main' - local nightly='nightly' + local main_branch=${CIA_DEBUGMAINBRANCH:-main} + local nightly=${CIA_DEBUGNIGHTLY:-nightly} # Patterns used below. local nightly_pattern_1='^main-[0-9.]+-'"${nightly}"'-[-0-9]+(-INTERMEDIATE)?$' local nightly_pattern_2='^main-[0-9.]+-'"${nightly}"'-[-0-9]+$' @@ -115,9 +118,10 @@ function _sdk_bootstrap_impl() { local flatcar_version="${versions[1]}" local sdk_docker_vernum="" sdk_docker_vernum=$(vernum_to_docker_image_version "${flatcar_sdk_version}") - if curl --head --fail --silent --show-error --location "https://${BUILDCACHE_SERVER}/containers/${sdk_docker_vernum}/flatcar-sdk-all-${sdk_docker_vernum}.tar.zst" \ - && curl --head --fail --silent --show-error --location "https://${BUILDCACHE_SERVER}/images/amd64/${flatcar_version}/flatcar_production_image.bin.bz2" \ - && curl --head --fail --silent --show-error --location "https://${BUILDCACHE_SERVER}/images/arm64/${flatcar_version}/flatcar_production_image.bin.bz2"; then + if check_bincache_images_existence \ + "https://${BUILDCACHE_SERVER}/containers/${sdk_docker_vernum}/flatcar-sdk-all-${sdk_docker_vernum}.tar.zst" \ + "https://${BUILDCACHE_SERVER}/images/amd64/${flatcar_version}/flatcar_production_image.bin.bz2" \ + "https://${BUILDCACHE_SERVER}/images/arm64/${flatcar_version}/flatcar_production_image.bin.bz2"; then echo "Stopping build because there are no changes since tag ${existing_tag}, the SDK container tar ball and the Flatcar images exist" >&2 return 0 fi @@ -130,6 +134,9 @@ function _sdk_bootstrap_impl() { fi fi fi + if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then + set +x + fi local vernum="${version#*-}" # remove alpha-,beta-,stable-,lts- version tag local git_vernum="${vernum}" @@ -139,7 +146,13 @@ function _sdk_bootstrap_impl() { source sdk_lib/sdk_container_common.sh create_versionfile "${vernum}" ) + if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then + set -x + fi update_and_push_version "${version}" "${target_branch}" + if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then + exit 0 + fi apply_local_patches ./bootstrap_sdk_container -x ./ci-cleanup.sh "${seed_version}" "${vernum}"