Skip to content

ci(root): add path filters to skip irrelevant jobs per PR#9041

Open
gokulhost wants to merge 2 commits into
masterfrom
gokuldevaraju330/wcn-974-ci-add-path-filters-to-skip-irrelevant-jobs-per-pr
Open

ci(root): add path filters to skip irrelevant jobs per PR#9041
gokulhost wants to merge 2 commits into
masterfrom
gokuldevaraju330/wcn-974-ci-add-path-filters-to-skip-irrelevant-jobs-per-pr

Conversation

@gokulhost

@gokulhost gokulhost commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a changes job using dorny/paths-filter that detects which file groups changed on a PR. Downstream jobs declare needs: [changes] and skip when their relevant files are untouched. An all-checks umbrella job aggregates all results so branch protection has a single, reliable gate.

How it works

flowchart TD
    PR([pull_request event]):::event --> changes

    changes["changes\ndorny/paths-filter\n─────────────────\noutputs: source / docker / vendor"]:::filter

    changes -->|source=true| unit-test
    changes -->|source=true| browser-test
    changes -->|docker=true| docker-build
    changes -->|docker=true| dockerfile-check
    changes -->|vendor=true| verify-vendor-integrity
    changes -. always runs .-> verify-npm-packages
    changes -. always runs .-> code-quality

    unit-test:::job --> all-checks
    browser-test:::job --> all-checks
    docker-build:::job --> all-checks
    dockerfile-check:::job --> all-checks
    verify-vendor-integrity:::job --> all-checks
    verify-npm-packages:::job --> all-checks
    code-quality:::job --> all-checks
    changes --> all-checks

    all-checks{"all-checks\nif: always()\n──────────────────────────────\n✅ pass → all results are success or skipped\n❌ fail → any result is failure or cancelled"}:::gate

    classDef event fill:#6366f1,color:#fff,stroke:none
    classDef filter fill:#0ea5e9,color:#fff,stroke:none
    classDef job fill:#64748b,color:#fff,stroke:none
    classDef gate fill:#16a34a,color:#fff,stroke:none
Loading

On push to master or workflow_dispatch, the changes job is skipped (its if: condition excludes non-PR events). Every downstream job sees needs.changes.result == 'skipped' and runs unconditionally — full CI on every master merge, no exceptions.

What skips and when (PR events only)

Job Skips when
unit-test (×3 Node versions) only Dockerfile, .dockerignore, .github/**, renovate.json, etc. changed
browser-test same as above
docker-build no Dockerfile, .dockerignore, or modules/** changes
dockerfile-check same as docker-build
verify-vendor-integrity no modules/argon2/** changes
code-quality never skipped
verify-npm-packages never skipped

Why all-checks is secure

all-checks explicitly needs: [changes]. This means:

  • If a test job fails → its result is failure → jq check rejects it → all-checks fails ❌
  • If a test job is skipped by path filter → result is skipped → jq check accepts it → all-checks passes ✅
  • If changes itself errors → its result is failure (not skipped) → all-checks catches it and fails ❌

GitHub job results are exactly one of success | failure | cancelled | skipped. Only success and skipped pass. A real failure can never sneak through.

Required: branch protection update (admin action)

Branch protection currently requires the individual job names. To make this work, a repo admin needs to replace those with all-checks as the single required check. The individual jobs still run and report status — they just aren't the merge gate anymore.

Expected savings on infra-only PRs

Before: ~12 min wall time (blocked on docker-build + browser-test + unit-test ×3)
After: ~3 min wall time (only changes + code-quality + verify-npm-packages run)

Test plan

  • Open a PR touching only Dockerfile — verify unit-test and browser-test are skipped, docker-build runs, all-checks passes
  • Open a PR touching only modules/sdk-core/src — verify docker-build is skipped, unit-test and browser-test run, all-checks passes
  • Force-fail a test job — verify all-checks fails and blocks merge
  • Merge to master — verify all jobs run unconditionally

Closes WCN-974

@gokulhost gokulhost requested review from a team as code owners June 16, 2026 20:51
@gokulhost gokulhost requested review from Marzooqa and bdesoky June 16, 2026 20:51
@linear-code

linear-code Bot commented Jun 16, 2026

Copy link
Copy Markdown

WCN-974

@gokulhost gokulhost force-pushed the gokuldevaraju330/wcn-974-ci-add-path-filters-to-skip-irrelevant-jobs-per-pr branch from 804ece5 to 0c1ac17 Compare June 16, 2026 21:00
Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml
@gokulhost gokulhost force-pushed the gokuldevaraju330/wcn-974-ci-add-path-filters-to-skip-irrelevant-jobs-per-pr branch from 0c1ac17 to 0d1ba26 Compare June 16, 2026 22:01
@gokulhost gokulhost requested a review from zahin-mohammad June 16, 2026 23:50
zahin-mohammad
zahin-mohammad previously approved these changes Jun 17, 2026
Adds a `changes` job using dorny/paths-filter to detect which file
groups changed. Downstream jobs skip when their files are unaffected:

- unit-test, browser-test: skip when only Dockerfile/infra files change
- docker-build, dockerfile-check: skip when only source modules change
- verify-vendor-integrity: skip when modules/argon2 is untouched
- code-quality, verify-npm-packages: always run

On push to master and workflow_dispatch the changes job is skipped,
causing all downstream jobs to run unconditionally via the
`needs.changes.result == 'skipped'` guard.

Action pinned to SHA (fbd0ab8f # v4.0.1) matching internal convention
used in bitgo-retail and mobile-native.

Ref: WCN-974

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gokulhost gokulhost force-pushed the gokuldevaraju330/wcn-974-ci-add-path-filters-to-skip-irrelevant-jobs-per-pr branch from 0d1ba26 to c37ee2f Compare June 18, 2026 05:49
@gokulhost gokulhost removed request for Marzooqa and bdesoky June 18, 2026 06:17
Marzooqa
Marzooqa previously approved these changes Jun 18, 2026
@gokulhost gokulhost dismissed stale reviews from Marzooqa and zahin-mohammad via 5cc3e9d June 18, 2026 06:46
Adds an `all-checks` job (if: always()) that aggregates every skippable
job. It passes when each dependency result is `success` or `skipped`,
and fails on `failure` or `cancelled` — so no broken job can sneak through.

`changes` is explicitly listed in needs: if the path-filter job itself
errors, its result is `failure` (not `skipped`), which the jq check
rejects and blocks the merge.

Branch protection should require `all-checks` instead of the individual
job names so that CI-only PRs (tests intentionally skipped) can merge
while still blocking PRs where tests actually fail.

Ref: WCN-974

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gokulhost gokulhost force-pushed the gokuldevaraju330/wcn-974-ci-add-path-filters-to-skip-irrelevant-jobs-per-pr branch from 5cc3e9d to 35067e9 Compare June 18, 2026 06:48
@gokulhost

Copy link
Copy Markdown
Contributor Author

Branch protection update needed to unblock CI-only PRs

The required checks (unit-test (22.x), unit-test (20.x), browser-test, docker-build) are defined in Terraform at infra/terraform/accounts/github-repositories-0/branch-protection.tf. Once this PR is approved, I can follow up with an infra PR to replace those individual checks with the new all-checks gate.

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.

3 participants