ci.yml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. name: CI
  2. on:
  3. workflow_dispatch:
  4. push:
  5. branches:
  6. - main
  7. merge_group:
  8. pull_request:
  9. paths-ignore:
  10. - ".vscode/**"
  11. - "**/*.md"
  12. - ".github/ISSUE_TEMPLATE/**"
  13. # Automatically cancel older in-progress jobs on the same branch
  14. concurrency:
  15. group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }}
  16. cancel-in-progress: true
  17. defaults:
  18. run:
  19. shell: bash
  20. env:
  21. TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
  22. TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
  23. FORCE_COLOR: true
  24. ASTRO_TELEMETRY_DISABLED: true
  25. # 7 GiB by default on GitHub, setting to 6 GiB
  26. # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
  27. NODE_OPTIONS: --max-old-space-size=6144
  28. jobs:
  29. # Build primes out Turbo build cache and pnpm cache
  30. build:
  31. name: "Build: ${{ matrix.os }}"
  32. runs-on: ${{ matrix.os }}
  33. timeout-minutes: 3
  34. strategy:
  35. matrix:
  36. OS: [ubuntu-latest, windows-latest]
  37. NODE_VERSION: [18]
  38. fail-fast: true
  39. steps:
  40. # Disable crlf so all OS can share the same Turbo cache
  41. # https://github.com/actions/checkout/issues/135
  42. - name: Disable git crlf
  43. run: git config --global core.autocrlf false
  44. - name: Checkout
  45. uses: actions/checkout@v4
  46. - name: Setup PNPM
  47. uses: pnpm/action-setup@v2
  48. - name: Setup node@${{ matrix.NODE_VERSION }}
  49. uses: actions/setup-node@v4
  50. with:
  51. node-version: ${{ matrix.NODE_VERSION }}
  52. cache: "pnpm"
  53. - name: Install dependencies
  54. run: pnpm install
  55. # Only build in ubuntu as windows can share the build cache.
  56. # Also only build in core repo as forks don't have access to the Turbo cache.
  57. - name: Build Packages
  58. if: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'withastro' }}
  59. run: pnpm run build
  60. lint:
  61. name: Lint
  62. runs-on: ubuntu-latest
  63. timeout-minutes: 5
  64. needs: build
  65. steps:
  66. - name: Disable git crlf
  67. run: git config --global core.autocrlf false
  68. - name: Checkout
  69. uses: actions/checkout@v4
  70. - name: Setup PNPM
  71. uses: pnpm/action-setup@v2
  72. - name: Setup Node
  73. uses: actions/setup-node@v4
  74. with:
  75. node-version: 18
  76. cache: "pnpm"
  77. - name: Install dependencies
  78. run: pnpm install
  79. - name: Build Packages
  80. run: pnpm run build
  81. - name: Lint
  82. run: pnpm run lint
  83. - name: Format Check
  84. run: pnpm run format --check
  85. test:
  86. name: "Test: ${{ matrix.os }} (node@${{ matrix.NODE_VERSION }})"
  87. runs-on: ${{ matrix.os }}
  88. timeout-minutes: 25
  89. needs: build
  90. strategy:
  91. matrix:
  92. OS: [ubuntu-latest]
  93. NODE_VERSION: [18, 20.5.1]
  94. include:
  95. - os: macos-14
  96. NODE_VERSION: 18
  97. - os: windows-latest
  98. NODE_VERSION: 18.17.1
  99. fail-fast: false
  100. env:
  101. NODE_VERSION: ${{ matrix.NODE_VERSION }}
  102. steps:
  103. - name: Disable git crlf
  104. run: git config --global core.autocrlf false
  105. - name: Checkout
  106. uses: actions/checkout@v4
  107. - name: Setup PNPM
  108. uses: pnpm/action-setup@v2
  109. - name: Setup node@${{ matrix.NODE_VERSION }}
  110. uses: actions/setup-node@v4
  111. with:
  112. node-version: ${{ matrix.NODE_VERSION }}
  113. cache: "pnpm"
  114. - name: Install dependencies
  115. run: pnpm install
  116. - name: Build Packages
  117. run: pnpm run build
  118. - name: Test
  119. run: pnpm run test
  120. e2e:
  121. name: "Test (E2E): ${{ matrix.os }} (node@${{ matrix.NODE_VERSION }})"
  122. runs-on: ${{ matrix.os }}
  123. timeout-minutes: 25
  124. needs: build
  125. strategy:
  126. matrix:
  127. OS: [ubuntu-latest, windows-latest]
  128. NODE_VERSION: [18.17.1]
  129. fail-fast: false
  130. env:
  131. NODE_VERSION: ${{ matrix.NODE_VERSION }}
  132. steps:
  133. - name: Disable git crlf
  134. run: git config --global core.autocrlf false
  135. - name: Checkout
  136. uses: actions/checkout@v4
  137. - name: Setup PNPM
  138. uses: pnpm/action-setup@v2
  139. - name: Setup node@${{ matrix.NODE_VERSION }}
  140. uses: actions/setup-node@v4
  141. with:
  142. node-version: ${{ matrix.NODE_VERSION }}
  143. cache: "pnpm"
  144. - name: Install dependencies
  145. run: pnpm install
  146. - name: Build Packages
  147. run: pnpm run build
  148. - name: Test
  149. run: pnpm run test:e2e
  150. smoke:
  151. name: "Test (Smoke): ${{ matrix.os }} (node@${{ matrix.NODE_VERSION }})"
  152. runs-on: ${{ matrix.os }}
  153. timeout-minutes: 25
  154. needs: build
  155. strategy:
  156. matrix:
  157. OS: [ubuntu-latest, windows-latest]
  158. NODE_VERSION: [18]
  159. env:
  160. NODE_VERSION: ${{ matrix.NODE_VERSION }}
  161. steps:
  162. - name: Disable git crlf
  163. run: git config --global core.autocrlf false
  164. - name: Checkout
  165. uses: actions/checkout@v4
  166. - name: Setup PNPM
  167. uses: pnpm/action-setup@v2
  168. - name: Setup node@${{ matrix.NODE_VERSION }}
  169. uses: actions/setup-node@v4
  170. with:
  171. node-version: ${{ matrix.NODE_VERSION }}
  172. cache: "pnpm"
  173. - name: Checkout docs
  174. uses: actions/checkout@v4
  175. with:
  176. repository: withastro/docs
  177. path: smoke/docs
  178. - name: Install dependencies
  179. run: pnpm install --no-frozen-lockfile
  180. # Reset lockfile changes so that Turbo can reuse the old build cache
  181. - name: Reset lockfile changes
  182. run: git reset --hard
  183. - name: Build Packages
  184. run: pnpm run build
  185. - name: Remove docs translations except for English and Korean
  186. run: find smoke/docs/src/content/docs ! -name 'en' ! -name 'ko' -type d -mindepth 1 -maxdepth 1 -exec rm -rf {} +
  187. - name: Check if docs changed
  188. id: changes
  189. uses: dorny/paths-filter@v3
  190. with:
  191. filters: |
  192. docs:
  193. - 'packages/integrations/*/README.md'
  194. - 'packages/astro/src/@types/astro.ts'
  195. - 'packages/astro/src/core/errors/errors-data.ts'
  196. - name: Build autogenerated docs pages from current astro branch
  197. if: ${{ steps.changes.outputs.docs == 'true' }}
  198. run: cd smoke/docs && pnpm docgen && pnpm docgen:errors
  199. env:
  200. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  201. SOURCE_REPO: ${{ github.event.pull_request.head.repo.full_name || github.event.repository.full_name }}
  202. SOURCE_BRANCH: ${{ github.head_ref || github.ref_name }}
  203. - name: Test
  204. run: pnpm run test:smoke
  205. env:
  206. SKIP_OG: true
  207. PUBLIC_TWO_LANG: true