Rebuild scoped Rector after a pull request is merged#962
Merged
Conversation
Port of rectorphp/rector-phpunit#730 and #731. Merging a rule pull request here only reaches rectorphp/rector once something else lands in rector-src main and retriggers its build. This dispatches that build directly. The tag check skips the dispatch when rector-src main sits on a release tag commit, which the tag build is already publishing, to avoid racing it for the push to rectorphp/rector.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port of rectorphp/rector-phpunit#730 and rectorphp/rector-phpunit#731 to this repository.
Merging a rule pull request here changes
rectorphp/rectoronly once something else lands inrector-srcmain and retriggers its build. This dispatches that build directly instead.New
.github/workflows/dispatch_build_scoped_rector.yaml, identical to therector-phpunitone except for the repository guard:pull_request: closedfires on every close, so themerged == truecheck is what limits it to merges. Closed-without-merge dispatches nothing. Reuses theACCESS_TOKENsecret already used byrector.yaml.yml.Tag check
Carried over from rector-phpunit#731. When
rector-srcmain sits on a release tag commit, that commit is already being published torectorphp/rectorby the tag build. Dispatching a second build makes the two race each other forgit push origin main, and the loser fails on a non fast forward push.git ls-remote --tagsis used rather than the tags API becausegit/refs/tagsexposes the sha of the tag object for an annotated tag, not of the commit, so a comparison against a commit sha silently never matches.ls-remotelists a lightweight tag with the commit itself and an annotated tag with an extra^{}line, so matching on line start covers both.Verified
Preconditions checked against live repositories rather than assumed:
build_scoped_rector.yamlinrector-srccarriesworkflow_dispatch: null, commented "allows rector-* package repositories to rebuild after their pull request is merged", sogh workflow runresolves here. (This was the HTTP 422 blocker in rector-phpunit#730; Allow dispatching Build Scoped Rector manually rector-src#8188 has since landed.)ACCESS_TOKENalready exists in this repository, used byrector.yaml.yml.The tag-check script was run as is against live
rector-src:c607ef0, untagged, writes no output, so the dispatch runs2.5.7(653ec23), detected, writestagged=true, so the dispatch is skippedTwo things worth confirming before merging
ACCESS_TOKENneedsactions: writeonrectorphp/rector-src.rector.yaml.ymlonly uses it to push to this repository, so cross-repository scope is unconfirmed here just as it was in rector-phpunit#730 — if that has since been verified forrector-phpunit, the same token settings apply and this is a non-issue.The dispatch fires at merge time, but the build resolves
rector-symfonydev-mainthrough Packagist, which can lag a merge by a few minutes. A dispatched build may rebuild against the previousmain. A Packagist update hook on this repository is the fix; not included here.