Skip to content

Commit da521c2

Browse files
committed
fix(ci): validate Glean version before image retagging
1 parent f18220a commit da521c2

2 files changed

Lines changed: 100 additions & 22 deletions

File tree

.github/scripts/tests/nighty-release-workflow-test.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,38 @@ assert_contains() {
2323
}
2424
}
2525

26+
assert_not_contains() {
27+
local name="$1"
28+
local needle="$2"
29+
if grep -Fq -- "${needle}" "${WORKFLOW}"; then
30+
echo "FAIL: ${name}: unexpectedly found ${needle}" >&2
31+
exit 1
32+
fi
33+
}
34+
35+
assert_step_before() {
36+
local name="$1"
37+
local first_id="$2"
38+
local second_name="$3"
39+
local first_index second_index
40+
41+
first_index="$(
42+
yq -r \
43+
".jobs.retag-latest-images.steps | to_entries | map(select(.value.id == \"${first_id}\")) | .[0].key" \
44+
"${WORKFLOW}"
45+
)"
46+
second_index="$(
47+
yq -r \
48+
".jobs.retag-latest-images.steps | to_entries | map(select(.value.name == \"${second_name}\")) | .[0].key" \
49+
"${WORKFLOW}"
50+
)"
51+
52+
if [[ "${first_index}" == "null" || "${second_index}" == "null" || "${first_index}" -ge "${second_index}" ]]; then
53+
echo "FAIL: ${name}: expected ${first_id} before ${second_name}" >&2
54+
exit 1
55+
fi
56+
}
57+
2658
assert_eq "release input type" \
2759
"$(yq -r '.on.workflow_dispatch.inputs.release_type.type' "${WORKFLOW}")" choice
2860
assert_eq "release input default" \
@@ -48,4 +80,48 @@ assert_contains "selected tag mode" \
4880
assert_contains "selected promotion" \
4981
'--promote "${{ needs.release-config.outputs.channel_name }}"'
5082

83+
assert_eq "seed channel name output" \
84+
"$(yq -r '.jobs.release-config.outputs.seed_channel_name' "${WORKFLOW}")" \
85+
'${{ steps.config.outputs.seed_channel_name }}'
86+
assert_eq "seed channel id output" \
87+
"$(yq -r '.jobs.release-config.outputs.seed_channel_id' "${WORKFLOW}")" \
88+
'${{ steps.config.outputs.seed_channel_id }}'
89+
assert_eq "seed chart output" \
90+
"$(yq -r '.jobs.release-config.outputs.seed_chart_oci_ref' "${WORKFLOW}")" \
91+
'${{ steps.config.outputs.seed_chart_oci_ref }}'
92+
assert_eq "version prefix output" \
93+
"$(yq -r '.jobs.release-config.outputs.version_prefix' "${WORKFLOW}")" \
94+
'${{ steps.config.outputs.version_prefix }}'
95+
96+
assert_eq "selected seed channel name" \
97+
"$(yq -r '.jobs.retag-latest-images.steps[] | select(.id == "calculate_release_tag") | .env.SEED_CHANNEL_NAME' "${WORKFLOW}")" \
98+
'${{ needs.release-config.outputs.seed_channel_name }}'
99+
assert_eq "selected seed channel id" \
100+
"$(yq -r '.jobs.retag-latest-images.steps[] | select(.id == "calculate_release_tag") | .env.SEED_CHANNEL_ID' "${WORKFLOW}")" \
101+
'${{ needs.release-config.outputs.seed_channel_id }}'
102+
assert_eq "selected seed chart" \
103+
"$(yq -r '.jobs.retag-latest-images.steps[] | select(.id == "calculate_release_tag") | .env.SEED_CHART_OCI_REF' "${WORKFLOW}")" \
104+
'${{ needs.release-config.outputs.seed_chart_oci_ref }}'
105+
106+
assert_eq "release version helper" \
107+
"$(yq -r '.jobs.retag-latest-images.steps[] | select(.id == "calculate_version") | .run' "${WORKFLOW}")" \
108+
'bash ./.github/scripts/calculate-release-version.sh'
109+
assert_eq "retag current version output" \
110+
"$(yq -r '.jobs.retag-latest-images.outputs.current_version' "${WORKFLOW}")" \
111+
'${{ steps.calculate_version.outputs.current }}'
112+
assert_eq "retag new version output" \
113+
"$(yq -r '.jobs.retag-latest-images.outputs.new_version' "${WORKFLOW}")" \
114+
'${{ steps.calculate_version.outputs.new }}'
115+
assert_eq "replicated previous version consumption" \
116+
"$(yq -r '.jobs.replicated-release.outputs.previous_version' "${WORKFLOW}")" \
117+
'${{ needs.retag-latest-images.outputs.current_version }}'
118+
assert_eq "replicated new version consumption" \
119+
"$(yq -r '.jobs.replicated-release.outputs.version' "${WORKFLOW}")" \
120+
'${{ needs.retag-latest-images.outputs.new_version }}'
121+
122+
assert_step_before "version validation precedes AWS credentials" \
123+
calculate_version "Determine AWS Assume Role ARN"
124+
assert_not_contains "late inline version calculation" \
125+
'name: Get and bump version'
126+
51127
echo "nighty-release workflow tests passed"

