validate-registry.yml 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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: 1.3.14
  31. - name: Setup pnpm
  32. uses: pnpm/action-setup@b0f76dfb45f55f8421693e4803ac7bb65143bd34 # v6
  33. - name: Setup Node.js
  34. uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
  35. with:
  36. node-version: '20'
  37. cache: 'pnpm'
  38. cache-dependency-path: 'pnpm-lock.yaml'
  39. - name: Install project dependencies
  40. run: pnpm install --frozen-lockfile
  41. - name: Make validation scripts executable
  42. run: |
  43. chmod +x scripts/registry/validate-registry.sh
  44. chmod +x scripts/registry/auto-detect-components.sh
  45. chmod +x scripts/registry/register-component.sh
  46. chmod +x scripts/prompts/validate-pr.sh
  47. - name: Report registry drift
  48. id: registry_drift
  49. run: |
  50. ./scripts/registry/auto-detect-components.sh --dry-run > /tmp/detect-output.txt 2>&1
  51. cat /tmp/detect-output.txt
  52. sed $'s/\033\\[[0-9;]*m//g' /tmp/detect-output.txt > /tmp/detect-output-plain.txt
  53. if grep -Eq 'New Components:[[:space:]]*[1-9][0-9]*([[:space:]]|$)' /tmp/detect-output-plain.txt; then
  54. echo "drift_detected=true" >> "$GITHUB_OUTPUT"
  55. echo "## Registry drift detected" >> "$GITHUB_STEP_SUMMARY"
  56. echo "" >> "$GITHUB_STEP_SUMMARY"
  57. echo "The repository already contains components not represented in registry.json." >> "$GITHUB_STEP_SUMMARY"
  58. echo "This is reported but does not block security validation until the existing drift is reconciled." >> "$GITHUB_STEP_SUMMARY"
  59. else
  60. echo "drift_detected=false" >> "$GITHUB_OUTPUT"
  61. fi
  62. - name: Validate prompt library structure
  63. run: ./scripts/prompts/validate-pr.sh
  64. - name: Validate markdown context links
  65. run: pnpm run validate:context-links
  66. - name: Validate registry
  67. run: pnpm run validate:registry
  68. - name: Validation summary
  69. if: success()
  70. run: |
  71. echo "## All registry validations passed" >> "$GITHUB_STEP_SUMMARY"
  72. echo "" >> "$GITHUB_STEP_SUMMARY"
  73. echo "- Prompt library structure is valid" >> "$GITHUB_STEP_SUMMARY"
  74. echo "- Context markdown links are valid" >> "$GITHUB_STEP_SUMMARY"
  75. echo "- Registry paths and dependencies are valid" >> "$GITHUB_STEP_SUMMARY"
  76. if [ "${{ steps.registry_drift.outputs.drift_detected }}" = "true" ]; then
  77. echo "- Existing registry drift was reported separately" >> "$GITHUB_STEP_SUMMARY"
  78. else
  79. echo "- No unregistered components were detected" >> "$GITHUB_STEP_SUMMARY"
  80. fi