Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@ concurrency:
cancel-in-progress: true

jobs:
# Detect whether this PR/push touches code that mutation testing covers.
# Infection is expensive, so the `infection` job below runs only when src/
# or test/ changed — a docs-only or config-only change skips it.
changes:
name: Detect code changes
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
Comment thread
math3usmartins marked this conversation as resolved.
id: filter
with:
filters: |
code:
- 'src/**'
- 'test/**'
Comment on lines +29 to +36

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Shallow clone may force extra fetches on push-to-main

For pull_request events, dorny/paths-filter uses the GitHub API (no git history needed), so the current setup is perfectly correct there. For push events to main, the action needs to compare against github.event.before, which isn't present in the default fetch-depth: 1 shallow clone. The action recovers by calling git fetch --deepen in a loop until the merge-base is found, but this adds unnecessary network round-trips on every push to main. Adding fetch-depth: 0 to the checkout step (or setting the base input) avoids the extra fetching and makes the behavior explicit.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Declining. Accurate that on push to main, dorny deepens the shallow clone to reach github.event.before.

But the suggested fix trades the wrong way:

  • On pull_request: the event that actually gates mutation on feature branches — dorny uses the GitHub API and touches no git history, so the shallow checkout is already optimal (fetch-depth is irrelevant there).
  • On push to main, before is the previous tip, so it's typically 1–2 incremental fetches. That's trivial.
  • fetch-depth: 0 clones the entire history on every run (all PRs and pushes), including the PR runs where dorny doesn't use git at all.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You're right. The trade-off math is clearly against fetch-depth: 0 — paying a full history clone on every PR (where dorny never touches git) just to save 1–2 incremental fetches on push-to-main is the wrong direction. The current shallow checkout is the better default. Thanks for the clear breakdown.


phpunit:
# 8.4 is the supported/default runtime and runs the full suite minus the
# `php85` group; a dedicated 8.5 container runs only that group, which
Expand Down Expand Up @@ -116,7 +137,10 @@ jobs:
infection:
name: Mutation testing
runs-on: ubuntu-latest
needs: phpunit
# Only after unit tests pass, and only when src/ or test/ changed
# (see the `changes` job) — mutation is skipped for docs/config-only work.
needs: [phpunit, changes]
if: needs.changes.outputs.code == 'true'
steps:
- uses: actions/checkout@v4

Expand Down
Loading