Skip to content

WIP: Add Konflux pipeline for Go version validation#19737

Draft
janisz wants to merge 5 commits intomasterfrom
check_go_version
Draft

WIP: Add Konflux pipeline for Go version validation#19737
janisz wants to merge 5 commits intomasterfrom
check_go_version

Conversation

@janisz
Copy link
Copy Markdown
Contributor

@janisz janisz commented Apr 1, 2026

Description

Create a minimal, hermetic Konflux pipeline to verify Go version compatibility by running 'go mod tidy'.
This change was partially generated with AI assistance.

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

CI

Create a minimal, hermetic Konflux pipeline to verify Go version
compatibility by running 'go mod tidy'. The pipeline:

- Triggers automatically on PRs that modify go.mod (via labeler)
- Runs go mod tidy in the same Go environment as production builds
- Fails if go.mod or go.sum are modified by tidy (indicating version issues)
- Provides fast feedback (~2-5 min) compared to full builds (~1+ hour)
- Uses hermetic builds with Cachi2 dependency prefetching

Files:
- .github/labeler.yml: Add go-mod-check label for go.mod changes
- .tekton/go-mod-validation-pipeline.yaml: Pipeline definition with
  inline verify-go-mod-tidy task
- .tekton/go-mod-validation-build.yaml: PipelineRun with triggers

User request: Create a Konflux pipeline to check if the installed Go
version supports the version specified in go.mod, using go mod tidy
as the validation mechanism.

Note: Requires service account 'build-pipeline-go-mod-validation' to be
created by Konflux admins with access to quay.io/rhacs-eng/go-mod-validation.

This change was partially generated with AI assistance.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Apr 1, 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

@github-actions github-actions bot added area/ci konflux-build Run Konflux in PR. Push commit to trigger it. ai-review coderabbit-review labels Apr 1, 2026
@janisz janisz changed the title Add Konflux pipeline for Go version validation WIP: Add Konflux pipeline for Go version validation Apr 1, 2026
Copy link
Copy Markdown
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:

  • In the verify-go-mod-tidy script, cp go.sum go.sum.before will fail for modules that don't yet have a go.sum; consider guarding this copy and the subsequent diff with an if [ -f go.sum ] check so the task works for both cases.
  • The Slack notification message hardcodes the Konflux UI base URL; consider parameterizing the host (e.g., via a pipeline param) so the same pipeline can be reused across clusters or environments without edits.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the `verify-go-mod-tidy` script, `cp go.sum go.sum.before` will fail for modules that don't yet have a `go.sum`; consider guarding this copy and the subsequent `diff` with an `if [ -f go.sum ]` check so the task works for both cases.
- The Slack notification message hardcodes the Konflux UI base URL; consider parameterizing the host (e.g., via a pipeline param) so the same pipeline can be reused across clusters or environments without edits.

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

📝 Walkthrough

Walkthrough

This pull request introduces a new Tekton-based CI/CD pipeline for validating Go module tidiness. It adds GitHub PR labeler configuration to identify commits affecting go.mod, along with Tekton pipeline and pipeline-run manifests that orchestrate repository cloning, optional dependency prefetching, Go module validation, and notifications.

Changes

Cohort / File(s) Summary
GitHub PR Labeling
.github/labeler.yml
Added new labeler rule go-mod-check to automatically label pull requests when go.mod file changes.
Tekton Go Module Validation Pipeline
.tekton/go-mod-validation-pipeline.yaml, .tekton/go-mod-validation-build.yaml
Added Tekton pipeline and pipeline-run manifests. Pipeline orchestrates git cloning, optional Cachi2 dependency prefetching, go mod tidy validation (fails if files change), Slack notifications on failure, and BigQuery metrics reporting. Defines input parameters for git source, OCI artifacts, and cache configuration, with results for git URL, commit hash, and Go version.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description includes a clear explanation of changes and uses the required template structure. However, testing/validation checkboxes are unchecked and validation details are minimal.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The PR title clearly and specifically describes the main change: adding a Konflux pipeline for Go version validation. It is concise, directly related to the primary objective in the changeset, and a teammate scanning history would understand the key contribution.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch check_go_version

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/labeler.yml:
- Around line 97-100: The go-mod-check label currently triggers only when go.mod
changes (see label name "go-mod-check" and the "changed-files ->
any-glob-to-any-file -> - go.mod" entry); update that label's changed-files
pattern to include go.sum as well (add "- go.sum" alongside "- go.mod") so the
auto-trigger fires for changes to either file.

In @.tekton/go-mod-validation-pipeline.yaml:
- Around line 193-200: The current shell block silently continues if
/workspace/cachi2/cachi2.env is missing; change it to fail-fast by exiting with
a non-zero status when the file is not found. Modify the existing if/else that
checks /workspace/cachi2/cachi2.env so that the else branch echoes a clear error
(e.g., "ERROR: cachi2.env not found") and calls exit 1, ensuring the
PipelineRun/prefetch-input validation cannot be bypassed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 3e7c1a52-2e75-4261-913e-037c946bb74c

📥 Commits

Reviewing files that changed from the base of the PR and between ead673e and c578982.

📒 Files selected for processing (3)
  • .github/labeler.yml
  • .tekton/go-mod-validation-build.yaml
  • .tekton/go-mod-validation-pipeline.yaml

Comment on lines +97 to +100
go-mod-check:
- changed-files:
- any-glob-to-any-file:
- go.mod
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Include go.sum in the auto-trigger label.

The validation fails on drift in either go.mod or go.sum, but this label is only applied for go.mod. A PR that only updates go.sum will skip the new check entirely.

Suggested fix
 go-mod-check:
 - changed-files:
   - any-glob-to-any-file:
     - go.mod
+    - go.sum
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
go-mod-check:
- changed-files:
- any-glob-to-any-file:
- go.mod
go-mod-check:
- changed-files:
- any-glob-to-any-file:
- go.mod
- go.sum
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/labeler.yml around lines 97 - 100, The go-mod-check label currently
triggers only when go.mod changes (see label name "go-mod-check" and the
"changed-files -> any-glob-to-any-file -> - go.mod" entry); update that label's
changed-files pattern to include go.sum as well (add "- go.sum" alongside "-
go.mod") so the auto-trigger fires for changes to either file.

Comment on lines +193 to +200
if [ -f /workspace/cachi2/cachi2.env ]; then
echo "=== Sourcing Cachi2 environment ==="
set +u
source /workspace/cachi2/cachi2.env
set -u
else
echo "WARNING: cachi2.env not found, proceeding without hermetic environment"
fi
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Fail fast when cachi2.env is missing.

This check is supposed to validate the hermetic path, and the paired PipelineRun always supplies prefetch-input. Continuing without cachi2.env can turn a broken prefetch/configuration into a false green run.

Suggested fix
-          if [ -f /workspace/cachi2/cachi2.env ]; then
-            echo "=== Sourcing Cachi2 environment ==="
-            set +u
-            source /workspace/cachi2/cachi2.env
-            set -u
-          else
-            echo "WARNING: cachi2.env not found, proceeding without hermetic environment"
-          fi
+          if [ ! -f /workspace/cachi2/cachi2.env ]; then
+            echo "ERROR: cachi2.env not found; aborting because this validation must run hermetically"
+            exit 1
+          fi
+          echo "=== Sourcing Cachi2 environment ==="
+          set +u
+          source /workspace/cachi2/cachi2.env
+          set -u
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ -f /workspace/cachi2/cachi2.env ]; then
echo "=== Sourcing Cachi2 environment ==="
set +u
source /workspace/cachi2/cachi2.env
set -u
else
echo "WARNING: cachi2.env not found, proceeding without hermetic environment"
fi
if [ ! -f /workspace/cachi2/cachi2.env ]; then
echo "ERROR: cachi2.env not found; aborting because this validation must run hermetically"
exit 1
fi
echo "=== Sourcing Cachi2 environment ==="
set +u
source /workspace/cachi2/cachi2.env
set -u
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.tekton/go-mod-validation-pipeline.yaml around lines 193 - 200, The current
shell block silently continues if /workspace/cachi2/cachi2.env is missing;
change it to fail-fast by exiting with a non-zero status when the file is not
found. Modify the existing if/else that checks /workspace/cachi2/cachi2.env so
that the else branch echoes a clear error (e.g., "ERROR: cachi2.env not found")
and calls exit 1, ensuring the PipelineRun/prefetch-input validation cannot be
bypassed.

@rhacs-bot
Copy link
Copy Markdown
Contributor

Images are ready for the commit at c578982.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.11.x-512-gc578982594.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.60%. Comparing base (69c8f9f) to head (e6ab972).
⚠️ Report is 13 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #19737      +/-   ##
==========================================
+ Coverage   49.58%   49.60%   +0.01%     
==========================================
  Files        2756     2756              
  Lines      207951   208036      +85     
==========================================
+ Hits       103112   103187      +75     
- Misses      97177    97188      +11     
+ Partials     7662     7661       -1     
Flag Coverage Δ
go-unit-tests 49.60% <ø> (+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.

@janisz janisz removed the konflux-build Run Konflux in PR. Push commit to trigger it. label Apr 1, 2026
janisz and others added 2 commits April 1, 2026 12:33
The diff checking is unnecessary because go mod tidy will naturally fail
with a clear error if the Go version is incompatible:
  'go: go.mod requires go >= X.Y.Z (running go A.B.C)'

Changes:
- Keep Cachi2 prefetch task (required for hermetic dependency download)
- Keep artifact extraction and environment sourcing
- Remove file copying (cp go.mod go.mod.before)
- Remove diff checking logic
- Remove verbose error messages
- Simplify to just run go mod tidy and report success

This pipeline validates only: Can the installed Go version run go mod tidy?
Other CI jobs check whether go.mod/go.sum are properly tidied.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The build-pipeline-go-mod-validation service account hasn't been created yet.
Temporarily use build-pipeline-roxctl to test the pipeline logic.

TODO: Request the dedicated service account from Konflux admins:
  Name: build-pipeline-go-mod-validation
  Namespace: rh-acs-tenant
  Copy permissions from: build-pipeline-roxctl

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions github-actions bot added the konflux-build Run Konflux in PR. Push commit to trigger it. label Apr 1, 2026
janisz and others added 2 commits April 1, 2026 13:44
The build-pipeline-roxctl service account only has write access to
quay.io/rhacs-eng/release-roxctl, not go-mod-validation.

Temporarily use release-roxctl for storing OCI artifacts (git clone
and Cachi2 prefetch results).

TODO: Once dedicated service account is created, change back to
quay.io/rhacs-eng/go-mod-validation

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The openshift-golang-builder image doesn't include oras, which is needed
to extract OCI artifacts. Install it at runtime from GitHub releases.

This adds ~5 seconds to the pipeline but avoids needing a custom image.

Alternative considered: Create a custom Dockerfile with oras pre-installed,
but that adds maintenance overhead for a simple validation pipeline.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

/konflux-retest go-mod-validation-on-push

2 similar comments
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

/konflux-retest go-mod-validation-on-push

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

/konflux-retest go-mod-validation-on-push

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

/konflux-retest operator-bundle-on-push

2 similar comments
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

/konflux-retest operator-bundle-on-push

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

/konflux-retest operator-bundle-on-push

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