Skip to content

Commit a1047bb

Browse files
committed
ci-automation: Make tagging code testable through env vars
1 parent 4234b8b commit a1047bb

File tree

3 files changed

+45
-9
lines changed

3 files changed

+45
-9
lines changed

ci-automation/ci_automation_common.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ function update_and_push_version() {
7272
}
7373
# --
7474

75+
function check_bincache_images_existence() {
76+
case ${CIA_DEBUGIMAGESEXIST:-} in
77+
'yes') return 0;;
78+
'no' ) return 1;;
79+
'') curl --head --fail --fail-early --silent --show-error --location "${@}" || return 1;;
80+
*) echo "Invalid CIA_DEBUGIMAGESEXIST value (${CIA_DEBUGIMAGESEXIST@Q})" >&2; exit 1;;
81+
esac
82+
}
83+
# --
84+
7585
function copy_from_buildcache() {
7686
local what="$1"
7787
local where_to="$2"

ci-automation/packages-tag.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,17 @@ function _packages_tag_impl() {
6666
source sdk_container/.repo/manifests/version.txt
6767
local sdk_version="${FLATCAR_SDK_VERSION}"
6868

69+
if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then
70+
set -x
71+
fi
6972
# Create new tag in scripts repo w/ updated versionfile
7073
# Also push the changes to the branch ONLY IF we're doing a nightly
7174
# build of the 'flatcar-MAJOR' branch AND we're definitely ON the respective branch
7275
local target_branch=''
7376
# These variables are here to make it easier to test nightly
7477
# builds without messing with actual release branches.
75-
local flatcar_branch_prefix='flatcar'
76-
local nightly='nightly'
78+
local flatcar_branch_prefix=${CIA_DEBUGFLATCARBRANCHPREFIX:-flatcar}
79+
local nightly=${CIA_DEBUGNIGHTLY:-nightly}
7780
# Patterns used below.
7881
local nightly_pattern_1='^(stable|alpha|beta|lts)-[0-9.]+-'"${nightly}"'-[-0-9]+$'
7982
local nightly_pattern_2='^(stable|alpha|beta|lts)-[0-9.]+(|-'"${nightly}"'-[-0-9]+)$'
@@ -95,8 +98,9 @@ function _packages_tag_impl() {
9598
local ret=0
9699
git diff --exit-code "${existing_tag}" || ret=$?
97100
if [[ ret -eq 0 ]]; then
98-
if curl --head --fail --silent --show-error --location "https://${BUILDCACHE_SERVER}/images/amd64/${FLATCAR_VERSION}/flatcar_production_image.bin.bz2" \
99-
&& curl --head --fail --silent --show-error --location "https://${BUILDCACHE_SERVER}/images/arm64/${FLATCAR_VERSION}/flatcar_production_image.bin.bz2"; then
101+
if check_bincache_images_existence \
102+
"https://${BUILDCACHE_SERVER}/images/amd64/${FLATCAR_VERSION}/flatcar_production_image.bin.bz2" \
103+
"https://${BUILDCACHE_SERVER}/images/arm64/${FLATCAR_VERSION}/flatcar_production_image.bin.bz2"; then
100104
touch ./skip-build
101105
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
102106
return 0
@@ -110,13 +114,22 @@ function _packages_tag_impl() {
110114
fi
111115
fi
112116
fi
117+
if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then
118+
set +x
119+
fi
113120

114121
# Create version file
115122
(
116123
source sdk_lib/sdk_container_common.sh
117124
create_versionfile "$sdk_version" "$version"
118125
)
126+
if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then
127+
set -x
128+
fi
119129
update_and_push_version "${version}" "${target_branch}"
130+
if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then
131+
exit 0
132+
fi
120133
apply_local_patches
121134
}
122135
# --

ci-automation/sdk_bootstrap.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,18 @@ function _sdk_bootstrap_impl() {
7474

7575
check_version_string "${version}"
7676

77+
if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then
78+
set -x
79+
fi
7780
# Create new tag in scripts repo w/ updated versionfile.
7881
# Also push the changes to the branch ONLY IF we're doing a nightly
7982
# build of the 'main' branch AND we're definitely ON the main branch.
8083
# This includes intermediate SDKs when doing 2-phase nightly builds.
8184
local target_branch=''
8285
# These variables are here to make it easier to test nightly
8386
# builds without messing with actual release branches.
84-
local main_branch='main'
85-
local nightly='nightly'
87+
local main_branch=${CIA_DEBUGMAINBRANCH:-main}
88+
local nightly=${CIA_DEBUGNIGHTLY:-nightly}
8689
# Patterns used below.
8790
local nightly_pattern_1='^main-[0-9.]+-'"${nightly}"'-[-0-9]+(-INTERMEDIATE)?$'
8891
local nightly_pattern_2='^main-[0-9.]+-'"${nightly}"'-[-0-9]+$'
@@ -115,9 +118,10 @@ function _sdk_bootstrap_impl() {
115118
local flatcar_version="${versions[1]}"
116119
local sdk_docker_vernum=""
117120
sdk_docker_vernum=$(vernum_to_docker_image_version "${flatcar_sdk_version}")
118-
if curl --head --fail --silent --show-error --location "https://${BUILDCACHE_SERVER}/containers/${sdk_docker_vernum}/flatcar-sdk-all-${sdk_docker_vernum}.tar.zst" \
119-
&& curl --head --fail --silent --show-error --location "https://${BUILDCACHE_SERVER}/images/amd64/${flatcar_version}/flatcar_production_image.bin.bz2" \
120-
&& curl --head --fail --silent --show-error --location "https://${BUILDCACHE_SERVER}/images/arm64/${flatcar_version}/flatcar_production_image.bin.bz2"; then
121+
if check_bincache_images_existence \
122+
"https://${BUILDCACHE_SERVER}/containers/${sdk_docker_vernum}/flatcar-sdk-all-${sdk_docker_vernum}.tar.zst" \
123+
"https://${BUILDCACHE_SERVER}/images/amd64/${flatcar_version}/flatcar_production_image.bin.bz2" \
124+
"https://${BUILDCACHE_SERVER}/images/arm64/${flatcar_version}/flatcar_production_image.bin.bz2"; then
121125
echo "Stopping build because there are no changes since tag ${existing_tag}, the SDK container tar ball and the Flatcar images exist" >&2
122126
return 0
123127
fi
@@ -130,6 +134,9 @@ function _sdk_bootstrap_impl() {
130134
fi
131135
fi
132136
fi
137+
if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then
138+
set +x
139+
fi
133140

134141
local vernum="${version#*-}" # remove alpha-,beta-,stable-,lts- version tag
135142
local git_vernum="${vernum}"
@@ -139,7 +146,13 @@ function _sdk_bootstrap_impl() {
139146
source sdk_lib/sdk_container_common.sh
140147
create_versionfile "${vernum}"
141148
)
149+
if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then
150+
set -x
151+
fi
142152
update_and_push_version "${version}" "${target_branch}"
153+
if [[ -n ${CIA_DEBUGTESTRUN:-} ]]; then
154+
exit 0
155+
fi
143156
apply_local_patches
144157

145158
./bootstrap_sdk_container -x ./ci-cleanup.sh "${seed_version}" "${vernum}"

0 commit comments

Comments
 (0)