Skip to content

.github: add automerge script and workflow for upstream sync - #209

Merged
lumachad merged 2 commits into
amd-stagingfrom
users/lumachad/automerge_2
Aug 26, 2026
Merged

.github: add automerge script and workflow for upstream sync#209
lumachad merged 2 commits into
amd-stagingfrom
users/lumachad/automerge_2

Conversation

@lumachad

@lumachad lumachad commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Make the automerge script fully generic: repo slug, target branch, and upstream branch are read from required repository variables (AUTOMERGE_TARGET_BRANCH, AUTOMERGE_UPSTREAM_BRANCH) instead of being hardcoded. The script exits with an error if any are unset.
  • Push conflict-free branches by direct refspec to avoid local merge commits.
  • Add --dry-run mode: fetches and probes normally but skips all pushes and PR creation, printing what it would do instead (branch name, commit range, PR title, and conflicted files if applicable).
  • Wire --dry-run to a boolean workflow_dispatch input so it can be toggled from the Actions UI.
  • Use "conflict-free" instead of "fast-forward" throughout: the script merges rather than pointer-advances, so the old term was misleading.
  • Activate the workflow: remove the if: false guard and enable the schedule and workflow_dispatch triggers. The pull_request trigger has been dropped in favour of relying solely on the 6-hour schedule.

Repository variables required before merge

  • AUTOMERGE_TARGET_BRANCH — branch to merge into (e.g. amd-staging)
  • AUTOMERGE_UPSTREAM_BRANCH — upstream branch to pull from (e.g. master)

Test plan

  • Trigger manually from the Actions UI with dry-run checked — verify no pushes or PRs are created, output shows what would happen
  • Trigger manually with dry-run unchecked — verify origin/master is updated and a conflict-free or conflict PR is opened
  • Unit tests pass: python3 -m pytest .github/scripts/test_automerge.py

@lumachad lumachad self-assigned this Jul 14, 2026
@lumachad lumachad added the ci:skip Skip all pre-commit / CI jobs while the label is up label Jul 14, 2026
@lumachad
lumachad force-pushed the users/lumachad/automerge_2 branch 3 times, most recently from 848c3fb to 9dfe6b8 Compare July 20, 2026 11:47
@lumachad lumachad changed the title .github: add dry-run input to automerge workflow .github: add generic automerge script with dry-run support Jul 20, 2026
@lumachad
lumachad force-pushed the users/lumachad/automerge_2 branch from 9dfe6b8 to b709061 Compare July 20, 2026 12:18
@lumachad
lumachad marked this pull request as ready for review July 20, 2026 12:18
@lumachad
lumachad requested a review from a team as a code owner July 20, 2026 12:18
@lumachad lumachad assigned lancesix and unassigned lumachad Jul 20, 2026
@lumachad
lumachad force-pushed the users/lumachad/automerge_2 branch from b709061 to a281154 Compare July 21, 2026 16:12
@lumachad

Copy link
Copy Markdown
Collaborator Author

Updated to do a general FF -> conflict-free merge renaming.

@lumachad lumachad assigned spatrang and unassigned lancesix Aug 24, 2026

@spatrang spatrang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary

Nice improvement — generic config, dry-run wiring, conflict-free naming, and enabling the workflow all look solid.

Action items before merge:

  • Fix dry-run fall-through in §7b (bug)
  • Confirm repo variables are configured
  • Update tests/docs for renamed API (this PR or immediate follow-up)

Comments on files not changed in this PR

.github/scripts/test_automerge.py — renamed symbols

test_automerge.py still references removed/renamed APIs: find_open_ff_pr, open_ff_pr, push_master_mirror. Please update to find_open_conflict_free_pr, open_conflict_free_pr, and push_upstream_mirror in this PR or an immediate follow-up.

.github/scripts/test_automerge.py ~L203–221 — merge abort test expectation

test_cleanup_runs_even_when_abort_raises expects probe_clean_prefix to raise when merge --abort fails. This PR changed abort to check=False (automerge.py L378), so cleanup completes and the function returns instead of raising. Please update the test to assert cleanup still runs and (last_clean, first_conflict) is returned correctly.

.github/scripts/test_automerge.py ~L344–351 — missing dry-run regression test

TestDryRun.test_dry_run_partial_prefix_skips_push_and_pr mocks probe_result=("aaa", "bbb") but does not assert that conflict PR dry-run output is not printed. Once the §7b return is fixed, please add an assertion that only the conflict-free dry-run path runs for partial prefix.

.github/scripts/automerge.md — documentation out of date

Documentation still describes hardcoded amd-staging/master, "fast-forward" terminology, and old branch prefixes/constants. Please update to match configurable branches, conflict-free naming, dry-run, and required repo variables.

Comment thread .github/scripts/automerge.py
Comment thread .github/scripts/automerge.py
Comment thread .github/scripts/automerge.py Outdated
Comment thread .github/workflows/automerge.yml Outdated
Comment thread .github/workflows/automerge.yml Outdated
@lumachad
lumachad force-pushed the users/lumachad/automerge_2 branch from 01cc268 to cf2bd3f Compare August 25, 2026 12:07
@lumachad lumachad changed the title .github: add generic automerge script with dry-run support .github: add automerge script and workflow for upstream sync Aug 25, 2026
@lumachad lumachad removed the ci:skip Skip all pre-commit / CI jobs while the label is up label Aug 25, 2026
@lumachad
lumachad requested a review from spatrang August 25, 2026 12:14

@spatrang spatrang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Second-round review

All first-round items are addressed. Unit tests pass (19 tests).

First-round item Status
§7b dry-run missing return Fixed (L549)
Import-time env vars break tests Fixed — _load_automerge() injects _TEST_ENV
Tests still used old APIs (find_open_ff_pr, open_ff_pr, push_master_mirror) Fixed
Abort test expected a raise after check=False Fixed — test_cleanup_runs_even_when_abort_fails asserts return values + cleanup
Dry-run partial-prefix missing conflict-path assertion Fixed — mock_conflict_pr.assert_not_called()
automerge.md out of date Fixed
Direct refspec push Confirmed intentional
Broad pull_request trigger Resolved by dropping the trigger; schedule + workflow_dispatch only
Repo variables must be set before merge Confirmed (AUTOMERGE_TARGET_BRANCH=amd-staging, AUTOMERGE_UPSTREAM_BRANCH=master)

Pre-merge reminder (not a code change): set those two repository variables before the scheduled job starts running.

LGTM.

@lumachad
lumachad force-pushed the users/lumachad/automerge_2 branch from 5e0fee4 to 3c14c1f Compare August 26, 2026 08:37
@lumachad lumachad added the ci:skip Skip all pre-commit / CI jobs while the label is up label Aug 26, 2026
@lumachad
lumachad force-pushed the users/lumachad/automerge_2 branch 2 times, most recently from 938488b to 4905fd6 Compare August 26, 2026 10:06
Adds automerge.py, which fetches ROCgdb upstream commits, probes them
for merge conflicts against the target branch, and opens either a
conflict-free PR or a conflict PR for manual resolution. Dry-run mode
skips all pushes and PR creation.

Also adds test_automerge.py with unit tests covering run(), run_net(),
probe_clean_prefix(), find_open_conflict_pr/conflict_free_pr, early-exit
gating, and dry-run behavior for all three outcome paths.
Schedules automerge.py to run every 6 hours and exposes a workflow_dispatch
trigger with an optional dry-run input. The job uses repository variables
AUTOMERGE_TARGET_BRANCH and AUTOMERGE_UPSTREAM_BRANCH so the target and
upstream branches are configurable without touching the workflow file.
@lumachad
lumachad force-pushed the users/lumachad/automerge_2 branch from 4905fd6 to 319a093 Compare August 26, 2026 10:37
@lumachad
lumachad merged commit 356ac50 into amd-staging Aug 26, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:skip Skip all pre-commit / CI jobs while the label is up

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants