ci: run tests and phpstan on pull requests - #19
Merged
Conversation
Both workflows only triggered on push, so a pull request from a fork ran no tests and no static analysis at all: the checks appeared on the branch after a merge, which is the wrong side of the decision. That matters more than usual here because dependabot-auto-merge.yml runs on pull_request_target and calls `gh pr merge --auto` for every semver minor and patch bump, so dependency updates could reach main without a single test having run against them. Push is now scoped to main, so a branch that has a pull request open gets one run rather than two.
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.
Problem
run-tests.ymlandphpstan.ymlboth trigger onpushonly:No
pull_request. For a branch pushed to this repository the checks still show up, because the push itself fires them. But:main.That second point has teeth here because of
dependabot-auto-merge.yml:Every semver-minor and semver-patch bump is queued for auto-merge.
--autowaits for whatever checks branch protection makes required — and a workflow that never runs on the pull request cannot be a required check on it. So dependency updates can land onmainwithout a single test having run against them.Fix
Add
pull_requestto both workflows, with the same path filters.pushis narrowed tobranches: [main]at the same time. Without that, pushing to a branch that already has a PR open fires both triggers and runs the 16-job matrix twice for nothing. With it: pull requests are tested before merge,mainis tested after, and nothing runs twice.Deliberately unchanged
fix-php-code-style-issues.ymlstays onpushonly. It commits its fixes back withstefanzweifel/git-auto-commit-action, which needs write access to the branch — it cannot push to a fork's branch, so running it onpull_requestwould just fail, andpull_request_targetwould mean checking out and running untrusted code with a writable token. Formatting onmainafter merge is the right place for it.Still needs doing by hand
This PR makes the checks run on pull requests. It cannot make them required — that is branch protection on
main, configured in the repository settings, not in a workflow file. Untilrun-testsandphpstanare marked as required status checks there,gh pr merge --autohas nothing to wait for and the dependabot auto-merge gap stays open.Worth considering separately: a
concurrencygroup keyed on the ref, so pushing twice to a PR cancels the superseded run instead of leaving 16 jobs to finish. Left out here to keep the diff to the triggers.Verified
Both files pass
yaml-lint. No job definitions touched, only theon:blocks.