.github/workflows/nighty-release.yml

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ jobs:
8080
chart_oci_ref: ${{ steps.config.outputs.chart_oci_ref }}
8181
tag_calculation_mode: ${{ steps.config.outputs.tag_calculation_mode }}
8282
branch_prefix: ${{ steps.config.outputs.branch_prefix }}
83+
seed_channel_name: ${{ steps.config.outputs.seed_channel_name }}
84+
seed_channel_id: ${{ steps.config.outputs.seed_channel_id }}
85+
seed_chart_oci_ref: ${{ steps.config.outputs.seed_chart_oci_ref }}
86+
version_prefix: ${{ steps.config.outputs.version_prefix }}
8387
steps:
8488
- name: Checkout code
8589
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
@@ -131,7 +135,8 @@ jobs:
131135
outputs:
132136
release_tag: ${{ steps.retag.outputs.release_tag }}
133137
retagged_images: ${{ steps.retag.outputs.retagged_images }}
134-
current_version: ${{ steps.calculate_release_tag.outputs.replicated_current_version }}
138+
current_version: ${{ steps.calculate_version.outputs.current }}
139+
new_version: ${{ steps.calculate_version.outputs.new }}
135140
env:
136141
IMAGE_REPOS: "apollo frontend apollo-db-init thermos thermos-db-init mercury weaviate thermos-toolkit-registry"
137142
# Per-repo ECR source tags (manual runs only; empty on schedule). Empty = use "latest".
@@ -193,8 +198,21 @@ jobs:
193198
RELEASE_CHANNEL_NAME: ${{ needs.release-config.outputs.channel_name }}
194199
RELEASE_CHANNEL_ID: ${{ needs.release-config.outputs.channel_id }}
195200
TAG_CALCULATION_MODE: ${{ needs.release-config.outputs.tag_calculation_mode }}
201+
SEED_CHANNEL_NAME: ${{ needs.release-config.outputs.seed_channel_name }}
202+
SEED_CHANNEL_ID: ${{ needs.release-config.outputs.seed_channel_id }}
203+
SEED_CHART_OCI_REF: ${{ needs.release-config.outputs.seed_chart_oci_ref }}
196204
run: bash ./.github/scripts/calculate-nightly-release-tag.sh
197205

206+
- name: Calculate and validate release version
207+
id: calculate_version
208+
shell: bash
209+
env:
210+
RELEASE_TYPE: ${{ needs.release-config.outputs.release_type }}
211+
RELEASE_CHANNEL_NAME: ${{ needs.release-config.outputs.channel_name }}
212+
CURRENT_VERSION: ${{ steps.calculate_release_tag.outputs.replicated_current_version }}
213+
VERSION_PREFIX: ${{ needs.release-config.outputs.version_prefix }}
214+
run: bash ./.github/scripts/calculate-release-version.sh
215+
198216
- name: Determine AWS Assume Role ARN
199217
id: env
200218
run: |
@@ -366,8 +384,8 @@ jobs:
366384
id-token: write
367385
outputs:
368386
branch_name: ${{ steps.branch.outputs.branch_name }}
369-
previous_version: ${{ steps.version.outputs.current }}
370-
version: ${{ steps.version.outputs.new }}
387+
previous_version: ${{ needs.retag-latest-images.outputs.current_version }}
388+
version: ${{ needs.retag-latest-images.outputs.new_version }}
371389
steps:
372390
- name: Checkout code
373391
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
@@ -425,33 +443,17 @@ jobs:
425443
run: |
426444
helm template composio ./composio
427445
428-
- name: Get and bump version
429-
id: version
430-
run: |
431-
set -euo pipefail
432-
CURRENT_APPVERSION="${{ needs.retag-latest-images.outputs.current_version }}"
433-
if [[ ! "${CURRENT_APPVERSION}" =~ ^[0-9]+([.][0-9]+)*$ ]]; then
434-
echo "${{ needs.release-config.outputs.channel_name }} channel returned an invalid currentVersion: ${CURRENT_APPVERSION:-<empty>}" >&2
435-
exit 1
436-
fi
437-
438-
NEW_APPVERSION="$(echo "${CURRENT_APPVERSION}" | awk -F. '{$NF = $NF + 1} 1' OFS=.)"
439-
echo "current=${CURRENT_APPVERSION}" >> "${GITHUB_OUTPUT}"
440-
echo "new=${NEW_APPVERSION}" >> "${GITHUB_OUTPUT}"
441-
echo "Current version: ${CURRENT_APPVERSION}"
442-
echo "New version: ${NEW_APPVERSION}"
443-
444446
- name: Update Chart.yaml versions
445447
run: |
446448
cd ./composio
447-
export NEW_VERSION="${{ steps.version.outputs.new }}"
449+
export NEW_VERSION="${{ needs.retag-latest-images.outputs.new_version }}"
448450
yq eval -i '.appVersion = strenv(NEW_VERSION)' ./Chart.yaml
449451
yq eval -i '.version = strenv(NEW_VERSION)' ./Chart.yaml
450452
echo "Updated Chart.yaml"
451453
452454
- name: Update manifest versions
453455
run: |
454-
export NEW_VERSION="${{ steps.version.outputs.new }}"
456+
export NEW_VERSION="${{ needs.retag-latest-images.outputs.new_version }}"
455457
export RELEASE_TAG="${{ needs.retag-latest-images.outputs.release_tag }}"
456458
457459
cd ./composio
@@ -494,7 +496,7 @@ jobs:
494496
replicated release create \
495497
--yaml-dir manifests \
496498
--promote "${{ needs.release-config.outputs.channel_name }}" \
497-
--version "${{ steps.version.outputs.new }}"
499+
--version "${{ needs.retag-latest-images.outputs.new_version }}"
498500
499501
- name: Push release branch
500502
if: success()

0 commit comments

Comments
 (0)