XS ◾ Code Change - Auto-fix category index sync on PRs when rule category changes#12050
XS ◾ Code Change - Auto-fix category index sync on PRs when rule category changes#12050Freego1783 merged 7 commits intomainfrom
Conversation
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>
|
Change the workflow so that, on PRs, it auto-fixes category index sync issues instead of posting PR review comments. Auto-fix behavior:
Workflow behavior:
|
…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>
Done in |
PR Metrics✔ Thanks for keeping your pull request small.
Metrics computed by PR Metrics. Add it to your Azure DevOps and GitHub PRs! |
There was a problem hiding this comment.
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>
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:
.github/workflows/check-category-sync.ymlworkflow to automatically check and fix category index synchronization on pull requests targetingmain. The workflow installs Node.js, detects changed files, runs the sync validator, and commits any auto-fixed changes.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.