Skip to content

Comments

XS ◾ Code Change - Auto-fix category index sync on PRs when rule category changes#12050

Merged
Freego1783 merged 7 commits intomainfrom
copilot/auto-update-category-index
Feb 20, 2026
Merged

XS ◾ Code Change - Auto-fix category index sync on PRs when rule category changes#12050
Freego1783 merged 7 commits intomainfrom
copilot/auto-update-category-index

Conversation

Copy link
Contributor

Copilot AI commented Feb 19, 2026

Relates to SSWConsulting/SSW.Rules#2473

This pull request introduces a new automated workflow and supporting scripts to ensure category index files stay in sync with rule files. The main addition is a GitHub Actions workflow that runs on pull requests to automatically check and fix discrepancies between rule frontmatter and category index lists. The workflow leverages a new Node.js script for validation and auto-fixing, and includes necessary dependency setup.

Automation for category index synchronization:

  • Added .github/workflows/check-category-sync.yml workflow to automatically check and fix category index synchronization on pull requests targeting main. The workflow installs Node.js, detects changed files, runs the sync validator, and commits any auto-fixed changes.
  • Introduced scripts/category-sync-validator/category-sync-validator.js, a Node.js script that parses rule and category files, ensures category index lists include referenced rules, removes stale entries, and reports errors.

Create a GitHub Actions workflow that detects when a rule's category
field references a category, but the category's index file does not
include the rule. Fails with clear, actionable error messages.

Co-authored-by: Aibono1225 <127192800+Aibono1225@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement auto-update for category index on rule changes ✨ Add category sync check workflow to catch missing category index updates Feb 19, 2026
Copilot AI requested a review from Aibono1225 February 19, 2026 13:15
@Aibono1225
Copy link
Member

@copilot

Change the workflow so that, on PRs, it auto-fixes category index sync issues instead of posting PR review comments.

Auto-fix behavior:

  • For each changed rule MDX, read its categories frontmatter and ensure every referenced category MDX index includes - rule: <rulePath>.
  • If missing, update the category file by inserting the entry (preserve existing formatting/order if possible; otherwise append).
  • If the category file does not exist or the frontmatter cannot be parsed, fail with a clear error (do NOT try to create new category files).

Workflow behavior:

  • Run the fixer script.
  • If it produced changes, commit them back to the PR branch (use github-actions bot) and push.
  • Then re-run the validator (or have the fixer exit cleanly and let the job pass).
  • Remove the “post PR comment on failure” step.

…ments

The script now auto-inserts missing rule entries into category index
files and the workflow commits changes back to the PR branch using
the github-actions bot. Non-fixable errors (missing/unparseable
category files) still fail the workflow.

Co-authored-by: Aibono1225 <127192800+Aibono1225@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 19, 2026

@copilot

Change the workflow so that, on PRs, it auto-fixes category index sync issues instead of posting PR review comments.
...

Done in 9393be8. The script now auto-fixes category index sync issues by inserting missing - rule: entries into category MDX files (appending after the last existing entry to preserve formatting). The workflow commits and pushes changes back to the PR branch using github-actions[bot]. Non-fixable issues (missing or unparseable category files) still fail the job with a clear error. PR comment steps have been removed.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

PR Metrics

Thanks for keeping your pull request small.

Lines
Product Code -
Test Code -
Subtotal -
Ignored Code 411
Total 411

Metrics computed by PR Metrics. Add it to your Azure DevOps and GitHub PRs!

@github-actions github-actions bot changed the title ✨ Add category sync check workflow to catch missing category index updates XS ◾ ✨ Add category sync check workflow to catch missing category index updates Feb 19, 2026
Copilot AI changed the title XS ◾ ✨ Add category sync check workflow to catch missing category index updates ✨ Auto-fix category index sync on PRs when rule category changes Feb 19, 2026
@github-actions github-actions bot added the Age: 🥚 - New About 2 hours old label Feb 19, 2026
@github-actions github-actions bot changed the title ✨ Auto-fix category index sync on PRs when rule category changes XS ◾ ✨ Auto-fix category index sync on PRs when rule category changes Feb 19, 2026
@Aibono1225 Aibono1225 added the code change Code changes for scripts on this repo - Only review if you are developer label Feb 19, 2026
@Aibono1225 Aibono1225 changed the title XS ◾ ✨ Auto-fix category index sync on PRs when rule category changes Code Change - Auto-fix category index sync on PRs when rule category changes Feb 19, 2026
@Aibono1225 Aibono1225 requested a review from Copilot February 19, 2026 15:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an automated PR check + fixer to keep category index MDX files in sync with rule frontmatter categories, preventing rules from disappearing from the Categories page when category metadata changes.

Changes:

  • Added a GitHub Actions workflow to detect changed rule MDX files, run a sync fixer, and auto-commit resulting category index updates back to the PR branch.
  • Added a Node.js validator/fixer script that inserts missing - rule: entries into category index frontmatter (and removes stale ones).
  • Added minimal npm dependency setup for the validator script.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 6 comments.

File Description
.github/workflows/check-category-sync.yml Runs validator on PRs and auto-commits category index fixes back to the PR branch.
scripts/category-sync-validator/category-sync-validator.js Implements frontmatter parsing and category index add/remove sync logic.
scripts/category-sync-validator/package.json Declares js-yaml dependency for parsing frontmatter.
scripts/category-sync-validator/.gitignore Ignores local node_modules/ for the script folder.
Files not reviewed (1)
  • scripts/category-sync-validator/package-lock.json: Language not supported

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions github-actions bot changed the title Code Change - Auto-fix category index sync on PRs when rule category changes XS ◾ Code Change - Auto-fix category index sync on PRs when rule category changes Feb 19, 2026
@github-actions github-actions bot added the Age: 🐣 - Young About 4 hours old label Feb 19, 2026
@github-actions github-actions bot added Age: 🐥 - Adolescent About 8 hours old Age: 🐤 - Mature About 16 hours old Age: 🐓 - Old About 32 hours old and removed Age: 🥚 - New About 2 hours old Age: 🐣 - Young About 4 hours old Age: 🐥 - Adolescent About 8 hours old Age: 🐤 - Mature About 16 hours old labels Feb 19, 2026
@Aibono1225 Aibono1225 marked this pull request as ready for review February 20, 2026 08:48
@Freego1783 Freego1783 merged commit a16bd54 into main Feb 20, 2026
8 checks passed
@Freego1783 Freego1783 deleted the copilot/auto-update-category-index branch February 20, 2026 08:48
@github-actions github-actions bot added the Age: 🥚 - New About 2 hours old label Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Age: 🥚 - New About 2 hours old Age: 🐓 - Old About 32 hours old code change Code changes for scripts on this repo - Only review if you are developer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants