packages-checks.yml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. name: Packages Checks
  2. on:
  3. pull_request:
  4. paths:
  5. - 'packages/**'
  6. - '.github/workflows/packages-checks.yml'
  7. - 'scripts/validation/detect-pr-changes.ts'
  8. permissions:
  9. contents: read
  10. jobs:
  11. check-changes:
  12. name: Detect Package Changes
  13. runs-on: ubuntu-latest
  14. outputs:
  15. has-packages: ${{ steps.filter.outputs.has-packages }}
  16. steps:
  17. - name: Checkout code
  18. uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
  19. with:
  20. fetch-depth: 0
  21. persist-credentials: false
  22. - name: Setup Bun
  23. uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
  24. with:
  25. bun-version: 1.3.14
  26. - name: Check changed files
  27. id: filter
  28. run: |
  29. echo "Changed files:" >&2
  30. git diff --name-only -z "${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}" |
  31. tee >(while IFS= read -r -d '' path; do printf ' %q\n' "$path" >&2; done) |
  32. bun run scripts/validation/detect-pr-changes.ts
  33. cli-checks:
  34. name: CLI (build + test + typecheck)
  35. runs-on: ubuntu-latest
  36. timeout-minutes: 10
  37. needs: check-changes
  38. if: needs.check-changes.outputs.has-packages == 'true'
  39. steps:
  40. - name: Checkout code
  41. uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
  42. with:
  43. persist-credentials: false
  44. - name: Setup Bun
  45. uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
  46. with:
  47. bun-version: 1.3.14
  48. # packages/cli is a root bun workspace member; the root lockfile covers it.
  49. - name: Install workspace dependencies
  50. run: bun install --frozen-lockfile
  51. # cli tsconfig paths point at ../compatibility-layer/dist, so build it first.
  52. - name: Build compatibility-layer dependency
  53. working-directory: packages/compatibility-layer
  54. run: bun run build
  55. - name: Typecheck
  56. working-directory: packages/cli
  57. run: bun run typecheck
  58. - name: Build
  59. working-directory: packages/cli
  60. run: bun run build
  61. # packages/cli tests use Bun-only APIs (Bun.file, Bun.spawn, import.meta.dir)
  62. # until Stage 5 removes them — they must run under `bun test`, not vitest.
  63. - name: Test
  64. working-directory: packages/cli
  65. run: bun run test
  66. compatibility-layer-checks:
  67. name: Compatibility Layer (build + test + lint)
  68. runs-on: ubuntu-latest
  69. timeout-minutes: 10
  70. needs: check-changes
  71. if: needs.check-changes.outputs.has-packages == 'true'
  72. steps:
  73. - name: Checkout code
  74. uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
  75. with:
  76. persist-credentials: false
  77. - name: Setup Node.js
  78. uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
  79. with:
  80. node-version: '20'
  81. cache: 'npm'
  82. cache-dependency-path: 'packages/compatibility-layer/package-lock.json'
  83. - name: Install dependencies
  84. working-directory: packages/compatibility-layer
  85. run: npm ci
  86. # build runs tsc, which is also the typecheck for this package.
  87. - name: Build (tsc typecheck)
  88. working-directory: packages/compatibility-layer
  89. run: npm run build
  90. - name: Lint
  91. working-directory: packages/compatibility-layer
  92. run: npm run lint
  93. - name: Test (vitest)
  94. working-directory: packages/compatibility-layer
  95. run: npm test
  96. # Non-blocking: packages/plugin-abilities is known-red today (92 tsc errors,
  97. # 23 failing bun tests; its lint script is broken — eslint is not a dependency
  98. # and no config exists). This job reports build/test status without failing
  99. # PRs until the package is repaired. Once it is green, promote the build and
  100. # test commands to normal failing steps and gate the summary on this job.
  101. plugin-abilities-checks:
  102. name: Plugin Abilities (build + test, non-blocking)
  103. runs-on: ubuntu-latest
  104. timeout-minutes: 10
  105. needs: check-changes
  106. if: needs.check-changes.outputs.has-packages == 'true'
  107. outputs:
  108. status: ${{ steps.nonblocking.outputs.status }}
  109. steps:
  110. - name: Checkout code
  111. uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
  112. with:
  113. persist-credentials: false
  114. - name: Setup Bun
  115. uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
  116. with:
  117. bun-version: 1.3.14
  118. # Not a root workspace member — it has its own lockfile.
  119. - name: Install dependencies
  120. working-directory: packages/plugin-abilities
  121. run: bun install --frozen-lockfile
  122. - name: Build and test (non-blocking)
  123. id: nonblocking
  124. working-directory: packages/plugin-abilities
  125. run: |
  126. STATUS=pass
  127. bun run build || STATUS=fail
  128. bun test || STATUS=fail
  129. echo "status=$STATUS" >> "$GITHUB_OUTPUT"
  130. if [ "$STATUS" = "fail" ]; then
  131. echo "::warning title=plugin-abilities red::packages/plugin-abilities build/test failing (pre-existing, non-blocking)"
  132. fi
  133. summary:
  134. name: Packages Checks Summary
  135. runs-on: ubuntu-latest
  136. needs: [check-changes, cli-checks, compatibility-layer-checks, plugin-abilities-checks]
  137. if: always()
  138. steps:
  139. - name: Generate summary
  140. run: |
  141. echo "## 📦 Packages Checks Summary" >> $GITHUB_STEP_SUMMARY
  142. echo "" >> $GITHUB_STEP_SUMMARY
  143. report() {
  144. local label="$1" result="$2"
  145. case "$result" in
  146. success) echo "✅ **${label}:** Passed" >> $GITHUB_STEP_SUMMARY ;;
  147. skipped) echo "⏭️ **${label}:** Skipped (no packages/** changes)" >> $GITHUB_STEP_SUMMARY ;;
  148. *) echo "❌ **${label}:** ${result}" >> $GITHUB_STEP_SUMMARY ;;
  149. esac
  150. }
  151. report "Change Detection" "${{ needs.check-changes.result }}"
  152. report "CLI" "${{ needs.cli-checks.result }}"
  153. report "Compatibility Layer" "${{ needs.compatibility-layer-checks.result }}"
  154. case "${{ needs.plugin-abilities-checks.result }}/${{ needs.plugin-abilities-checks.outputs.status }}" in
  155. success/pass) echo "✅ **Plugin Abilities (non-blocking):** Passed" >> $GITHUB_STEP_SUMMARY ;;
  156. success/fail) echo "⚠️ **Plugin Abilities (non-blocking):** Failing (pre-existing, does not block this PR)" >> $GITHUB_STEP_SUMMARY ;;
  157. skipped/*) echo "⏭️ **Plugin Abilities (non-blocking):** Skipped (no packages/** changes)" >> $GITHUB_STEP_SUMMARY ;;
  158. *) echo "⚠️ **Plugin Abilities (non-blocking):** ${{ needs.plugin-abilities-checks.result }}" >> $GITHUB_STEP_SUMMARY ;;
  159. esac
  160. echo "" >> $GITHUB_STEP_SUMMARY
  161. FAILED=0
  162. [ "${{ needs.check-changes.result }}" != "success" ] && FAILED=1
  163. for result in "${{ needs.cli-checks.result }}" "${{ needs.compatibility-layer-checks.result }}"; do
  164. if [ "$result" != "success" ] && [ "$result" != "skipped" ]; then
  165. FAILED=1
  166. fi
  167. done
  168. if [ $FAILED -eq 0 ]; then
  169. echo "### ✅ Required Package Checks Passed" >> $GITHUB_STEP_SUMMARY
  170. else
  171. echo "### ❌ Some Package Checks Failed" >> $GITHUB_STEP_SUMMARY
  172. exit 1
  173. fi