Skip to content

Commit 8ad67ca

Browse files
fix: renovate readiness check unicorn pepr image version (#2062)
## Description The current implementation only checks the REGISTRY1_PEPR_IMAGE version against package.json, only validates that registry1 matches package.json, but doesn't check if unicorn is also in sync. I've updated the Pepr version checking logic in the renovate readiness action to validate that all three Pepr versions are in sync. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Other (security config, docs update, etc) ## Checklist before merging - [x] Test, docs, adr added or updated as needed - [x] [Contributor Guide](https://github.com/defenseunicorns/uds-template-capability/blob/main/CONTRIBUTING.md) followed
1 parent 8869a6c commit 8ad67ca

File tree

2 files changed

+67
-6
lines changed

2 files changed

+67
-6
lines changed

.github/actions/renovate-readiness/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@ The action performs the following steps:
1515
2. **Branch Name Processing**: The action extracts the package name from the branch name by removing the `renovate/` prefix.
1616

1717
3. **Special Case Handling**:
18-
- **Pepr Updates**: For Pepr updates, the action compares the version in `package.json` with the image versions in `tasks/create.yaml`. If they don't match, it adds the `waiting on ironbank` label.
18+
- **Pepr Updates**: For Pepr updates, the action validates that all three Pepr versions are in sync:
19+
- `package.json` dependency version
20+
- `REGISTRY1_PEPR_IMAGE` in `tasks/create.yaml`
21+
- `UNICORN_PEPR_IMAGE` in `tasks/create.yaml`
22+
23+
The action applies specific labels based on which versions are out of sync:
24+
- `waiting on upstream`: If package.json version is behind both/either image versions (indicates a Pepr release issue)
25+
- `waiting on ironbank`: If Ironbank image is behind package.json
26+
- `waiting on unicorn`: If Unicorn image is behind package.json
27+
- Multiple `waiting on` labels can be applied if multiple images are behind
1928
- **Support Dependencies**: For support dependency updates, the action adds the `needs-review` label and sets `should_process` to `false` to prevent excessive IAC runs.
2029

2130
4. **Regular Package Updates**:

.github/actions/renovate-readiness/action.yaml

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,67 @@ runs:
8282
IRONBANK_IMAGE_VERSION=${IRONBANK_IMAGE_VERSION#v}
8383
echo "Ironbank image version: $IRONBANK_IMAGE_VERSION"
8484
85-
# Compare versions
85+
UNICORN_IMAGE_VERSION=$(yq e '.variables[] | select(.name == "UNICORN_PEPR_IMAGE") | .default | split(":")[1]' tasks/create.yaml)
86+
UNICORN_IMAGE_VERSION=${UNICORN_IMAGE_VERSION#v}
87+
echo "Unicorn image version: $UNICORN_IMAGE_VERSION"
88+
89+
# Check if all three versions are in sync
90+
IRONBANK_MISMATCH=false
91+
UNICORN_MISMATCH=false
92+
UPSTREAM_BEHIND=false
93+
8694
if [[ "$PEPR_VERSION" != "$IRONBANK_IMAGE_VERSION" ]]; then
87-
echo "Pepr version mismatch. Waiting on Ironbank image update."
95+
echo "ERROR: package.json version ($PEPR_VERSION) does not match Ironbank image version ($IRONBANK_IMAGE_VERSION)"
96+
# Check if package.json version is less than image version (upstream is behind)
97+
if printf '%s\n' "$PEPR_VERSION" "$IRONBANK_IMAGE_VERSION" | sort -V | head -n1 | grep -q "^$PEPR_VERSION$" && [[ "$PEPR_VERSION" != "$IRONBANK_IMAGE_VERSION" ]]; then
98+
UPSTREAM_BEHIND=true
99+
else
100+
IRONBANK_MISMATCH=true
101+
fi
102+
fi
103+
104+
if [[ "$PEPR_VERSION" != "$UNICORN_IMAGE_VERSION" ]]; then
105+
echo "ERROR: package.json version ($PEPR_VERSION) does not match Unicorn image version ($UNICORN_IMAGE_VERSION)"
106+
# Check if package.json version is less than image version (upstream is behind)
107+
if printf '%s\n' "$PEPR_VERSION" "$UNICORN_IMAGE_VERSION" | sort -V | head -n1 | grep -q "^$PEPR_VERSION$" && [[ "$PEPR_VERSION" != "$UNICORN_IMAGE_VERSION" ]]; then
108+
UPSTREAM_BEHIND=true
109+
else
110+
UNICORN_MISMATCH=true
111+
fi
112+
fi
113+
114+
# Apply labels and exit if any mismatch
115+
if [[ "$UPSTREAM_BEHIND" == "true" ]] || [[ "$IRONBANK_MISMATCH" == "true" ]] || [[ "$UNICORN_MISMATCH" == "true" ]]; then
116+
echo "Pepr versions are not in sync. Waiting on updates."
88117
gh pr edit ${{ github.event.pull_request.number }} --remove-label "needs-review" || true
89-
gh pr edit ${{ github.event.pull_request.number }} --add-label "waiting on ironbank"
118+
119+
if [[ "$UPSTREAM_BEHIND" == "true" ]]; then
120+
echo "Upstream package.json is behind image versions - possible Pepr release issue"
121+
gh pr edit ${{ github.event.pull_request.number }} --add-label "waiting on upstream"
122+
gh pr edit ${{ github.event.pull_request.number }} --remove-label "waiting on ironbank" || true
123+
gh pr edit ${{ github.event.pull_request.number }} --remove-label "waiting on unicorn" || true
124+
else
125+
gh pr edit ${{ github.event.pull_request.number }} --remove-label "waiting on upstream" || true
126+
127+
if [[ "$IRONBANK_MISMATCH" == "true" ]]; then
128+
gh pr edit ${{ github.event.pull_request.number }} --add-label "waiting on ironbank"
129+
else
130+
gh pr edit ${{ github.event.pull_request.number }} --remove-label "waiting on ironbank" || true
131+
fi
132+
133+
if [[ "$UNICORN_MISMATCH" == "true" ]]; then
134+
gh pr edit ${{ github.event.pull_request.number }} --add-label "waiting on unicorn"
135+
else
136+
gh pr edit ${{ github.event.pull_request.number }} --remove-label "waiting on unicorn" || true
137+
fi
138+
fi
139+
90140
exit 1
91141
else
92-
echo "Pepr versions match. Ready for review."
142+
echo "All Pepr versions are in sync. Ready for review."
143+
gh pr edit ${{ github.event.pull_request.number }} --remove-label "waiting on upstream" || true
93144
gh pr edit ${{ github.event.pull_request.number }} --remove-label "waiting on ironbank" || true
145+
gh pr edit ${{ github.event.pull_request.number }} --remove-label "waiting on unicorn" || true
94146
gh pr edit ${{ github.event.pull_request.number }} --add-label "needs-review"
95147
fi
96148
@@ -199,7 +251,7 @@ runs:
199251
echo "Current labels: $CURRENT_LABELS"
200252
201253
# Define the managed labels we care about
202-
MANAGED_LABELS=("waiting on ironbank" "waiting on rapidfort" "needs-review" "helm-chart-only" "major-helm-update" "major-image-update")
254+
MANAGED_LABELS=("waiting on upstream" "waiting on ironbank" "waiting on unicorn" "waiting on rapidfort" "needs-review" "helm-chart-only" "major-helm-update" "major-image-update")
203255
204256
# Remove labels that are currently on the PR but not in the new set
205257
for LABEL in "${MANAGED_LABELS[@]}"; do

0 commit comments

Comments
 (0)