mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-15 17:06:58 +02:00
ci-automation: Make tagging code testable through env vars
This commit is contained in:
parent
890ec0aba6
commit
1aed1b2be4
@ -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() {
|
function copy_from_buildcache() {
|
||||||
local what="$1"
|
local what="$1"
|
||||||
local where_to="$2"
|
local where_to="$2"
|
||||||
|
@ -66,14 +66,17 @@ function _packages_tag_impl() {
|
|||||||
source sdk_container/.repo/manifests/version.txt
|
source sdk_container/.repo/manifests/version.txt
|
||||||
local sdk_version="${FLATCAR_SDK_VERSION}"
|
local sdk_version="${FLATCAR_SDK_VERSION}"
|
||||||
|
|
||||||
|
if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
# Create new tag in scripts repo w/ updated versionfile
|
# Create new tag in scripts repo w/ updated versionfile
|
||||||
# Also push the changes to the branch ONLY IF we're doing a nightly
|
# 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
|
# build of the 'flatcar-MAJOR' branch AND we're definitely ON the respective branch
|
||||||
local target_branch=''
|
local target_branch=''
|
||||||
# These variables are here to make it easier to test nightly
|
# These variables are here to make it easier to test nightly
|
||||||
# builds without messing with actual release branches.
|
# builds without messing with actual release branches.
|
||||||
local flatcar_branch_prefix='flatcar'
|
local flatcar_branch_prefix=${CIA_DEBUGFLATCARBRANCHPREFIX:-flatcar}
|
||||||
local nightly='nightly'
|
local nightly=${CIA_DEBUGNIGHTLY:-nightly}
|
||||||
# Patterns used below.
|
# Patterns used below.
|
||||||
local nightly_pattern_1='^(stable|alpha|beta|lts)-[0-9.]+-'"${nightly}"'-[-0-9]+$'
|
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]+)$'
|
local nightly_pattern_2='^(stable|alpha|beta|lts)-[0-9.]+(|-'"${nightly}"'-[-0-9]+)$'
|
||||||
@ -95,8 +98,9 @@ function _packages_tag_impl() {
|
|||||||
local ret=0
|
local ret=0
|
||||||
git diff --exit-code "${existing_tag}" || ret=$?
|
git diff --exit-code "${existing_tag}" || ret=$?
|
||||||
if [[ ret -eq 0 ]]; then
|
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" \
|
if check_bincache_images_existence \
|
||||||
&& curl --head --fail --silent --show-error --location "https://${BUILDCACHE_SERVER}/images/arm64/${FLATCAR_VERSION}/flatcar_production_image.bin.bz2"; then
|
"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
|
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
|
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
|
return 0
|
||||||
@ -110,13 +114,22 @@ function _packages_tag_impl() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then
|
||||||
|
set +x
|
||||||
|
fi
|
||||||
|
|
||||||
# Create version file
|
# Create version file
|
||||||
(
|
(
|
||||||
source sdk_lib/sdk_container_common.sh
|
source sdk_lib/sdk_container_common.sh
|
||||||
create_versionfile "$sdk_version" "$version"
|
create_versionfile "$sdk_version" "$version"
|
||||||
)
|
)
|
||||||
|
if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
update_and_push_version "${version}" "${target_branch}"
|
update_and_push_version "${version}" "${target_branch}"
|
||||||
|
if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
apply_local_patches
|
apply_local_patches
|
||||||
}
|
}
|
||||||
# --
|
# --
|
||||||
|
@ -74,6 +74,9 @@ function _sdk_bootstrap_impl() {
|
|||||||
|
|
||||||
check_version_string "${version}"
|
check_version_string "${version}"
|
||||||
|
|
||||||
|
if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
# Create new tag in scripts repo w/ updated versionfile.
|
# Create new tag in scripts repo w/ updated versionfile.
|
||||||
# Also push the changes to the branch ONLY IF we're doing a nightly
|
# 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.
|
# build of the 'main' branch AND we're definitely ON the main branch.
|
||||||
@ -81,8 +84,8 @@ function _sdk_bootstrap_impl() {
|
|||||||
local target_branch=''
|
local target_branch=''
|
||||||
# These variables are here to make it easier to test nightly
|
# These variables are here to make it easier to test nightly
|
||||||
# builds without messing with actual release branches.
|
# builds without messing with actual release branches.
|
||||||
local main_branch='main'
|
local main_branch=${CIA_DEBUGMAINBRANCH:-main}
|
||||||
local nightly='nightly'
|
local nightly=${CIA_DEBUGNIGHTLY:-nightly}
|
||||||
# Patterns used below.
|
# Patterns used below.
|
||||||
local nightly_pattern_1='^main-[0-9.]+-'"${nightly}"'-[-0-9]+(-INTERMEDIATE)?$'
|
local nightly_pattern_1='^main-[0-9.]+-'"${nightly}"'-[-0-9]+(-INTERMEDIATE)?$'
|
||||||
local nightly_pattern_2='^main-[0-9.]+-'"${nightly}"'-[-0-9]+$'
|
local nightly_pattern_2='^main-[0-9.]+-'"${nightly}"'-[-0-9]+$'
|
||||||
@ -115,9 +118,10 @@ function _sdk_bootstrap_impl() {
|
|||||||
local flatcar_version="${versions[1]}"
|
local flatcar_version="${versions[1]}"
|
||||||
local sdk_docker_vernum=""
|
local sdk_docker_vernum=""
|
||||||
sdk_docker_vernum=$(vernum_to_docker_image_version "${flatcar_sdk_version}")
|
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" \
|
if check_bincache_images_existence \
|
||||||
&& curl --head --fail --silent --show-error --location "https://${BUILDCACHE_SERVER}/images/amd64/${flatcar_version}/flatcar_production_image.bin.bz2" \
|
"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/arm64/${flatcar_version}/flatcar_production_image.bin.bz2"; then
|
"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
|
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
|
return 0
|
||||||
fi
|
fi
|
||||||
@ -130,6 +134,9 @@ function _sdk_bootstrap_impl() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then
|
||||||
|
set +x
|
||||||
|
fi
|
||||||
|
|
||||||
local vernum="${version#*-}" # remove alpha-,beta-,stable-,lts- version tag
|
local vernum="${version#*-}" # remove alpha-,beta-,stable-,lts- version tag
|
||||||
local git_vernum="${vernum}"
|
local git_vernum="${vernum}"
|
||||||
@ -139,7 +146,13 @@ function _sdk_bootstrap_impl() {
|
|||||||
source sdk_lib/sdk_container_common.sh
|
source sdk_lib/sdk_container_common.sh
|
||||||
create_versionfile "${vernum}"
|
create_versionfile "${vernum}"
|
||||||
)
|
)
|
||||||
|
if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
update_and_push_version "${version}" "${target_branch}"
|
update_and_push_version "${version}" "${target_branch}"
|
||||||
|
if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
apply_local_patches
|
apply_local_patches
|
||||||
|
|
||||||
./bootstrap_sdk_container -x ./ci-cleanup.sh "${seed_version}" "${vernum}"
|
./bootstrap_sdk_container -x ./ci-cleanup.sh "${seed_version}" "${vernum}"
|
||||||
|
Loading…
Reference in New Issue
Block a user