validate-registry.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. name: Validate Registry on PR
  2. # Contributor code must run only with a read-only token and no secrets.
  3. # Never change this workflow back to pull_request_target while it checks out
  4. # and executes pull-request code.
  5. on:
  6. pull_request:
  7. branches:
  8. - main
  9. - dev
  10. workflow_dispatch:
  11. permissions:
  12. contents: read
  13. jobs:
  14. validate-and-update:
  15. runs-on: ubuntu-latest
  16. timeout-minutes: 10
  17. steps:
  18. - name: Checkout code without persisted credentials
  19. uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
  20. with:
  21. fetch-depth: 0
  22. persist-credentials: false
  23. - name: Install system dependencies
  24. run: |
  25. sudo apt-get update
  26. sudo apt-get install -y jq
  27. - name: Install Bun
  28. uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
  29. with:
  30. bun-version: latest
  31. - name: Install project dependencies
  32. run: bun install --frozen-lockfile
  33. - name: Make validation scripts executable
  34. run: |
  35. chmod +x scripts/registry/validate-registry.sh
  36. chmod +x scripts/registry/auto-detect-components.sh
  37. chmod +x scripts/registry/register-component.sh
  38. chmod +x scripts/prompts/validate-pr.sh
  39. - name: Report registry drift
  40. id: registry_drift
  41. run: |
  42. ./scripts/registry/auto-detect-components.sh --dry-run > /tmp/detect-output.txt 2>&1
  43. cat /tmp/detect-output.txt
  44. sed $'s/\033\\[[0-9;]*m//g' /tmp/detect-output.txt > /tmp/detect-output-plain.txt
  45. if grep -Eq 'New Components:[[:space:]]*[1-9][0-9]*([[:space:]]|$)' /tmp/detect-output-plain.txt; then
  46. echo "drift_detected=true" >> "$GITHUB_OUTPUT"
  47. echo "## Registry drift detected" >> "$GITHUB_STEP_SUMMARY"
  48. echo "" >> "$GITHUB_STEP_SUMMARY"
  49. echo "The repository already contains components not represented in registry.json." >> "$GITHUB_STEP_SUMMARY"
  50. echo "This is reported but does not block security validation until the existing drift is reconciled." >> "$GITHUB_STEP_SUMMARY"
  51. else
  52. echo "drift_detected=false" >> "$GITHUB_OUTPUT"
  53. fi
  54. - name: Validate prompt library structure
  55. run: ./scripts/prompts/validate-pr.sh
  56. - name: Validate markdown context links
  57. run: npm run validate:context-links
  58. - name: Validate registry
  59. run: npm run validate:registry
  60. - name: Validation summary
  61. if: success()
  62. run: |
  63. echo "## All registry validations passed" >> "$GITHUB_STEP_SUMMARY"
  64. echo "" >> "$GITHUB_STEP_SUMMARY"
  65. echo "- Prompt library structure is valid" >> "$GITHUB_STEP_SUMMARY"
  66. echo "- Context markdown links are valid" >> "$GITHUB_STEP_SUMMARY"
  67. echo "- Registry paths and dependencies are valid" >> "$GITHUB_STEP_SUMMARY"
  68. if [ "${{ steps.registry_drift.outputs.drift_detected }}" = "true" ]; then
  69. echo "- Existing registry drift was reported separately" >> "$GITHUB_STEP_SUMMARY"
  70. else
  71. echo "- No unregistered components were detected" >> "$GITHUB_STEP_SUMMARY"
  72. fi