Skip to content

ROX-33413: Add check to verify release version exists in scannver version file#19260

Open
ksurabhi91 wants to merge 2 commits intomasterfrom
scanner_ver_check
Open

ROX-33413: Add check to verify release version exists in scannver version file#19260
ksurabhi91 wants to merge 2 commits intomasterfrom
scanner_ver_check

Conversation

@ksurabhi91
Copy link
Contributor

@ksurabhi91 ksurabhi91 commented Mar 2, 2026

This PR adds a script in finish release workflow that verifies that planned release version exists in scanner version file. This will ensure that the rhacs-bot PR that makes this change is merged otherwise this check fails.
Script was tested locally using different version as input
Screenshot 2026-03-02 at 1 03 43 PM

change me!

User-facing documentation

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

change me!

@openshift-ci
Copy link

openshift-ci bot commented Mar 2, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The new check-scanner-version.sh script assumes GITHUB_REPOSITORY is set, which will not be true for local runs as suggested in the usage comment; consider either documenting that requirement or allowing the repository to be passed in as an argument or defaulting to a sensible local value.
  • The script hardcodes the master branch in the GitHub API ref parameter; if the default branch ever changes, this will break silently, so consider using a configurable branch (e.g., an env var) instead of a literal 'master'.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new check-scanner-version.sh script assumes GITHUB_REPOSITORY is set, which will not be true for local runs as suggested in the usage comment; consider either documenting that requirement or allowing the repository to be passed in as an argument or defaulting to a sensible local value.
- The script hardcodes the master branch in the GitHub API ref parameter; if the default branch ever changes, this will break silently, so consider using a configurable branch (e.g., an env var) instead of a literal 'master'.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@rhacs-bot
Copy link
Contributor

rhacs-bot commented Mar 2, 2026

Images are ready for the commit at ae0d19b.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.11.x-216-gae0d19b6b4.

@ksurabhi91 ksurabhi91 marked this pull request as ready for review March 2, 2026 21:41
@ksurabhi91 ksurabhi91 requested a review from a team as a code owner March 2, 2026 21:41
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The grep -q "^${VERSION}$" check in check-scanner-version.sh treats VERSION as a regex, so versions with dots or other special characters may match incorrectly; consider using grep -Fx (or grep -F with manual line-boundary handling) to perform an exact string match instead.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `grep -q "^${VERSION}$"` check in `check-scanner-version.sh` treats `VERSION` as a regex, so versions with dots or other special characters may match incorrectly; consider using `grep -Fx` (or `grep -F` with manual line-boundary handling) to perform an exact string match instead.

## Individual Comments

### Comment 1
<location path=".github/workflows/scripts/check-scanner-version.sh" line_range="18" />
<code_context>
+SCANNER_VERSION=$(gh api -H "Accept: application/vnd.github.v3.raw" \
+  "/repos/${GITHUB_REPOSITORY}/contents/scanner/updater/version/RELEASE_VERSION?ref=master")
+
+if ! grep -q "^${VERSION}$" <<<"$SCANNER_VERSION"; then
+    gh_log error "Release version $VERSION (inferred from the tag '$TAG') not added to scanner/updater/version/RELEASE_VERSION in master branch"
+    gh_summary "Release version not found in scanner/updater/version/RELEASE_VERSION in master branch"
</code_context>
<issue_to_address>
**issue (bug_risk):** Use fixed-string matching for version to avoid regex semantics in grep.

`${VERSION}` is used as a grep regex here, so characters like `.` or `+` will be interpreted as metacharacters rather than literals, which can cause false matches or misses if version formats change. Prefer fixed-string, whole-line matching, e.g. `grep -Fqx -- "$VERSION" <<<"$SCANNER_VERSION"`, to avoid regex interpretation.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

SCANNER_VERSION=$(gh api -H "Accept: application/vnd.github.v3.raw" \
"/repos/${GITHUB_REPOSITORY}/contents/scanner/updater/version/RELEASE_VERSION?ref=master")

if ! grep -q "^${VERSION}$" <<<"$SCANNER_VERSION"; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Use fixed-string matching for version to avoid regex semantics in grep.

${VERSION} is used as a grep regex here, so characters like . or + will be interpreted as metacharacters rather than literals, which can cause false matches or misses if version formats change. Prefer fixed-string, whole-line matching, e.g. grep -Fqx -- "$VERSION" <<<"$SCANNER_VERSION", to avoid regex interpretation.

@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.63%. Comparing base (a590540) to head (ae0d19b).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #19260      +/-   ##
==========================================
- Coverage   49.63%   49.63%   -0.01%     
==========================================
  Files        2679     2679              
  Lines      202130   202130              
==========================================
- Hits       100328   100325       -3     
- Misses      94325    94327       +2     
- Partials     7477     7478       +1     
Flag Coverage Δ
go-unit-tests 49.63% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ksurabhi91 ksurabhi91 changed the title Add check to verify release version exists in scannver version file ROX-33413: Add check to verify release version exists in scannver version file Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants