packages-checks.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. name: Packages Checks
  2. on:
  3. pull_request:
  4. paths:
  5. - 'packages/**'
  6. - 'package.json'
  7. - 'pnpm-lock.yaml'
  8. - 'pnpm-workspace.yaml'
  9. - '.github/workflows/packages-checks.yml'
  10. - '.github/dependabot.yml'
  11. - 'scripts/validation/detect-pr-changes.ts'
  12. - 'scripts/validation/detect-pr-changes.test.ts'
  13. permissions:
  14. contents: read
  15. jobs:
  16. check-changes:
  17. name: Detect Package Changes
  18. runs-on: ubuntu-latest
  19. outputs:
  20. has-packages: ${{ steps.filter.outputs.has-packages }}
  21. steps:
  22. - name: Checkout code
  23. uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
  24. with:
  25. fetch-depth: 0
  26. persist-credentials: false
  27. - name: Setup Bun
  28. uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
  29. with:
  30. bun-version: 1.3.14
  31. - name: Check changed files
  32. id: filter
  33. run: |
  34. echo "Changed files:" >&2
  35. git diff --name-only -z "${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}" |
  36. tee >(while IFS= read -r -d '' path; do printf ' %q\n' "$path" >&2; done) |
  37. bun run scripts/validation/detect-pr-changes.ts
  38. cli-checks:
  39. name: CLI (build + test + typecheck)
  40. runs-on: ubuntu-latest
  41. timeout-minutes: 10
  42. needs: check-changes
  43. if: needs.check-changes.outputs.has-packages == 'true'
  44. steps:
  45. - name: Checkout code
  46. uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
  47. with:
  48. persist-credentials: false
  49. - name: Setup Bun
  50. uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
  51. with:
  52. bun-version: 1.3.14
  53. - name: Setup pnpm
  54. uses: pnpm/action-setup@b0f76dfb45f55f8421693e4803ac7bb65143bd34 # v6
  55. - name: Setup Node.js
  56. uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
  57. with:
  58. node-version: '20'
  59. cache: 'pnpm'
  60. cache-dependency-path: 'pnpm-lock.yaml'
  61. - name: Install workspace dependencies
  62. run: pnpm install --frozen-lockfile
  63. # cli tsconfig paths point at ../compatibility-layer/dist, so build it first.
  64. - name: Build compatibility-layer dependency
  65. run: pnpm --dir packages/compatibility-layer run build
  66. - name: Typecheck
  67. run: pnpm --dir packages/cli run typecheck
  68. - name: Build
  69. run: pnpm --dir packages/cli run build
  70. # packages/cli tests use Bun-only APIs (Bun.file, Bun.spawn, import.meta.dir)
  71. # until Stage 5 removes them — they must run under `bun test`, not vitest.
  72. - name: Test
  73. run: pnpm --dir packages/cli run test
  74. compatibility-layer-checks:
  75. name: Compatibility Layer (build + test + lint)
  76. runs-on: ubuntu-latest
  77. timeout-minutes: 10
  78. needs: check-changes
  79. if: needs.check-changes.outputs.has-packages == 'true'
  80. steps:
  81. - name: Checkout code
  82. uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
  83. with:
  84. persist-credentials: false
  85. - name: Setup pnpm
  86. uses: pnpm/action-setup@b0f76dfb45f55f8421693e4803ac7bb65143bd34 # v6
  87. - name: Setup Node.js
  88. uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
  89. with:
  90. node-version: '20'
  91. cache: 'pnpm'
  92. cache-dependency-path: 'pnpm-lock.yaml'
  93. - name: Install workspace dependencies
  94. run: pnpm install --frozen-lockfile
  95. # build runs tsc, which is also the typecheck for this package.
  96. - name: Build (tsc typecheck)
  97. run: pnpm --dir packages/compatibility-layer run build
  98. - name: Lint
  99. run: pnpm --dir packages/compatibility-layer run lint
  100. - name: Test (vitest)
  101. run: pnpm --dir packages/compatibility-layer test
  102. summary:
  103. name: Packages Checks Summary
  104. runs-on: ubuntu-latest
  105. needs: [check-changes, cli-checks, compatibility-layer-checks]
  106. if: always()
  107. steps:
  108. - name: Generate summary
  109. run: |
  110. echo "## 📦 Packages Checks Summary" >> $GITHUB_STEP_SUMMARY
  111. echo "" >> $GITHUB_STEP_SUMMARY
  112. report() {
  113. local label="$1" result="$2"
  114. case "$result" in
  115. success) echo "✅ **${label}:** Passed" >> $GITHUB_STEP_SUMMARY ;;
  116. skipped) echo "⏭️ **${label}:** Skipped (no packages/** changes)" >> $GITHUB_STEP_SUMMARY ;;
  117. *) echo "❌ **${label}:** ${result}" >> $GITHUB_STEP_SUMMARY ;;
  118. esac
  119. }
  120. report "Change Detection" "${{ needs.check-changes.result }}"
  121. report "CLI" "${{ needs.cli-checks.result }}"
  122. report "Compatibility Layer" "${{ needs.compatibility-layer-checks.result }}"
  123. echo "" >> $GITHUB_STEP_SUMMARY
  124. FAILED=0
  125. [ "${{ needs.check-changes.result }}" != "success" ] && FAILED=1
  126. for result in "${{ needs.cli-checks.result }}" "${{ needs.compatibility-layer-checks.result }}"; do
  127. if [ "$result" != "success" ] && [ "$result" != "skipped" ]; then
  128. FAILED=1
  129. fi
  130. done
  131. if [ $FAILED -eq 0 ]; then
  132. echo "### ✅ Required Package Checks Passed" >> $GITHUB_STEP_SUMMARY
  133. else
  134. echo "### ❌ Some Package Checks Failed" >> $GITHUB_STEP_SUMMARY
  135. exit 1
  136. fi