Skip to content

INTPYTHON-1025 Add retrigger-ci action - #140

Merged
Jibola merged 17 commits into
mongodb-labs:mainfrom
aclark4life:INTPYTHON-1025-retrigger-ci
Oct 8, 2026
Merged

Jibola merged 17 commits into
mongodb-labs:mainfrom
aclark4life:INTPYTHON-1025-retrigger-ci

Conversation

@aclark4life

@aclark4life aclark4life commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

INTPYTHON-1025

Changes in this PR

Adds the retrigger-ci action. A downstream repository's CI pins a fork branch
at a ref, so a force-push changes what it builds against without re-triggering
anything.

ci_rerun maps each downstream owner/name to a target, and the value's type
selects the behaviour: a ref dispatches the test workflows, a PR number re-runs
that PR's runs, and the object form also retries Evergreen. See the README. The
shape matches the mapping the existing sync tooling uses, so one copies across
verbatim.

Re-triggering is best-effort. A stale PR number, a closed pull request, or an
API error warns and is skipped, so one bad entry cannot mask the branches that
re-triggered correctly.

Test Plan

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)?
  • Is the intention of the code captured in relevant tests?
  • If there are new TODOs, has a related JIRA ticket been created?

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Have you checked for spelling & grammar errors?
  • Is all relevant documentation (README or docstring) updated?

Re-run a downstream repository's CI after this repository changed
something it depends on, such as a force-pushed fork branch it checks
out by ref. Takes the downstream repo and a ci_rerun JSON spec with
three kinds: evergreen (retry comment on a pull request), pr (re-queue
the runs on a pull request head commit), and ref (dispatch the
workflows on a branch or tag).

The action mints the downstream-scoped App token itself, so callers
pass only app_id and private_key.
Reimplements `dbx sync --all-branches`'s downstream CI re-run, and takes
that command's ci_rerun config shape unchanged so a mapping copies
across verbatim instead of being translated.

The value's type selects the behaviour: a string dispatches the test
workflows on a ref, an integer re-runs every workflow run on a PR's head
commit, and {pr, evergreen} does the PR re-run and also comments
'evergreen retry'. Lists and several downstream repos are supported.

Re-triggering is best-effort, as in dbx: a stale PR number or an API
error warns and is skipped, so one bad entry cannot mask the branches
that re-triggered correctly.

Python rather than bash: the type dispatch, list handling, and
workflow_dispatch inspection were the parts hardest to review as shell.
@aclark4life aclark4life changed the title INTPYTHON-1025 Add retrigger-ci action INTPYTHON-1025 Add retrigger-ci action, porting dbx sync's CI re-run Sep 24, 2026
@aclark4life aclark4life changed the title INTPYTHON-1025 Add retrigger-ci action, porting dbx sync's CI re-run INTPYTHON-1025 Add retrigger-ci action Sep 24, 2026
- gh_error raised IndexError on whitespace-only stderr, which escapes
  Skip and aborts the run the best-effort handling exists to protect.
- A value that was neither a ref nor a {"pr": N} object parsed to
  nothing and exited clean, reporting success on an untested
  downstream. A digit-only string read as a git ref.
- The de-duplication the comment claimed did not exist, so a repeated
  entry dispatched twice and posted two identical comments.
- workflow_pattern went into the jq regex unescaped, so a '.' matched
  any character and could widen the scope past the test workflows.
- retry_evergreen treated a failed state lookup as open and commented
  on closed pull requests.
@aclark4life
aclark4life marked this pull request as ready for review September 24, 2026 21:57
@aclark4life
aclark4life requested a review from a team as a code owner September 24, 2026 21:57
Comment thread retrigger-ci/action.yml Resolved
Comment thread retrigger-ci/retrigger_ci.py Resolved
Comment thread retrigger-ci/retrigger_ci.py Resolved
Comment thread retrigger-ci/retrigger_ci.py Resolved
Comment thread retrigger-ci/action.yml Resolved
Comment thread retrigger-ci/test_retrigger_ci.py Resolved
Comment thread retrigger-ci/retrigger_ci.py Resolved
Comment thread retrigger-ci/retrigger_ci.py Resolved
Comment thread retrigger-ci/retrigger_ci.py Resolved
@aclark4life
aclark4life force-pushed the INTPYTHON-1025-retrigger-ci branch 2 times, most recently from a0d4e07 to 2e0d7f0 Compare October 7, 2026 22:08
Quote the workflow-filter regex for the jq string layer. The "\-" in
re.escape("test-python") is not a valid jq escape, so a ref dispatched nothing.

Grant the token contents:read, which reads each workflow definition at the ref,
and skip on 403 rather than dispatching blind into a 422.

Paginate a PR's workflow runs, warn when only some re-queue, and fail when
every entry was skipped.

Drop the retry-window string match: GitHub does not document the wording.

Run the built jq program under real jq in the tests.
@aclark4life
aclark4life force-pushed the INTPYTHON-1025-retrigger-ci branch from 2e0d7f0 to 209b95a Compare October 7, 2026 22:11
@aclark4life

Copy link
Copy Markdown
Collaborator Author

@GromNaN @connorsmacd Thanks! Latest review comments addressed in 209b95a

@aclark4life
aclark4life requested a review from GromNaN October 7, 2026 22:19

@GromNaN GromNaN left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved. The two blocking items from my review are fixed and verified: the jq program now compiles under real jq (the suite runs it, 20 passing) and the token grants contents: read.

Non-blocking follow-ups if you touch this again:

  • os.environ["CI_RERUN"] raises KeyError when unset; .get would be safer.
  • A few test cases were dropped (empty ci_rerun, duplicates, Evergreen on a closed PR), so that coverage is gone.
  • The tests stub gh, so live behavior (App permissions, actual dispatch) stays unvalidated until the end-to-end run on mongodb-forks/django#21.

@Jibola
Jibola merged commit db69c8c into mongodb-labs:main Oct 8, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants