Skip to content

ci: Classify a PR's changed files in a tested script - #188

Merged
mpaulosky merged 2 commits into
mainfrom
chore/tested-change-detection
Sep 30, 2026
Merged

mpaulosky merged 2 commits into
mainfrom
chore/tested-change-detection

Conversation

@mpaulosky

@mpaulosky mpaulosky commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

The docs-only skip (#175) decided inline, in ci.yml's shell, whether a PR skips the build and tests. That rule decides whether required checks run, yet it had no automated tests. Copilot asked for them on the port to mpaulosky/atelier-store#95, so the rule now lives in a tested script here too, keeping this reference in step.

  • .github/scripts/detect_changes.py lists the changed files (git diff --name-only --no-renames -z against the base) and appends code=true or code=false to $GITHUB_OUTPUT. The rule is unchanged: docs-only when every path is under docs/ or ends in .md; anything else, or an empty diff, runs the build. -z keeps file names with spaces or line breaks whole, and git's output is decoded by hand, because text=True would turn a \r in a name into \n. The first code path is logged with \r and \n escaped, so a file name can't start a workflow command such as ::error:: on the next log line.
  • The Detect Changes step keeps its push and manual-run shortcut and calls the script for pull requests. The job now matches atelier-store's exactly.

Testing

  • New test_detect_changes.py (23 tests) builds real git repos: docs-only, code, mixed, an empty diff, code moved into docs/, code renamed to .md, a deletion, file names with spaces and newlines, and a code path whose name holds \n::error:: and \r::warning:: (logged on one escaped line), plus each path's classification and the output line the job reads. All script tests: 181 passed, 1 skipped.
  • The same script runs live in atelier-store: Bump actions/upload-pages-artifact from 4 to 5 in the all-actions group #95 itself ran the build, and its docs-only blog PR (docs: add release blog for PR #95 [skip-release] atelier-store#98) skipped the build and tests and merged in about 1.5 minutes under main's ruleset.
  • yamllint, actionlint and zizmor are clean, and the pre-push gate passed.

Refs #144

🤖 Generated with Claude Code

detect_changes.py holds the docs-only rule the Detect Changes job ran
inline: every path under docs/ or ending in .md skips the build, and
anything else, an empty diff or a rename out of code runs it. Its tests
build real git repos to cover docs-only, code, mixed, empty, rename,
delete and odd-filename changes. Found by review of the port to
mpaulosky/atelier-store#95.

Refs #144

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings September 30, 2026 05:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

An unescaped filename can inject GitHub Actions workflow commands into the job log.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Extracts docs-only PR classification from CI into a tested Python script.

Changes:

  • Adds fail-safe changed-file classification.
  • Adds 22 Git-backed tests.
  • Updates CI to invoke the classifier.
File Description
.github/​workflows/​ci.yml Calls the classifier for pull requests.
.github/​scripts/​detect_changes.py Classifies changed paths and emits code.
.github/​scripts/​tests/​test_detect_changes.py Tests classification and edge cases.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/scripts/detect_changes.py Outdated
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Test Results Summary

483 tests  ±0   483 ✅ ±0   14s ⏱️ -5s
  9 suites ±0     0 💤 ±0 
  9 files   ±0     0 ❌ ±0 

Results for commit d569bbd. ± Comparison against base commit 1fd6540.

♻️ This comment has been updated with latest results.

@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.40%. Comparing base (1fd6540) to head (d569bbd).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #188   +/-   ##
=======================================
  Coverage   85.40%   85.40%           
=======================================
  Files          77       77           
  Lines        1596     1596           
  Branches      150      150           
=======================================
  Hits         1363     1363           
  Misses        189      189           
  Partials       44       44           

Git allows line breaks in file names, and the first code path is written
to the Actions log, so a name like "src/x\n::error::forged" could start
a workflow command. The path is logged with \r and \n escaped. Reading
git's output with text=True also turned a \r in a name into \n; it is
now decoded by hand.

Refs #144

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings September 30, 2026 05:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation is robust and thoroughly tested; only a minor notice pluralization issue remains.

Review effort: Balanced
Findings: None

Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Low severity Fix singular/plural grammar for one-file notices

.github/​scripts/​detect_changes.py:76

For a one-file docs PR, this notice renders 1 files, and the new test currently codifies that grammar. Please pluralize file based on len(paths) and update the assertion accordingly.

@mpaulosky
mpaulosky merged commit e7108f4 into main Sep 30, 2026
31 checks passed
@mpaulosky
mpaulosky deleted the chore/tested-change-detection branch September 30, 2026 05:34
mpaulosky added a commit that referenced this pull request Sep 30, 2026
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
mpaulosky added a commit that referenced this pull request Sep 30, 2026
The docs job listed Releases eight seconds after v0.0.20 was published,
GitHub's list didn't include it yet, and the run opened no blog PR for
PR #188. The job now passes the PRs it released, and the backfill lists
again, every 5s for up to a minute, until each has a Release. A release
that never appears is logged as a warning; the next run writes its post.
The posts and the tables use the same listing.

Refs #144

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants