-
Notifications
You must be signed in to change notification settings - Fork 705
208 lines (180 loc) · 6.49 KB
/
Copy pathjs-ci.yml
File metadata and controls
208 lines (180 loc) · 6.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
name: 'ci / Front End'
on:
workflow_dispatch:
push:
branches:
- main
- 6.x
pull_request:
concurrency:
group: js-ci-${{ github.ref }}
cancel-in-progress: true
env:
NODE_VERSION: '24'
PHP_VERSION: '8.5'
permissions:
contents: read
jobs:
setup:
name: 'Setup / Install + Build + Generate'
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
cache-key: ${{ steps.cache-key.outputs.value }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
- name: Setup Vite+
uses: voidzero-dev/setup-vp@v1
with:
node-version: ${{ env.NODE_VERSION }}
cache: true
- name: Compute cache key
id: cache-key
# Hash everything that can affect installed deps, the cp build, or the
# generated TS/wayfinder files. PHP source is included because both
# `testbench typescript:transform` and `testbench wayfinder:generate`
# derive their output from controllers, DTOs, and routes in src/.
run: |
echo "value=js-ci-v3-${{ runner.os }}-${{ hashFiles('package-lock.json', 'composer.lock', 'package.json', 'packages/*/package.json', 'packages/craftcms-ui/src/**', 'packages/craftcms-ui/tsconfig*.json', 'packages/craftcms-ui/vite.config.*', 'packages/craftcms-ui/tsdown.config.*', 'packages/craftcms-garnish/src/**', 'packages/craftcms-garnish/tsconfig*.json', 'packages/craftcms-garnish/vite.config.*', 'src/**/*.php', 'workbench/**/*.php') }}" >> "$GITHUB_OUTPUT"
- name: Restore install + build + generated cache
id: cache
uses: actions/cache@v4
with:
path: |
node_modules
packages/*/node_modules
packages/craftcms-ui/dist
packages/craftcms-garnish/dist
vendor
resources/js/actions
resources/js/routes
resources/js/wayfinder
resources/js/generated
key: ${{ steps.cache-key.outputs.value }}
- name: Install Composer dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: composer install --no-interaction --no-progress
- name: Install frontend dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: vp install --frozen-lockfile
env:
CRAFT_FONTAWESOME_TOKEN: ${{ secrets.CRAFT_FONTAWESOME_TOKEN }}
# Build the garnish package so its `dist/*.d.ts` exist — `vue-tsc` resolves
# `@craftcms/garnish` from `dist` (its `types`), and dist is gitignored.
# Without this the typecheck job fails to resolve the module.
- name: Build @craftcms/garnish
if: steps.cache.outputs.cache-hit != 'true'
run: vp run build:garnish
- name: Build @craftcms/ui
if: steps.cache.outputs.cache-hit != 'true'
run: vp run build:ui
# `build:cp` does not produce the Custom Elements Manifest (only the
# Storybook pre-hooks do), so generate it explicitly — it lands in the
# packages/craftcms-cp/dist cache path above for the downstream jobs.
- name: Build Custom Elements Manifest
if: steps.cache.outputs.cache-hit != 'true'
run: vp run @craftcms/ui#build:manifest
- name: Generate TypeScript types
if: steps.cache.outputs.cache-hit != 'true'
run: vp run generate:types
- name: Generate Wayfinder routes
if: steps.cache.outputs.cache-hit != 'true'
run: vp run generate:wayfinder
eslint:
name: 'Code Quality / Oxlint'
runs-on: ubuntu-latest
timeout-minutes: 5
needs: setup
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Vite+
uses: voidzero-dev/setup-vp@v1
with:
node-version: ${{ env.NODE_VERSION }}
cache: true
- name: Restore install + build + generated cache
uses: actions/cache@v4
with:
path: |
node_modules
packages/*/node_modules
packages/craftcms-ui/dist
packages/craftcms-garnish/dist
vendor
resources/js/actions
resources/js/routes
resources/js/wayfinder
resources/js/generated
key: ${{ needs.setup.outputs.cache-key }}
- name: Run Oxlint
run: vp lint resources/js/
typecheck:
name: 'Code Quality / TypeScript'
runs-on: ubuntu-latest
timeout-minutes: 5
needs: setup
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Vite+
uses: voidzero-dev/setup-vp@v1
with:
node-version: ${{ env.NODE_VERSION }}
cache: true
- name: Restore install + build + generated cache
uses: actions/cache@v4
with:
path: |
node_modules
packages/*/node_modules
packages/craftcms-ui/dist
packages/craftcms-garnish/dist
vendor
resources/js/actions
resources/js/routes
resources/js/wayfinder
resources/js/generated
key: ${{ needs.setup.outputs.cache-key }}
# Skip the `pretypecheck` hook (it would re-run generate:types +
# generate:wayfinder, which need PHP/Composer that this job doesn't set
# up — the setup job already produced and cached the output).
- name: Run TypeScript type check
run: vp run typecheck
test-ui:
name: 'Tests / @craftcms/ui'
runs-on: ubuntu-latest
timeout-minutes: 10
needs: setup
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Vite+
uses: voidzero-dev/setup-vp@v1
with:
node-version: ${{ env.NODE_VERSION }}
cache: true
- name: Restore install + build + generated cache
uses: actions/cache@v4
with:
path: |
node_modules
packages/*/node_modules
packages/craftcms-ui/dist
packages/craftcms-garnish/dist
vendor
resources/js/actions
resources/js/routes
resources/js/wayfinder
resources/js/generated
key: ${{ needs.setup.outputs.cache-key }}
# The storybook tests run in real Chromium via @vitest/browser-playwright.
- name: Install Playwright Chromium
run: vp exec playwright install --with-deps chromium
- name: Run @craftcms/ui tests
run: vp run test:ui