-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
265 lines (227 loc) · 7.95 KB
/
prod-test.yml
File metadata and controls
265 lines (227 loc) · 7.95 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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
name: Prod
on:
push:
branches:
- main
- next
- v*
- patch-release
- "!renovate/**"
pull_request:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build
uses: ./.github/workflows/_build.yml
lint:
name: Lint
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
cache: "yarn"
- name: Install Dependencies
run: yarn install --immutable
- name: Download Artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: dist
path: dist
- name: Lint Code
run: yarn test:production-lint
test:
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os:
- "ubuntu-latest"
- "macos-latest"
- "windows-latest"
node:
# Latest even version
- "24"
# Minimal version for production
- "14"
include:
- os: "ubuntu-latest"
# Pick a version that is fast (normally highest LTS version)
node: "24"
FULL_TEST: true
# Versions not tested on linux, normally only even versions
# If latest version is an odd number, it can be listed below too
- os: "ubuntu-latest"
node: "25"
- os: "ubuntu-latest"
node: "22"
- os: "ubuntu-latest"
node: "20"
- os: "ubuntu-latest"
node: "18"
- os: "ubuntu-latest"
node: "16"
# Tests on Intel Mac x Node.js 14 ( https://github.com/prettier/prettier/issues/16248 )
- os: "macos-15-intel"
node: "14"
# setup-node does not support Node.js 14 x M1 Mac
exclude:
- os: "macos-latest"
node: "14"
env:
FULL_TEST: ${{ matrix.FULL_TEST }}
name: ${{ matrix.FULL_TEST && '[Full Test] ' || '' }} Node.js ${{ matrix.node }} on ${{ startsWith(matrix.os, 'macos') && 'MacOS' || startsWith(matrix.os, 'windows') && 'Windows' || 'Linux' }}
runs-on: ${{ matrix.os }}
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install yarn@3
if: ${{ matrix.node == '14' || matrix.node == '16' }}
run: |
yarn set version 3
yarn config set httpRetry 10
cat .yarnrc.yml
- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ matrix.node }}
cache: "yarn"
- name: Downgrade Jest
if: ${{ matrix.node == '14' || matrix.node == '16' }}
run: node ./scripts/prepare-test-for-legacy-nodejs.js --node-version ${{ matrix.node }}
- name: Install Dependencies(yarn@3,mutable)
if: ${{ matrix.node == '14' || matrix.node == '16' }}
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
run: yarn install
- name: Install Dependencies
run: yarn install --immutable
- name: Download Artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: dist
path: dist
- name: Run Tests
run: yarn test:production
- name: Run Format Tests (standalone)
run: yarn test:production-standalone
- name: "`--debug-benchmark` flag"
if: ${{ matrix.node != '14' && matrix.os != 'windows-latest' }}
working-directory: dist/prettier
run: node bin/prettier.cjs --debug-benchmark package.json 2>&1 >/dev/null | grep "Latency avg" || exit 1
browser:
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os:
- "ubuntu-latest"
# - "macos-latest"
- "windows-latest"
browser:
- "chrome"
- "firefox"
include:
# It's slow on firefox
- os: "ubuntu-latest"
browser: "chrome"
FULL_TEST: true
exclude:
# Hangs https://github.com/prettier/prettier/pull/18716
- os: "windows-latest"
browser: "chrome"
env:
FULL_TEST: ${{ matrix.FULL_TEST }}
TEST_RUNTIME_BROWSER: ${{ matrix.browser }}
name: ${{ matrix.FULL_TEST && '[Full Test] ' || '' }} Browser(${{ matrix.browser }}) on ${{ startsWith(matrix.os, 'macos') && 'MacOS' || startsWith(matrix.os, 'windows') && 'Windows' || 'Linux' }}
runs-on: ${{ matrix.os }}
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
cache: "yarn"
- name: Puppeteer cache
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
with:
path: .tmp/puppeteer/
key: v1
# https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
- run: echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
if: matrix.os == 'ubuntu-latest'
- name: Install Dependencies
run: yarn install --immutable
- name: Download Artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: dist
path: dist
- name: Run Tests (ESM)
env:
TEST_BUNDLE_FORMAT: esm
run: yarn test:production:browser
- name: Run Tests (UMD)
env:
TEST_BUNDLE_FORMAT: umd
run: yarn test:production:browser
cli:
name: CLI
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Download Artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: dist
path: dist
- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
package-manager-cache: false
- name: "`--debug-benchmark` flag"
working-directory: dist/prettier
run: node bin/prettier.cjs --debug-benchmark package.json 2>&1 >/dev/null | grep "'--debug-benchmark' requires the 'tinybench' package to be installed." || exit 1
- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: "0.10.48"
package-manager-cache: false
- name: Validate Node.js Version
run: node -v | grep "v0.10.48" || exit 1
- name: Run CLI on Node.js v0.10.48
working-directory: dist/prettier
run: node bin/prettier.cjs --version 2>&1 >/dev/null | grep "prettier requires at least version 14 of Node, please upgrade" || exit 1
preview:
if: github.repository == 'prettier/prettier'
name: Preview release
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
# `pkg-pr-new` requires Node.js v20
node-version: latest
- name: Download Artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: dist
path: dist
- name: Release
working-directory: dist
run: |
yarn dlx pkg-pr-new publish "./*" --compact --packageManager=yarn