|
| 1 | +--- |
| 2 | +name: Validate Rules |
| 3 | + |
| 4 | +permissions: |
| 5 | + contents: read |
| 6 | + |
| 7 | +on: |
| 8 | + pull_request: |
| 9 | + paths: |
| 10 | + - 'sources/**' |
| 11 | + - 'src/**' |
| 12 | + - 'pyproject.toml' |
| 13 | + push: |
| 14 | + branches: |
| 15 | + - main |
| 16 | + - develop |
| 17 | + paths: |
| 18 | + - 'sources/**' |
| 19 | + - 'src/**' |
| 20 | + - 'pyproject.toml' |
| 21 | + workflow_dispatch: |
| 22 | + |
| 23 | +jobs: |
| 24 | + validate: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout repository |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Install uv |
| 32 | + uses: astral-sh/setup-uv@v4 |
| 33 | + with: |
| 34 | + enable-cache: true |
| 35 | + |
| 36 | + - name: Set up Python |
| 37 | + uses: actions/setup-python@v5 |
| 38 | + with: |
| 39 | + python-version: '3.11' |
| 40 | + |
| 41 | + - name: Install dependencies |
| 42 | + run: uv sync |
| 43 | + |
| 44 | + - name: Validate unified rules |
| 45 | + run: uv run python src/validate_unified_rules.py sources/ |
| 46 | + |
| 47 | + - name: Check required core rule files exist |
| 48 | + run: | |
| 49 | + echo "Checking for required core rule files..." |
| 50 | + required_files=( |
| 51 | + "sources/core/codeguard-1-hardcoded-credentials.md" |
| 52 | + "sources/core/codeguard-1-crypto-algorithms.md" |
| 53 | + "sources/core/codeguard-1-digital-certificates.md" |
| 54 | + "sources/core/codeguard-1-safe-c-functions.md" |
| 55 | + "sources/core/codeguard-SKILLS.md.template" |
| 56 | + ) |
| 57 | + |
| 58 | + missing=0 |
| 59 | + for file in "${required_files[@]}"; do |
| 60 | + if [ ! -f "$file" ]; then |
| 61 | + echo "❌ Missing required file: $file" |
| 62 | + missing=1 |
| 63 | + else |
| 64 | + echo "✅ Found: $file" |
| 65 | + fi |
| 66 | + done |
| 67 | + |
| 68 | + if [ $missing -eq 1 ]; then |
| 69 | + exit 1 |
| 70 | + fi |
| 71 | +
|
| 72 | + - name: Test conversion to IDE formats |
| 73 | + run: | |
| 74 | + echo "Testing IDE format conversion..." |
| 75 | + uv run python src/convert_to_ide_formats.py --output-dir test-output |
| 76 | + |
| 77 | + # Check that files were generated |
| 78 | + if [ ! -d "test-output/.cursor" ]; then |
| 79 | + echo "❌ Cursor rules not generated" |
| 80 | + exit 1 |
| 81 | + fi |
| 82 | + |
| 83 | + if [ ! -d "test-output/.windsurf" ]; then |
| 84 | + echo "❌ Windsurf rules not generated" |
| 85 | + exit 1 |
| 86 | + fi |
| 87 | + |
| 88 | + if [ ! -d "test-output/.github" ]; then |
| 89 | + echo "❌ Copilot instructions not generated" |
| 90 | + exit 1 |
| 91 | + fi |
| 92 | + |
| 93 | + echo "✅ All IDE formats generated successfully" |
| 94 | +
|
| 95 | + - name: Check skills/ directory is up-to-date |
| 96 | + run: | |
| 97 | + echo "Checking if committed skills/ directory is up-to-date..." |
| 98 | + |
| 99 | + # Save current skills |
| 100 | + mv skills skills-committed |
| 101 | + |
| 102 | + # Regenerate skills (core rules only, matching default) |
| 103 | + uv run python src/convert_to_ide_formats.py |
| 104 | + |
| 105 | + # Compare |
| 106 | + if ! diff -r skills/ skills-committed/ > /dev/null 2>&1; then |
| 107 | + echo "❌ The skills/ directory is out of date!" |
| 108 | + echo "Please regenerate by running: python src/convert_to_ide_formats.py" |
| 109 | + echo "Then: git add skills/" |
| 110 | + mv skills-committed skills |
| 111 | + exit 1 |
| 112 | + fi |
| 113 | + |
| 114 | + # Restore original |
| 115 | + rm -rf skills |
| 116 | + mv skills-committed skills |
| 117 | + echo "✅ Committed skills/ directory is up-to-date" |
| 118 | +
|
| 119 | + - name: Summary |
| 120 | + if: success() |
| 121 | + run: | |
| 122 | + echo "✅ All validation checks passed!" |
| 123 | + echo "" |
| 124 | + echo "Rule validation: ✅" |
| 125 | + echo "Required files: ✅" |
| 126 | + echo "IDE conversion: ✅" |
| 127 | + echo "Skills directory: ✅" |
| 128 | +
|
0 commit comments