Skip to content

wip#4990

Draft
Prucek wants to merge 1 commit intoopenshift:mainfrom
Prucek:prowgen-sparse
Draft

wip#4990
Prucek wants to merge 1 commit intoopenshift:mainfrom
Prucek:prowgen-sparse

Conversation

@Prucek
Copy link
Member

@Prucek Prucek commented Mar 6, 2026

Summary by CodeRabbit

Release Notes

  • Improvements
    • Enhanced repository checkout performance with sparse checkout functionality, enabling selective file retrieval to reduce cloning time and bandwidth usage.
    • Improved private repository authentication handling with better OAuth token configuration support.
    • Optimized configuration initialization for more flexible deployment scenarios.

@openshift-ci-robot
Copy link
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 6, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 6, 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

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 6, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Prucek

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 6, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 6, 2026

Walkthrough

This change introduces sparse checkout functionality to the job base configuration in ProwGen. It adds helper functions to determine which files require sparse checkout, modifies the cloning skip logic to depend on sparse checkout file count, updates DecorationConfig initialization to conditionally set SkipCloning and OauthTokenSecret fields, populates the SparseCheckoutFiles field, and reverses the FromRepository handling logic.

Changes

Cohort / File(s) Summary
Sparse Checkout Logic
pkg/prowgen/jobbase.go
Adds fromRepositorySet and sparseCheckoutFiles helper functions to identify and assemble files requiring sparse checkout. Modifies skipCloning to return true only when sparse checkout files are empty. Populates SparseCheckoutFiles in UtilityConfig.DecorationConfig. Changes FromRepository handling to return true when any buildRoot has FromRepository (reversing previous behavior). Updates ProwJob base initialization to set DecorationConfig fields conditionally for SkipCloning and OauthTokenSecret instead of replacing the entire DecorationConfig.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title "wip" is vague and generic, using a non-descriptive abbreviation that conveys no meaningful information about the actual changes (sparse checkout logic, DecorationConfig modifications, and FromRepository handling). Replace the vague title with a descriptive summary of the main change, such as 'Add sparse checkout support to ProwJob base configuration' or similar that clearly identifies the primary modification.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Stable And Deterministic Test Names ✅ Passed Pull request only modifies production code in pkg/prowgen/jobbase.go with no Ginkgo test declarations.
Test Structure And Quality ✅ Passed This pull request does not introduce or modify any Ginkgo test files, so the Test Structure and Quality requirements are not applicable to these changes.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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

Copy link

@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.

🧹 Nitpick comments (2)
pkg/prowgen/jobbase.go (2)

105-113: Compute sparse files once and reuse the derived skip decision.

This block recalculates sparse checkout data multiple times (also used again at Line 131 via skipCloning(configSpec)). A single computation improves consistency and avoids duplicate work.

Proposed simplification
-	if skipCloning(configSpec) {
+	sparseFiles := sparseCheckoutFiles(configSpec)
+	shouldSkipCloning := len(sparseFiles) == 0
+	if shouldSkipCloning {
 		b.base.UtilityConfig.DecorationConfig.SkipCloning = utilpointer.Bool(true)
 	} else if info.Config.Private {
 		b.base.UtilityConfig.DecorationConfig.OauthTokenSecret = &prowv1.OauthTokenSecret{Key: cioperatorapi.OauthTokenSecretKey, Name: cioperatorapi.OauthTokenSecretName}
 	}
 
-	sparseFiles := sparseCheckoutFiles(configSpec)
 	b.base.UtilityConfig.DecorationConfig.SparseCheckoutFiles = sparseFiles
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/prowgen/jobbase.go` around lines 105 - 113, Compute sparseFiles once and
cache the skip decision so we don't recompute; call
sparseCheckoutFiles(configSpec) into sparseFiles and call
skipCloning(configSpec) once into a local boolean (e.g. shouldSkip) before the
decoration config block, then use shouldSkip to set
b.base.UtilityConfig.DecorationConfig.SkipCloning and reuse that same variable
wherever skipCloning(configSpec) was used later (instead of calling skipCloning
again), keeping the existing OauthTokenSecret and SparseCheckoutFiles
assignments intact.

30-37: Avoid mutating input config while checking build-root flags.

buildRoots := configSpec.BuildRootImages aliases the original map, so writing to buildRoots[""] mutates configSpec.BuildRootImages. This helper should stay read-only.

Proposed refactor (pure check, no map writes)
 func fromRepositorySet(configSpec *cioperatorapi.ReleaseBuildConfiguration) bool {
-	buildRoots := configSpec.BuildRootImages
-	if buildRoots == nil {
-		buildRoots = make(map[string]cioperatorapi.BuildRootImageConfiguration)
-	}
-	if configSpec.BuildRootImage != nil {
-		buildRoots[""] = *configSpec.BuildRootImage
-	}
-	for _, buildRoot := range buildRoots {
+	if configSpec.BuildRootImage != nil && configSpec.BuildRootImage.FromRepository {
+		return true
+	}
+	for _, buildRoot := range configSpec.BuildRootImages {
 		if buildRoot.FromRepository {
 			return true
 		}
 	}
 	return false
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/prowgen/jobbase.go` around lines 30 - 37, fromRepositorySet currently
aliases and mutates the input map by doing buildRoots :=
configSpec.BuildRootImages and then writing buildRoots[""]; avoid mutating
configSpec. Either (a) treat the check as read-only by testing
configSpec.BuildRootImage != nil or checking for the empty key in
configSpec.BuildRootImages without writing to it, or (b) create a local copy
before any writes (e.g. make a new map, copy entries from
configSpec.BuildRootImages, then set the "" key if configSpec.BuildRootImage !=
nil). Update the logic in fromRepositorySet to use one of these approaches so
configSpec.BuildRootImages is never modified.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/prowgen/jobbase.go`:
- Around line 105-113: Compute sparseFiles once and cache the skip decision so
we don't recompute; call sparseCheckoutFiles(configSpec) into sparseFiles and
call skipCloning(configSpec) once into a local boolean (e.g. shouldSkip) before
the decoration config block, then use shouldSkip to set
b.base.UtilityConfig.DecorationConfig.SkipCloning and reuse that same variable
wherever skipCloning(configSpec) was used later (instead of calling skipCloning
again), keeping the existing OauthTokenSecret and SparseCheckoutFiles
assignments intact.
- Around line 30-37: fromRepositorySet currently aliases and mutates the input
map by doing buildRoots := configSpec.BuildRootImages and then writing
buildRoots[""]; avoid mutating configSpec. Either (a) treat the check as
read-only by testing configSpec.BuildRootImage != nil or checking for the empty
key in configSpec.BuildRootImages without writing to it, or (b) create a local
copy before any writes (e.g. make a new map, copy entries from
configSpec.BuildRootImages, then set the "" key if configSpec.BuildRootImage !=
nil). Update the logic in fromRepositorySet to use one of these approaches so
configSpec.BuildRootImages is never modified.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 273c2059-d1e2-4358-8dff-08f771048c4d

📥 Commits

Reviewing files that changed from the base of the PR and between 6a0a2b5 and c7cab84.

📒 Files selected for processing (1)
  • pkg/prowgen/jobbase.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants