DEV Community

jidonglab
jidonglab

Posted on

GitHub Actions paths Filter: Why Required Checks Stay Pending Forever

A one-line README fix sat open in my repo for three days. No red X, no failing test. Just a grey dot next to test that said "Expected — Waiting for status to be reported." Auto-merge was on. Nothing merged.

The cause was a GitHub Actions paths filter combined with a required status check. The filter did its job and skipped CI for a docs-only change. Branch protection did its job too, and waited for a check that was never going to arrive. Two correct features, one deadlocked pull request.

This is one of those GitHub Actions behaviours that is documented, reproducible, and still bites almost everyone who adds paths: to a workflow. Here is exactly why the required check stays pending, and the pattern I now use everywhere instead.

TL;DR

  • A workflow skipped by on.pull_request.paths, paths-ignore, a branch filter, or [skip ci] never creates a check run, so a required check with that name stays "Pending" forever and blocks the merge.
  • A job skipped by an if: condition is different: GitHub reports it as Success, and it satisfies a required check.
  • The fix: remove workflow-level paths, detect changes inside a job, skip the expensive jobs with if:, and make one always-running gate job the only required check.
  • Renaming a job or a matrix entry causes the same "Expected" deadlock, because required checks match by name.

Why does a GitHub Actions paths filter leave a required check pending?

Because a required status check is just a name that branch protection waits to see reported, and a workflow skipped by a paths filter never reports anything. GitHub doesn't record "skipped" for it. It records nothing. From branch protection's point of view, CI simply hasn't started yet.

Here was my workflow:

name: CI
on:
  pull_request:
    paths:
      - 'src/**'
      - 'package.json'
      - 'package-lock.json'

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npm test
Enter fullscreen mode Exit fullscreen mode

And in branch protection, test was marked as a required status check.

Open a PR that touches only README.md. The workflow trigger evaluates the changed files, none match, and the whole workflow is dropped before a runner is ever requested. No workflow run, no job, no check run named test. The PR shows test as "Expected" with no link to click, because there is no run to link to.

The same thing happens with paths-ignore, with branches filters, and with [skip ci] in the commit message. GitHub's own docs say it plainly: checks for a workflow skipped this way remain in a "Pending" state, and a PR that requires them is blocked.

Why does a job skipped with if: count as passing?

Because a job skipped by its if: condition still creates a check run, and that check run concludes as skipped, which GitHub treats as Success for required checks. The docs say a job skipped this way reports "Success" and will not prevent a pull request from merging, even if it is a required check.

That asymmetry is the whole trick:

How it was skipped Check run created? Required check result
Workflow paths / paths-ignore No Pending forever
Workflow branches filter No Pending forever
[skip ci] in commit message No Pending forever
Job-level if: evaluates false Yes Success

So the move is obvious once you see the table: stop skipping at the workflow level, and skip at the job level instead.

How do I skip CI for docs-only changes without blocking merges?

Run the workflow on every PR, decide inside a cheap first job whether code changed, and gate the expensive jobs with if:. Then make a single gate job the only required check.

Here is the version I use now:

name: CI
on:
  pull_request:

jobs:
  changes:
    runs-on: ubuntu-latest
    outputs:
      code: ${{ steps.filter.outputs.code }}
    steps:
      - uses: actions/checkout@v4
      - uses: dorny/paths-filter@v3
        id: filter
        with:
          filters: |
            code:
              - 'src/**'
              - 'package.json'
              - 'package-lock.json'

  test:
    needs: changes
    if: needs.changes.outputs.code == 'true'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npm test

  lint:
    needs: changes
    if: needs.changes.outputs.code == 'true'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npm run lint

  ci-ok:
    if: always()
    needs: [changes, test, lint]
    runs-on: ubuntu-latest
    steps:
      - name: Fail if any needed job failed or was cancelled
        if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
        run: exit 1
      - run: echo "CI gate passed"
Enter fullscreen mode Exit fullscreen mode

Then in branch protection (or your ruleset), remove test and lint from required checks and require only ci-ok.

dorny/paths-filter is a third-party action. If you'd rather not depend on it, a git diff --name-only against the base SHA in a shell step does the same job; you just need fetch-depth: 0 or an explicit fetch of the base branch so the diff has something to compare against.

Why do I need a separate gate job instead of requiring test directly?

Because a docs-only PR would work fine, but the moment changes itself fails, test gets skipped, and a skipped required job counts as Success. You'd merge a PR whose CI never actually ran.

The gate job closes that hole:

  • if: always() makes ci-ok run even when upstream jobs fail or skip. Without it, a failure upstream would skip ci-ok, and a skipped required job passes. That is the exact opposite of what you want.
  • needs.*.result gives you the result of every job in needs. A docs PR produces success, skipped, skipped, which passes. A real failure produces failure somewhere, and the gate exits 1.
  • changes is in the needs list on purpose. If the filter job breaks, the gate fails instead of quietly waving the PR through.

The other benefit is boring and real: you never edit branch protection again. Add a typecheck job next month, put it in ci-ok's needs, done. The required check list stays at one entry.

What else causes "Expected — Waiting for status to be reported"?

Renaming things. Required status checks are matched by check name, and for GitHub Actions that name is the job's name: (or its job ID if there's no name). Change test to unit-tests and every open PR now waits for a test check that no workflow produces anymore.

Matrix jobs are worse, because their check names include the matrix values:

jobs:
  test:
    strategy:
      matrix:
        node: [18, 20]
Enter fullscreen mode Exit fullscreen mode

That produces checks named test (18) and test (20). Bump the matrix to [20, 22] and test (18) becomes a required check that will never report again. Every PR blocks until someone updates branch protection. The gate-job pattern fixes this too, since the matrix lives behind ci-ok and its names stop mattering.

One more sharp edge from the name matching: if two workflows both have a job called test, either one reporting success can satisfy a required check named test. Old advice for this exact problem was to create a duplicate no-op workflow with the inverse paths-ignore and the same job name, so docs PRs got a fake green test. It works, but it's two files to keep in sync, and it means a trivial echo job can satisfy your most important check. I stopped doing that.

Doesn't running the workflow on every PR waste minutes?

A little, and much less than you'd think. A docs-only PR now starts the workflow, runs the changes job (a few seconds of a runner), skips test and lint without allocating a runner for them, and runs ci-ok for a few seconds. That's two tiny jobs instead of zero.

Compared with a PR blocked for three days, or someone with admin rights clicking "merge without waiting for requirements" until it becomes a habit, that's a cheap trade. The admin bypass habit is the real cost. Once people learn the button exists, they'll use it on a PR where CI actually mattered.

A quick checklist before you add paths: to a workflow

  1. Is any job in this workflow a required status check? If yes, don't put paths on the workflow trigger.
  2. Move the path logic into a changes job and gate jobs with if:.
  3. Add an if: always() gate job that fails on failure or cancelled in needs.*.result.
  4. Make the gate job the only required check.
  5. Keep job names stable, and never require matrix-expanded check names directly.

Workflow-level paths is still fine for workflows that are not required: a docs site deploy, a nightly benchmark, a label bot. The deadlock only exists when a required check depends on a workflow that might not start.

So why does the GitHub Actions paths filter leave required checks pending forever?

A GitHub Actions paths filter skips the entire workflow before any job is created, so no check run with the required name is ever reported, and branch protection waits for it indefinitely as "Expected — Waiting for status to be reported." Jobs skipped by a job-level if: behave differently: they create a check run, conclude as skipped, and count as Success. The reliable fix is to trigger the workflow on every pull request, detect changed paths inside a first job, skip expensive jobs with if:, and require only a single if: always() gate job that fails when any needed job failed or was cancelled.


Written by the developer behind Preterview, an interview prep platform.

Top comments (0)