Skip to content

Commit ff221e6

Browse files
authored
ci: scope PR workflow runs by changed paths (#1067)
## Description Makes PR workflow runs more selective by routing docs-only changes to docs validation instead of the full CI workflow, while preserving workflow validation and existing code/e2e/release gates for applicable changes. ## Type of Change - [ ] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Performance improvement - [x] Code refactoring (no functional changes) ## Changes Made - Added `pull_request.paths-ignore` to `.github/workflows/ci.yml` so docs/wiki/markdown-only PRs do not queue the general CI workflow. - Removed `.github/workflows/ci.yml` from the CI internal `code` path filter so CI-only workflow edits can run workflow validation without forcing Python/Rust code jobs. - Added a docs PR validation job to `.github/workflows/docs.yml` for `docs/**`, `wiki/**`, `mkdocs.yml`, and docs workflow changes. - Reduced default docs workflow token permissions to `contents: read`, with `contents: write` scoped only to the deploy job. - Added docs workflow dry-runs to `scripts/validate-workflows.sh` so local/CI workflow validation covers the new PR and manual docs paths. ## Testing - [ ] Unit tests pass (`pytest`) - [ ] Linting passes (`ruff check .`) - [ ] Type checking passes (`mypy headroom`) - [ ] New tests added for new functionality - [x] Manual testing performed ### Test Output ```text $ actionlint .github/workflows/ci.yml .github/workflows/docs.yml # no output $ act pull_request -W .github/workflows/docs.yml -n *DRYRUN* [Deploy Documentation/validate] 🏁 Job succeeded $ act workflow_dispatch -W .github/workflows/docs.yml -n *DRYRUN* [Deploy Documentation/deploy] 🏁 Job succeeded $ act pull_request -W .github/workflows/ci.yml -n *DRYRUN* [CI/changes] 🏁 Job succeeded *DRYRUN* [CI/commitlint] 🏁 Job succeeded $ python -m mkdocs build INFO - Documentation built in 1.28 seconds $ bash scripts/validate-workflows.sh # completed successfully; act dry-runs passed. Some unsupported runner-platform matrix entries are skipped by local act, as before. $ git diff --check # no output ``` ## Real Behavior Proof - Environment: Windows local checkout, branch `smart-pr-runs`, `act` 0.2.87, temporary local `actionlint` installed via `go install`. - Exact command / steps: Ran `actionlint` against changed workflows, `act` dry-runs for docs PR/manual paths and CI PR path, actual `python -m mkdocs build`, full `scripts/validate-workflows.sh`, and `git diff --check`. - Observed result: Changed workflows lint cleanly; docs PR and manual docs workflow paths dry-run successfully; CI PR dry-run still covers `changes` and `commitlint`; MkDocs builds; repository workflow validation script completes with the new docs dry-runs included. - Not tested: Full non-dry-run GitHub Actions execution on hosted runners before PR creation. ## Review Readiness - [x] I have performed a self-review - [x] This PR is ready for human review ## Checklist - [x] My code follows the project's style guidelines - [x] I have performed a self-review of my code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] I have updated the CHANGELOG.md if applicable ## Screenshots (if applicable) N/A. ## Additional Notes - No issue is linked because this PR was not opened for a specific tracked issue. - `mkdocs build` reports existing docs/nav warnings but exits successfully; strict mode currently fails on existing warnings, so the PR validation uses the deploy-compatible non-strict build. - Python unit/lint/type checks are not applicable to this workflow-only change.
1 parent b2f04e4 commit ff221e6

3 files changed

Lines changed: 42 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ on:
1616
branches: [main]
1717
pull_request:
1818
branches: [main]
19+
paths-ignore:
20+
- 'docs/**'
21+
- 'wiki/**'
22+
- '**/*.md'
1923
workflow_dispatch:
2024

2125
permissions:
@@ -54,7 +58,6 @@ jobs:
5458
- 'Cargo.lock'
5559
- 'tests/**'
5660
- 'scripts/**'
57-
- '.github/workflows/ci.yml'
5861
e2e:
5962
- 'headroom/**'
6063
- 'crates/**'

.github/workflows/docs.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
name: Deploy Documentation
22

33
on:
4+
pull_request:
5+
branches: [main]
6+
paths:
7+
- 'docs/**'
8+
- 'wiki/**'
9+
- 'mkdocs.yml'
10+
- '.github/workflows/docs.yml'
411
push:
512
branches:
613
- main
@@ -11,11 +18,39 @@ on:
1118
workflow_dispatch:
1219

1320
permissions:
14-
contents: write
21+
contents: read
1522

1623
jobs:
24+
validate:
25+
if: github.event_name == 'pull_request'
26+
runs-on: ubuntu-latest
27+
timeout-minutes: 10
28+
steps:
29+
- uses: actions/checkout@v6
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v6
33+
with:
34+
python-version: '3.11'
35+
36+
- name: Cache pip
37+
uses: actions/cache@v5
38+
with:
39+
path: ~/.cache/pip
40+
key: ${{ runner.os }}-pip-docs-${{ hashFiles('mkdocs.yml') }}
41+
restore-keys: ${{ runner.os }}-pip-docs-
42+
43+
- name: Install dependencies
44+
run: pip install mkdocs-material
45+
46+
- name: Build docs
47+
run: mkdocs build
48+
1749
deploy:
50+
if: github.event_name != 'pull_request'
1851
runs-on: ubuntu-latest
52+
permissions:
53+
contents: write
1954
steps:
2055
- uses: actions/checkout@v6
2156
with:

scripts/validate-workflows.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ run_act act release -W .github/workflows/release.yml -e .github/act/release-publ
3434
run_act act push -W .github/workflows/release-please.yml -e .github/act/push-feat.json -n
3535
run_act act pull_request_target -W .github/workflows/pr-health.yml -e .github/act/pr-governance-invalid.json -n
3636
run_act act pull_request_target -W .github/workflows/pr-health.yml -e .github/act/pr-governance-valid.json -n
37+
run_act act pull_request -W .github/workflows/docs.yml -n
38+
run_act act workflow_dispatch -W .github/workflows/docs.yml -n
3739
run_act act workflow_dispatch -W .github/workflows/docker.yml -e .github/act/docker-version.json -n

0 commit comments

Comments
 (0)