Skip to content

Conversation

ayushsatyam146
Copy link
Member

@ayushsatyam146 ayushsatyam146 commented Aug 12, 2025

Changes

The existing TaskRun generation logic was concentrated in a single monolithic
GenerateTaskRun function, making it difficult to maintain, test, and debug
individual configuration aspects. This created tight coupling and poor separation
of concerns.

Decomposed the monolithic GenerateTaskRun into a comprehensive function.
orchestrated by smaller, single-responsibility helper functions. Each
configuration aspect now has its own dedicated applyXFeature* function.
This approach enables better error isolation, easier unit testing of individual
components, and clearer code organization. Enhanced error messages now provide
specific context about which BuildRun and strategy caused failures, improving
debugging experience for operators.

Key architectural changes:

  • Made GenerateTaskRun as the main entry point and removed the GenerateTaskSpec
  • Extracted applyNodeSelectors, applyTolerations, applyScheduler functions
  • Renamed addBuildStrategySteps → applyBuildStrategySteps for consistency
  • Renamed addStrategyParametersToTaskSpec → applyStrategyParametersToTaskSpec
  • Introduced initializeTaskRun, buildTaskSpec, and createBaseTaskSpec helpers
  • Improved error messages with BuildRun and strategy context

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Set a kind label on this PR
  • Release notes block has been filled in, or marked NONE

See the contributor guide
for details on coding conventions, github and prow interactions, and the code review process.

Release Notes

NONE

@openshift-ci openshift-ci bot added the release-note Label for when a PR has specified a release note label Aug 12, 2025
@pull-request-size pull-request-size bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Aug 12, 2025
@openshift-ci openshift-ci bot requested review from apoorvajagtap and rxinui August 12, 2025 11:30
@ayushsatyam146 ayushsatyam146 marked this pull request as draft August 12, 2025 11:31
@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 Aug 12, 2025
@openshift-ci openshift-ci bot added release-note-none Label for when a PR does not need a release note and removed release-note Label for when a PR has specified a release note labels Aug 13, 2025
@ayushsatyam146 ayushsatyam146 marked this pull request as ready for review August 14, 2025 09:31
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 14, 2025
@openshift-ci openshift-ci bot requested review from dorzel and qu1queee August 14, 2025 09:32
@adambkaplan adambkaplan linked an issue Aug 14, 2025 that may be closed by this pull request
1 task
@ayushsatyam146
Copy link
Member Author

/retest

@ayushsatyam146 ayushsatyam146 force-pushed the taskrun-refactor branch 2 times, most recently from c3e3921 to 1c25d88 Compare August 21, 2025 08:12
@ayushsatyam146 ayushsatyam146 changed the title chore: Refactor taskrun generation logic to be modular and follow SOLID principles chore: Refactor GenerateTaskRun with improved modularity and naming consistency Aug 21, 2025
@hasanawad94
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 21, 2025
@adambkaplan adambkaplan added this to the release-v0.17.0 milestone Aug 21, 2025
@adambkaplan adambkaplan moved this to In Progress in Shipwright Overview Aug 21, 2025
@adambkaplan adambkaplan self-assigned this Aug 25, 2025
@adambkaplan
Copy link
Member

@ayushsatyam146 PR needs rebase, looks like there is a merge conflict with one of the test files.

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 26, 2025
Copy link
Contributor

openshift-ci bot commented Aug 26, 2025

New changes are detected. LGTM label has been removed.

@ayushsatyam146
Copy link
Member Author

Hi @adambkaplan I resolved the merge conflict here, PTAL thanks!

Copy link
Member

@adambkaplan adambkaplan left a comment

Choose a reason for hiding this comment

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

First off, I want to commend you @ayushsatyam146 for this submisssion. The refactored form of taskrun.go is much clearer to read and will make it easier to add future contributions. I especially like that the features which apply to the TaskRun as a whole (node selector, annotations, etc.) are separated from features that apply to specific build steps (obtaining source code, processing the output image, etc.).

The refactor in taskrun_test.go likewise adds coverage that was missing and/or makes it clearer which behaviors are being verified at the "unit" level. In particular, the following test cases are improved:

  • Handling of parameter types + defaults
  • Handling of volumes (definition, overrides)
  • Checks that verify the image processing step is included

That said, it appears there are a few checks in the original code that are missing. Given that we want to release v0.17.0 soon, this PR as is presents a risk due to removed test coverage. Based on my analysis (with the help of Cursor), a few checks were removed:

  • Verify the arguments passed to the image-processing step
  • Verify the existence of the source clone step and its arguments
  • Verify the compute resources are correctly specified in the TaskRun

I tried to identify these specific missing tests/checks in my comments.

@adambkaplan
Copy link
Member

/approve

Green-lighting this as a "feature" to be added.

/hold

The size of change, and impact on test coverage, presents a risk to the release. My vote is to hold this PR until after the release, at which point we can merge it early in the v0.18.0 lifecycle.

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 26, 2025
Copy link
Contributor

openshift-ci bot commented Aug 26, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adambkaplan

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

The pull request process is described here

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 Aug 26, 2025
@adambkaplan
Copy link
Member

/hold cancel

v0.17.0 is released!

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 28, 2025
The existing TaskRun generation logic was concentrated in a single monolithic
GenerateTaskRun function, making it difficult to maintain, test, and debug
individual configuration aspects. This created tight coupling and poor separation
of concerns.

Decomposed the monolithic GenerateTaskRun into a comprehensive function.
orchestrated by smaller, single-responsibility helper functions. Each
configuration aspect now has its own dedicated applyXFeature* function.
This approach enables better error isolation, easier unit testing of individual
components, and clearer code organization. Enhanced error messages now provide
specific context about which BuildRun and strategy caused failures, improving
debugging experience for operators.

Key architectural changes:
- Made GenerateTaskRun as the main entry point and removed the GenerateTaskSpec
- Extracted applyNodeSelectors, applyTolerations, applyScheduler functions
- Renamed addBuildStrategySteps → applyBuildStrategySteps for consistency
- Renamed addStrategyParametersToTaskSpec → applyStrategyParametersToTaskSpec
- Introduced initializeTaskRun, buildTaskSpec, and createBaseTaskSpec helpers
- Improved error messages with BuildRun and strategy context

Signed-off-by: Ayush Satyam <[email protected]>
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. release-note-none Label for when a PR does not need a release note size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

[FEATURE] Use PipelineRuns for Builds (experimental)
3 participants