Skip to content

Commit 02cb671

Browse files
committed
Templates current build version to pass through to test containers
1 parent 7da0184 commit 02cb671

File tree

5 files changed

+22
-20
lines changed

5 files changed

+22
-20
lines changed

cloudbuild.yaml

+13-12
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,15 @@ steps:
269269
270270
pids=()
271271
typeset -A waitPids # Associative array for mapping `kubectl wait job` pid -> `kubectl wait job` output log name
272+
tmpdir=$(mktemp -d)
273+
trap 'rm -rf -- "$tmpdir"' EXIT SIGTERM
274+
275+
# Update image tags to include the current build version.
276+
DevVersion="1.45.0-dev-$(git rev-parse --short=7 HEAD)"
277+
export DevVersion
278+
envsubst < upgradeTest.yaml > "${tmpfile}"/upgradeTest.yaml
279+
envsubst < versionMap.yaml > "${tmpfile}"/versionMap.yaml
280+
272281
# Kill all currently running child processes on exit or if a non-zero signal is seen
273282
trap 'echo Cleaning up any remaining running pids: $(jobs -p) ; kill $(jobs -p) 2> /dev/null || :' EXIT SIGTERM
274283
@@ -326,20 +335,12 @@ steps:
326335
echo kubectl apply -f permissions.yaml on cluster "${testCluster}"
327336
kubectl apply -f permissions.yaml
328337
echo kubectl apply -f versionMap.yaml on cluster "${testCluster}"
329-
kubectl apply -f versionMap.yaml
338+
kubectl apply -f "${tmpfile}"/versionMap.yaml
330339
echo kubectl apply -f gameserverTemplate.yaml on cluster "${testCluster}"
331340
kubectl apply -f gameserverTemplate.yaml
332341
333-
# TODO: Replace image: us-docker.pkg.dev/agones-images/ci/upgrade-test-controller:1.45.0-dev
334-
# in upgradeTest.yaml with the commit tag (e.g. 1.45.0-dev-d3956c8) and pass the same VERSION as
335-
# environment variable for main.go `DevVersion = os.Getenv("DevVersion")`
336-
echo COMMIT_SHA "$COMMIT_SHA"
337-
echo BUILD_ID "$BUILD_ID"
338-
version="1.45.0-dev-$(git rev-parse --short=7 HEAD)"
339-
echo VERSION "$version"
340-
341342
echo kubectl apply -f upgradeTest.yaml on cluster "${testCluster}"
342-
kubectl apply -f upgradeTest.yaml
343+
kubectl apply -f "${tmpfile}"/upgradeTest.yaml
343344
344345
# We need to wait for job pod to be created and ready before we can wait on the job itself.
345346
# TODO: Once all test clusters are at Kubernetes Version >= 1.31 use `kubectl wait --for=create` instead of sleep.
@@ -348,10 +349,10 @@ steps:
348349
kubectl wait --for=condition=ready pod -l job-name=upgrade-test-runner --timeout=5m
349350
350351
echo Wait for job upgrade-test-runner to complete or fail on cluster "${testCluster}"
351-
kubectl wait job/upgrade-test-runner --timeout=20m --for jsonpath='{.status.conditions[*].status}'=True -o jsonpath='{.status.conditions[*].type}' | tee "${testCluster}".log &
352+
kubectl wait job/upgrade-test-runner --timeout=20m --for jsonpath='{.status.conditions[*].status}'=True -o jsonpath='{.status.conditions[*].type}' | tee "${tmpfile}"/"${testCluster}".log &
352353
waitPid=$!
353354
pids+=( "$waitPid" )
354-
waitPids[$waitPid]=${testCluster}.log
355+
waitPids[$waitPid]="${tmpfile}"/"${testCluster}".log
355356
done
356357
done
357358

test/upgrade/Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ REGISTRY ?=
2727
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
2828
project_path := $(dir $(mkfile_path))
2929
root_path = $(realpath $(project_path)/)
30-
dev_version = 1.45.0-dev
31-
server_tag := $(REGISTRY)/upgrade-test-controller:$(dev_version)
30+
base_version = 1.45.0-dev
31+
# Version defaults to the short hash of the latest commit
32+
VERSION ?= $(base_version)-dev-$(shell git rev-parse --short=7 HEAD)
33+
server_tag := $(REGISTRY)/upgrade-test-controller:$(VERSION)
3234

3335
# _____ _
3436
# |_ _|_ _ _ __ __ _ ___| |_ ___

test/upgrade/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const (
6565

6666
var (
6767
// Dev is the current development version of Agones
68-
Dev = os.Getenv("Dev")
68+
DevVersion = os.Getenv("DevVersion")
6969
// ReleaseVersion is the latest released version of Agones (DEV - 1).
7070
ReleaseVersion = os.Getenv("ReleaseVersion")
7171
// PodName the name of the pod this container is running in
@@ -162,7 +162,7 @@ func configTestSetup(ctx context.Context, kubeClient *kubernetes.Clientset) []*c
162162
countsAndLists := containsCountsAndLists(agonesVersion)
163163
ct.agonesVersion = agonesVersion
164164
if agonesVersion == "Dev" {
165-
ct.agonesVersion = Dev
165+
ct.agonesVersion = DevVersion
166166
// Game server container cannot be created at DEV version due to go.mod only able to access
167167
// published Agones versions. Use N-1 for DEV.
168168
ct.gameServerPath = createGameServerFile(ReleaseVersion, countsAndLists)
@@ -299,7 +299,7 @@ func runConfigWalker(ctx context.Context, validConfigs []*configTest) {
299299
for _, config := range validConfigs {
300300
registry := AgonesRegistry
301301
chart := HelmChart
302-
if config.agonesVersion == Dev {
302+
if config.agonesVersion == DevVersion {
303303
// TODO: Update to templated value for registry and chart for Dev build
304304
continue
305305
}

test/upgrade/upgradeTest.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ spec:
2626
spec:
2727
containers:
2828
- name: upgrade-test-controller
29-
# TODO: Update image name to use a templated value for current Dev version
30-
image: us-docker.pkg.dev/agones-images/ci/upgrade-test-controller:1.45.0-dev
29+
image: us-docker.pkg.dev/agones-images/ci/upgrade-test-controller:${DevVersion}
3130
imagePullPolicy: Always
3231
env:
3332
- name: PodName

test/upgrade/versionMap.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ kind: ConfigMap
1818
metadata:
1919
name: version-map
2020
data:
21-
Dev: "1.45.0-dev"
21+
DevVersion: ${DevVersion}
2222
ReleaseVersion: "1.44.0"
2323
version-mappings.json: |
2424
{

0 commit comments

Comments
 (0)