build(ci): add --base/--head changed-files support to validate-frontmatter - #2499
build(ci): add --base/--head changed-files support to validate-frontmatter#2499ashleyshaw with Copilot wants to merge 14 commits into
Conversation
The CI workflow calls `npm run validate:frontmatter:changed -- --base $BASE_SHA --head $HEAD_SHA` but the script previously ignored those flags and validated all files. This change: - Adds `FileDiscovery.findChangedFiles(baseSha, headSha, ...)` which uses `git diff --name-only --diff-filter=ACMRT` (via execFileSync, no shell interpolation) to get changed files, then intersects with the set of pattern-matched/non-excluded files; falls back to full scan on any error. - Validates SHA format (4–64 hex chars) before use to prevent shell injection. - Updates `validateFrontmatter(filePaths?)` to accept an optional file list. - Parses `--base`/`--head` in the CLI and passes the changed-file list to the validator when both are present. - Chains `.catch()` on both `validateFrontmatter()` call sites so unhandled rejections cause a non-zero exit (CI correctness fix). - Updates `--help` output to document the new flags. Co-authored-by: ashleyshaw <1805352+ashleyshaw@users.noreply.github.com>
…rontmatter-change
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR fixes the validate:frontmatter:changed CI workflow path by adding --base/--head support so frontmatter validation can scope to only files changed between two git SHAs, while retaining a full-scan fallback.
Changes:
- Added
FileDiscovery.findChangedFiles(baseSha, headSha, ...)to compute changed files viagit diff --name-onlyand filter them to supported patterns/exclusions. - Updated
validateFrontmatter(filePaths?)and CLI arg parsing to validate only changed files when--baseand--headare provided. - Ensured async validation invocations surface failures via
.catch()with non-zero exit codes.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ash Shaw <ashley@lightspeedwp.agency>
🔍 Reviewer Summary for PR #2499CI Status: ❌ Recommendations
|
1 similar comment
🔍 Reviewer Summary for PR #2499CI Status: ❌ Recommendations
|
Head branch was pushed to by a user without write access
…e CI diagnostics Co-authored-by: ashleyshaw <1805352+ashleyshaw@users.noreply.github.com>
Merge readiness checklist for #2499 (
|
🔍 Reviewer Summary for PR #2499CI Status: ❌ Recommendations
|
1 similar comment
🔍 Reviewer Summary for PR #2499CI Status: ❌ Recommendations
|
|
🚫 This PR description is missing required template content. Missing required section(s): Linked issues, Global DoD checklist Please update the PR body using one of the repository PR templates:
Empty placeholders, unchecked checklist boxes, and stub issue references do not count. |
|
This PR's branch name Standard pattern: Based on linked issue type: Correct template should be: No action required — this is informational. Future PRs should use the correct branch name. See Branching Strategy for more info. |
🔍 Reviewer Summary for PR #2499CI Status: ❌ Recommendations
|
1 similar comment
🔍 Reviewer Summary for PR #2499CI Status: ❌ Recommendations
|
The CI workflow calls `npm run validate:frontmatter:changed -- --base $BASE_SHA --head $HEAD_SHA` but the script previously ignored those flags and validated all files. This change: - Adds `FileDiscovery.findChangedFiles(baseSha, headSha, ...)` which uses `git diff --name-only --diff-filter=ACMRT` (via execFileSync, no shell interpolation) to get changed files, then intersects with the set of pattern-matched/non-excluded files; falls back to full scan on any error. - Validates SHA format (4–64 hex chars) before use to prevent shell injection. - Updates `validateFrontmatter(filePaths?)` to accept an optional file list. - Parses `--base`/`--head` in the CLI and passes the changed-file list to the validator when both are present. - Chains `.catch()` on both `validateFrontmatter()` call sites so unhandled rejections cause a non-zero exit (CI correctness fix). - Updates `--help` output to document the new flags. Co-authored-by: ashleyshaw <1805352+ashleyshaw@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ash Shaw <ashley@lightspeedwp.agency>
…e CI diagnostics Co-authored-by: ashleyshaw <1805352+ashleyshaw@users.noreply.github.com>
caeb4cf to
6ed087d
Compare
❌ Branch Name Validation FailedThe branch name Required Format
Allowed Branch Types
Valid Examples
Invalid Examples
SolutionRename your branch to follow the pattern and update the PR. For more information, see docs/BRANCHING_STRATEGY.md. |
…rontmatter-change
Co-authored-by: ashleyshaw <1805352+ashleyshaw@users.noreply.github.com>
Head branch was pushed to by a user without write access
…nge' of https://github.com/lightspeedwp/.github into ci/fix-missing-npm-script-validate-frontmatter-change
The
front-matter-validateCI check was failing on every PR becausenpm run validate:frontmatter:changedexisted inpackage.jsonbut the underlying script ignored the--base/--headSHA flags passed by the workflow — effectively running a full scan on every invocation and providing no "changed files only" behaviour.Build/CI change
FileDiscovery.findChangedFiles(baseSha, headSha, ...)— new static method; runsgit diff --name-only --diff-filter=ACMRTviaexecFileSync(arg array, no shell) and intersects results with the pattern-matched/excluded file set; falls back to full scan gracefully on any git errorvalidateFrontmatter(filePaths?)— accepts an optional file list; CLI wires it up when both--baseand--headare present, full scan otherwisevalidateFrontmatter()call sites now chain.catch()so async rejections produce a non-zero exit rather than a silent passBaseline & Target
BASE_SHAandHEAD_SHAare validated; full fallback retained when git is unavailableRollback
Revert the single commit to
scripts/validation/validate-frontmatter.js; thevalidate:frontmatter:changednpm script entry inpackage.jsonis unchanged.Notes
execFileSync(argument array) — no shell involved, no injection surface/^[0-9a-f]{4,64}$/i— covers abbreviated and full SHAsChangelog
Fixed
validate:frontmatter:changednow correctly scopes validation to files changed between the two git SHAs supplied by the CI workflow, unblocking thefront-matter-validatecheck on every PR. (Closes fix: Missing npm script 'validate:frontmatter:changed' in CI workflow #1929)Checklist (Global DoD / PR)