-
Story
-
Resolution: Done
-
Normal
-
None
-
None
-
None
Story (Required)
As a developer trying to test PR changes, I want the PR to be automatically merged with the target branch so that I can verify my changes will work with the latest code without having to manually rebase.
This story improves the developer experience by ensuring tests run against what will actually exist after the PR is merged, not just the isolated PR branch. This reduces the need for manual rebasing and repeat testing.
Background (Required)
When Konflux jobs run tests on PR branches, they currently test the PR branch code in isolation, without merging or rebasing against the target branch. This causes issues when:
1. Another PR is merged while a PR is still in review
2. Tests pass on the isolated branch but fail after merge due to incompatibilities
3. CVE fixes in the main branch aren't reflected in test results
4. Developers need to manually rebase frequently to pick up changes
This is different from the behavior of Prow jobs which test PRs after merging with the target branch.
Out of scope
- Implementing a full merge queue system
- Automatically rebasing branches outside of CI pipeline runs
- Changing the process for merging PRs after approval
Approach (Required)
Modify the git-clone task to add the capability to merge the target branch into the PR branch during CI pipeline execution:
1. Add two new parameters to the git-clone task:
- `mergeTargetBranch` - Boolean flag to enable/disable the feature (default: "false")
- `targetBranch` - The branch to merge into the checked-out code (default: "main")
2. Add a new result output:
- `merged_sha` - The SHA of the commit after merging
3. Update the task's clone script to:
- Check if merging is enabled
- Fetch the target branch
- Perform the merge with appropriate git configuration
- Handle merge conflicts appropriately
- Output the new SHA
4. Make the changes backward compatible so existing pipelines continue to work without modification
Dependencies
- Konflux pipeline infrastructure
- git-clone task in build-definitions repository
- Working git operations within pipeline containers
Acceptance Criteria (Mandatory)
- The git-clone task supports the new mergeTargetBranch parameter which defaults to "false" for backward compatibility
- When mergeTargetBranch is set to "true", the task successfully merges the target branch into the PR branch
- The task correctly handles merge conflicts by failing the pipeline with appropriate error messages
- The merged_sha result is available for downstream tasks to use
- The implementation works with both private and public repositories
- Successful merge operations include a proper commit message indicating the merge action
- Documentation for how to enable the feature in Konflux pipelines is provided