Skip to content

Add check_merge_conflicts.py to simulate dependencies.yaml merges bef… - #270

Closed
Zubair Maalick (zmaalick) wants to merge 4 commits into
MetOffice:mainfrom
zmaalick:merge_conflict_check
Closed

Zubair Maalick (zmaalick) wants to merge 4 commits into
MetOffice:mainfrom
zmaalick:merge_conflict_check

Conversation

@zmaalick

@zmaalick Zubair Maalick (zmaalick) commented Dec 2, 2026 •

Copy link
Copy Markdown

Add check_merge_conflicts.py to simulate dependencies.yaml merges before extracting

PR Summary

Sci/Tech Reviewer:
Code Reviewer:

Adds github_scripts/check_merge_conflicts.py, a pre-flight check that simulates the dependencies.yaml merges done by merge_sources.py/get_git_sources.py using git merge-tree, without a working copy or compile, so conflicts are found in seconds before a suite is submitted.
For each repository it reports which branches have drifted onto newer releases than the base, the merge step where the extract would fail, the conflicting files by type (code/housekeeping/other) and which branch they clash with, and a suggested merge order.
By default it models the per-file CONFLICT_RULES resolution from #269 (--resolver legacy models the current CONFLICT_IGNORES behaviour). Exit status is 0 if the extract would succeed, 1 if it would fail or a branch has drifted, and 2 on errors.
Tested with 4 new unit tests on local repos, and against u-ed285 and o-ab147, where it reproduced the real extract failures (same failing step and files).
`

Once merged, we can add this script in rose-suite.conf as:

[file:bin/check_merge_conflicts.py]
source=git:localmirrors:MetOffice/SimSys_Scripts.git::github_scripts/check_merge_conflicts.py::main
`

Code Quality Checklist

  • I have performed a self-review of my own code
  • My code follows the project's style guidelines
  • Comments have been included that aid understanding and enhance the readability of the code
  • My changes generate no new warnings
  • All automated checks in the CI pipeline have completed successfully

Testing

  • This change has been tested appropriately (please describe)

Security Considerations

  • I have reviewed my changes for potential security issues
  • Sensitive data is properly handled (if applicable)
  • Authentication and authorisation are properly implemented (if applicable)

AI Assistance and Attribution

  • Some of the content of this change has been produced with the assistance of Generative AI tool name (e.g., Met Office Github Copilot Enterprise, Github Copilot Personal, ChatGPT GPT-4, etc) and I have followed the Simulation Systems AI policy (including attribution labels)

Sci/Tech Review

  • I understand this area of code and the changes being added
  • The proposed changes correspond to the pull request description
  • Documentation is sufficient (do documentation papers need updating)
  • Sufficient testing has been completed

(Please alert the code reviewer via a tag when you have approved the SR)

Code Review

  • All dependencies have been resolved
  • Related Issues have been properly linked and addressed
  • Code quality standards have been met
  • Tests are adequate and have passed
  • Security considerations have been addressed
  • Performance impact is acceptable

@zmaalick
Zubair Maalick (zmaalick) marked this pull request as draft December 2, 2026 09:21
@github-actions github-actions Bot added the cla-required The CLA has not yet been signed by the author of this PR - added by GA label Dec 2, 2026
@github-actions github-actions Bot added cla-signed The CLA has been signed as part of this PR - added by GA and removed cla-required The CLA has not yet been signed by the author of this PR - added by GA labels Dec 2, 2026
- Run the release check before simulating. A branch failing it is reported
  as fail-release but not merged, so later steps, the pairwise table and the
  merge-order search are checked without it, as they would be once it is
  removed or rebased. Previously its newer upstream changes were merged in
  and later branches were reported as conflicting with them.
- Only apply the release check with --resolver rules: the legacy
  get_git_sources.py has no release check, so drift is a warning there.
- Fetch each entry straight into its ref instead of reading FETCH_HEAD,
  which concurrent runs sharing the cache could overwrite.
- Fail early with a clear message if git is older than 2.38.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zmaalick

Copy link
Copy Markdown
Author

Closing this in favour of #269.

This PR added check_merge_conflicts.py, a stand-alone tool that simulated the dependencies.yaml merges with git merge-tree. While reviewing it, we found that simulating the merge separately from the real extract creates two copies of the merge logic, and they disagree. The conflict rules and release check had to be duplicated from get_git_sources.py, the tool couldn't use the local mirrors, and in one case it blamed later branches for conflicts caused by an earlier branch that the real extract would have rejected.

#269 now does the same job by reusing the extract's own merge code:

merge_sources.py --check runs the real merge in a scratch directory before a suite is submitted. It reports every problem in one run: branches that can't be fetched, branches based on a different release, and branches with unresolved conflicts. It exits 1 if any are found.
--pin writes a copy of dependencies.yaml with every branch pinned to the commit that was checked. If the suite uses that file, it merges exactly what was checked.
The extract_lfric task uses the same code, so it reports every problem in one run instead of stopping at the first.
This PR's pairwise conflict table, merge-order suggestion and JSON report aren't carried over. If they're needed later, for example for a nightly integration check, they can be added on top of the code in #269.

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

Labels

cla-signed The CLA has been signed as part of this PR - added by GA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant