Skip to content
This repository was archived by the owner on Dec 8, 2021. It is now read-only.

Commit 2560625

Browse files
authored
ci: optionally freeze files in ci/kokoro/install (#100)
Support keeping some files in ci/kokoro/install frozen as they are more complicated to automatically generate than to maintain manually (or we expect that they will not last long).
1 parent 45bab21 commit 2560625

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

ci/templates/generate-kokoro-install.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ if [[ $# -ne 1 ]]; then
2020
exit 1
2121
fi
2222

23+
if [[ "${BASH_VERSINFO[0]}" -lt 4 || "${BASH_VERSINFO[1]}" -lt 4 ]]; then
24+
echo "This script requires BASH >= 4.4, found ${BASH_VERSION}"
25+
exit 1
26+
fi
27+
2328
if [[ -z "${PROJECT_ROOT+x}" ]]; then
2429
PROJECT_ROOT="$(cd "$(dirname "$0")/../.."; pwd)"
2530
readonly PROJECT_ROOT
@@ -53,8 +58,10 @@ source "${DESTINATION_ROOT}/ci/etc/kokoro/install/project-config.sh"
5358

5459
generate_dockerfile() {
5560
local -r build="$1"
61+
local -r path="kokoro/install/Dockerfile.${build}"
62+
local -r target="${DESTINATION_ROOT}/ci/${path}"
63+
local -r source="${PROJECT_ROOT}/ci/templates/${path}.in"
5664

57-
target="${DESTINATION_ROOT}/ci/kokoro/install/Dockerfile.${build}"
5865
echo "Generating ${target}"
5966
replace_fragments \
6067
"WARNING_GENERATED_FILE_FRAGMENT" \
@@ -66,7 +73,7 @@ generate_dockerfile() {
6673
"INSTALL_CRC32C_FROM_SOURCE" \
6774
"INSTALL_GOOGLE_CLOUD_CPP_COMMON_FROM_SOURCE" \
6875
"BUILD_AND_TEST_PROJECT_FRAGMENT" \
69-
<"${PROJECT_ROOT}/ci/templates/kokoro/install/Dockerfile.${build}.in" | \
76+
<"${source}" | \
7077
sed -e "s/Copyright [0-9][0-9][0-9][0-9]/Copyright ${ORIGINAL_COPYRIGHT_YEAR[${build}]}/" \
7178
>"${target}"
7279
}
@@ -89,4 +96,12 @@ for build in "${BUILD_NAMES[@]}"; do
8996
generate_dockerfile "${build}"
9097
done
9198

99+
# The project-config.sh file may specify a number of "frozen" files, that is,
100+
# files that are not modified by this script.
101+
for file in "${FROZEN_FILES[@]}"; do
102+
echo "Restoring ... ${file}"
103+
git -C "${DESTINATION_ROOT}" reset HEAD "${file}"
104+
git -C "${DESTINATION_ROOT}" checkout -- "${file}"
105+
done
106+
92107
git -C "${DESTINATION_ROOT}" add "ci/kokoro/install"

ci/templates/generate-kokoro-readme.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ if [[ $# -ne 1 ]]; then
2020
exit 1
2121
fi
2222

23+
if [[ "${BASH_VERSINFO[0]}" -lt 4 || "${BASH_VERSINFO[1]}" -lt 4 ]]; then
24+
echo "This script requires BASH >= 4.4, found ${BASH_VERSION}"
25+
exit 1
26+
fi
27+
2328
DESTINATION_ROOT="$1"
2429
readonly DESTINATION_ROOT
2530

@@ -95,4 +100,12 @@ for build in "${BUILD_NAMES[@]}"; do
95100
generate_dockerfile "${build}"
96101
done
97102

103+
# The project-config.sh file may specify a number of "frozen" files, that is,
104+
# files that are not modified by this script.
105+
for file in "${FROZEN_FILES[@]}"; do
106+
echo "Restoring ... ${file}"
107+
git -C "${DESTINATION_ROOT}" reset HEAD "${file}"
108+
git -C "${DESTINATION_ROOT}" checkout -- "${file}"
109+
done
110+
98111
git -C "${DESTINATION_ROOT}" add "ci/kokoro/readme"

0 commit comments

Comments
 (0)