-
Notifications
You must be signed in to change notification settings - Fork 1.9k
528 lines (528 loc) · 18.6 KB
/
Copy pathbuild_and_test.yml
File metadata and controls
528 lines (528 loc) · 18.6 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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
name: build_and_test
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- v*
tags:
- v*
env:
FLOW_BIN_PRIVATE_KEY_BASE64: ${{ secrets.FLOW_BIN_PRIVATE_KEY_BASE64 }}
FLOW_BOT_EMAIL: ${{ secrets.FLOW_BOT_EMAIL }}
FLOW_BOT_TOKEN: ${{ secrets.FLOW_BOT_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
jobs:
build_and_test:
runs-on: ubuntu-22.04
env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
RUSTC_BOOTSTRAP: 1
RUST_MIN_STACK: 5242880
steps:
- uses: actions/checkout@v3.6.0
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
- name: set up rust cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: flow-rust-port
- name: Build Rust port
working-directory: rust_port
run: cargo build
- name: Test Rust port
working-directory: rust_port
run: cargo test
- name: Build Rust port binary
working-directory: rust_port
env:
CARGO_PROFILE_RELEASE_STRIP: 'true'
CARGO_PROFILE_RELEASE_LTO: fat
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '1'
run: cargo build --release --bin flow_cli
- name: Create artifacts
run: |-
mkdir -p bin/rust-port-linux dist/flow
cp rust_port/target/release/flow_cli bin/rust-port-linux/flow
cp bin/rust-port-linux/flow dist/flow/flow
cd dist && zip -r flow-linux64.zip flow/flow
- uses: actions/upload-artifact@v4.4.0
with:
name: build_and_test_rust_port_bin
path: bin/rust-port-linux/flow
- uses: actions/upload-artifact@v4.4.0
with:
name: build_and_test_rust_port_dist
path: dist/flow-linux64.zip
build_linux_arm64:
runs-on: 4-core-ubuntu-arm
env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
RUSTC_BOOTSTRAP: 1
RUST_MIN_STACK: 5242880
steps:
- uses: actions/checkout@v3.6.0
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
- name: set up rust cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: flow-rust-port-linux-arm64
workspaces: rust_port -> target
- name: Build Rust port binary
working-directory: rust_port
env:
CARGO_PROFILE_RELEASE_STRIP: 'true'
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '1'
run: cargo build --release --bin flow_cli
- name: Create artifacts
run: |-
mkdir -p bin/rust-port-linux-arm64 dist/flow
cp rust_port/target/release/flow_cli bin/rust-port-linux-arm64/flow
cp bin/rust-port-linux-arm64/flow dist/flow/flow
cd dist && zip -r flow-linux64-arm64.zip flow/flow
- uses: actions/upload-artifact@v4.4.0
with:
name: build_rust_port_linux_arm64_bin
path: bin/rust-port-linux-arm64/flow
- uses: actions/upload-artifact@v4.4.0
with:
name: build_rust_port_linux_arm64_dist
path: dist/flow-linux64-arm64.zip
build_macos_arm64:
runs-on: macos-15
env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
RUSTC_BOOTSTRAP: 1
RUST_MIN_STACK: 5242880
steps:
- uses: actions/checkout@v3.6.0
- uses: maxim-lobanov/setup-xcode@v1.6.0
with:
xcode-version: '16.4.0'
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
- name: set up rust cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: flow-rust-port-macos-arm64
workspaces: rust_port -> target
- name: Build Rust port binary
working-directory: rust_port
env:
CARGO_PROFILE_RELEASE_STRIP: 'true'
CARGO_PROFILE_RELEASE_LTO: fat
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '1'
run: cargo build --release --bin flow_cli
- name: Create artifacts
run: |-
mkdir -p bin/rust-port-macos-arm64 dist/flow
cp rust_port/target/release/flow_cli bin/rust-port-macos-arm64/flow
cp bin/rust-port-macos-arm64/flow dist/flow/flow
cd dist && zip -r flow-osx-arm64.zip flow/flow
- uses: actions/upload-artifact@v4.4.0
with:
name: build_rust_port_macos_arm64_bin
path: bin/rust-port-macos-arm64/flow
- uses: actions/upload-artifact@v4.4.0
with:
name: build_rust_port_macos_arm64_dist
path: dist/flow-osx-arm64.zip
build_win:
runs-on: windows-2022
env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
RUSTC_BOOTSTRAP: 1
RUST_MIN_STACK: 5242880
steps:
- uses: actions/checkout@v3.6.0
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
- name: set up rust cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: flow-rust-port-win
workspaces: rust_port -> target
- name: Build Rust port binary
working-directory: rust_port
env:
CARGO_PROFILE_RELEASE_STRIP: 'true'
CARGO_PROFILE_RELEASE_LTO: fat
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '1'
run: cargo build --release --bin flow_cli
- name: Create artifacts
run: |-
New-Item -ItemType Directory -Force bin\rust-port-win64
New-Item -ItemType Directory -Force dist\flow
Copy-Item rust_port\target\release\flow_cli.exe bin\rust-port-win64\flow.exe
Copy-Item bin\rust-port-win64\flow.exe dist\flow\flow.exe
Push-Location dist
Compress-Archive -Path flow -DestinationPath flow-win64.zip -Force
Pop-Location
- uses: actions/upload-artifact@v4.4.0
with:
name: build_rust_port_win_bin
path: bin/rust-port-win64/flow.exe
- uses: actions/upload-artifact@v4.4.0
with:
name: build_rust_port_win_dist
path: dist/flow-win64.zip
build_js:
runs-on: ubuntu-22.04
env:
NODE_VERSION: 24.14.1
NPM_VERSION: 11.11.0
YARN_VERSION: 1.22.21
EMSDK_VERSION: 3.1.44
BINARYEN_VERSION: 121
BINARYEN_SHA256: c90e0e295e8f8484ba5b47da92f26e5d1d18db6cd2fcc0c5cc265a5a73609f17
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
RUSTC_BOOTSTRAP: 1
RUST_MIN_STACK: 5242880
steps:
- uses: actions/checkout@v3.6.0
- name: Install Node
uses: actions/setup-node@v4.4.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install npm and Yarn
run: npm install --global npm@${NPM_VERSION} yarn@${YARN_VERSION}
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2026-04-14
targets: wasm32-unknown-emscripten
components: rust-src
- name: Install Emscripten
run: |
git clone --depth 1 --branch "${EMSDK_VERSION}" https://github.com/emscripten-core/emsdk.git "${RUNNER_TEMP}/emsdk"
"${RUNNER_TEMP}/emsdk/emsdk" install "${EMSDK_VERSION}"
"${RUNNER_TEMP}/emsdk/emsdk" activate "${EMSDK_VERSION}"
binaryen_archive="${RUNNER_TEMP}/binaryen-version_${BINARYEN_VERSION}-x86_64-linux.tar.gz"
curl --fail --location --retry 3 --output "${binaryen_archive}" "https://github.com/WebAssembly/binaryen/releases/download/version_${BINARYEN_VERSION}/binaryen-version_${BINARYEN_VERSION}-x86_64-linux.tar.gz"
echo "${BINARYEN_SHA256} ${binaryen_archive}" | sha256sum --check -
mkdir -p "${RUNNER_TEMP}/binaryen"
tar -xzf "${binaryen_archive}" -C "${RUNNER_TEMP}/binaryen"
echo "${RUNNER_TEMP}/emsdk" >> "${GITHUB_PATH}"
echo "${RUNNER_TEMP}/emsdk/upstream/emscripten" >> "${GITHUB_PATH}"
echo "EMSDK=${RUNNER_TEMP}/emsdk" >> "${GITHUB_ENV}"
echo "EM_CONFIG=${RUNNER_TEMP}/emsdk/.emscripten" >> "${GITHUB_ENV}"
echo "EM_BINARYEN_ROOT=${RUNNER_TEMP}/binaryen/binaryen-version_${BINARYEN_VERSION}" >> "${GITHUB_ENV}"
echo "EM_CACHE=${HOME}/.emscripten_cache_${EMSDK_VERSION}" >> "${GITHUB_ENV}"
echo "EM_IGNORE_SANITY=1" >> "${GITHUB_ENV}"
- name: Verify pinned tool versions
run: |
test "$(node --version)" = "v${NODE_VERSION}"
test "$(npm --version)" = "${NPM_VERSION}"
test "$(yarn --version)" = "${YARN_VERSION}"
rustup show active-toolchain
rustc --version
emcc --version
test "$("${EM_BINARYEN_ROOT}/bin/wasm-opt" --version)" = "wasm-opt version ${BINARYEN_VERSION} (version_${BINARYEN_VERSION})"
- name: Build flow-parser WASM artifact
run: packages/scripts/buildFlowParserWasm.sh "${RUNNER_TEMP}/flow-parser-wasm.js"
- name: Install package dependencies
working-directory: packages
run: yarn install --frozen-lockfile
- name: Build packages
working-directory: packages
run: ./scripts/build.sh "${RUNNER_TEMP}/flow-parser-wasm.js"
- name: Test packages
working-directory: packages
run: yarn test -- --testPathPatterns='flow-parser|babel-plugin-syntax-flow-parser|flow-eslint|flow-transform'
- name: Create package artifact
run: |
mkdir -p "${RUNNER_TEMP}/build_js_packages/flow-parser" "${RUNNER_TEMP}/build_js_packages/flow-estree"
cp -R packages/flow-parser/dist "${RUNNER_TEMP}/build_js_packages/flow-parser/dist"
cp -R packages/flow-estree/dist "${RUNNER_TEMP}/build_js_packages/flow-estree/dist"
- uses: actions/upload-artifact@v4.4.0
with:
name: build_js_packages
path: ${{ runner.temp }}/build_js_packages
build_flow_js:
runs-on: ubuntu-22.04
env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
RUSTC_BOOTSTRAP: 1
RUST_MIN_STACK: 5242880
steps:
- uses: actions/checkout@v3.6.0
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
with:
targets: wasm32-unknown-emscripten
components: rust-src
- name: Install Emscripten
uses: mymindstorm/setup-emsdk@v14
with:
version: 3.1.44
- uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: set up rust cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: flow-rust-port-flow-js
- name: Build and test Rust flow.js
run: make test-js FLOW_JS_IMPL=rust-wasm
- uses: actions/upload-artifact@v4.4.0
with:
name: build_js_rust_port_bin
path: bin/flow.js
runtests_linux:
runs-on: ubuntu-22.04
needs:
- build_and_test
env:
FLOW_RUNTESTS_PARALLELISM: 8
steps:
- uses: actions/checkout@v3.6.0
- uses: actions/download-artifact@v4.1.7
with:
name: build_and_test_rust_port_bin
path: bin/rust-port-linux
- run: chmod +x bin/rust-port-linux/flow
- name: Run Rust port tests
run: ./runtests.sh bin/rust-port-linux/flow
runtests_macos_arm:
runs-on: macos-15
needs:
- build_macos_arm64
env:
FLOW_RUNTESTS_PARALLELISM: 8
steps:
- uses: maxim-lobanov/setup-xcode@v1.6.0
with:
xcode-version: '16.4.0'
- uses: actions/checkout@v3.6.0
- uses: actions/download-artifact@v4.1.7
with:
name: build_rust_port_macos_arm64_bin
path: bin/rust-port-macos-arm64
- run: chmod +x bin/rust-port-macos-arm64/flow
- name: Run Rust port tests
run: ./runtests.sh bin/rust-port-macos-arm64/flow
tool_test_linux:
runs-on: ubuntu-22.04
needs:
- build_and_test
steps:
- uses: actions/checkout@v3.6.0
- uses: actions/download-artifact@v4.1.7
with:
name: build_and_test_rust_port_bin
path: bin/rust-port-linux
- run: chmod +x bin/rust-port-linux/flow
- name: Install tool deps from yarn
run: (cd packages/flow-dev-tools && yarn install | cat)
- name: Run Rust port newtests
run: ./tool test -p 4 --check check --bin bin/rust-port-linux/flow
tool_test_macos:
runs-on: macos-15
needs:
- build_macos_arm64
steps:
- uses: maxim-lobanov/setup-xcode@v1.6.0
with:
xcode-version: '16.4.0'
- uses: actions/checkout@v3.6.0
- uses: actions/download-artifact@v4.1.7
with:
name: build_rust_port_macos_arm64_bin
path: bin/rust-port-macos-arm64
- run: chmod +x bin/rust-port-macos-arm64/flow
- name: Install tool deps from yarn
run: (cd packages/flow-dev-tools && yarn install | cat)
- name: Run Rust port newtests
run: ./tool test --check check --bin bin/rust-port-macos-arm64/flow
tool_test_win:
runs-on: windows-2022
needs:
- build_win
steps:
- uses: actions/checkout@v3.6.0
- uses: actions/download-artifact@v4.1.7
with:
name: build_rust_port_win_bin
path: bin/rust-port-win64
- name: Install tool deps from yarn
run: |-
cd packages/flow-dev-tools
yarn install --ignore-scripts --pure-lockfile
- name: Set TMP env var for consistency
run: |-
echo "TMP=$env:USERPROFILE\AppData\Local\Temp" >> $env:GITHUB_ENV
echo "TEMP=$env:USERPROFILE\AppData\Local\Temp" >> $env:GITHUB_ENV
- name: Run Rust port newtests
run: node packages/flow-dev-tools/bin/tool test --check check --bin bin/rust-port-win64/flow.exe --parallelism 1
npm_pack:
runs-on: ubuntu-22.04
needs:
- build_js
steps:
- uses: actions/checkout@v3.6.0
- uses: actions/download-artifact@v4.1.7
with:
name: build_js_packages
path: ${{ runner.temp }}/build_js_packages
- name: Install generated package artifacts
run: |
test -f "${RUNNER_TEMP}/build_js_packages/flow-parser/dist/index.js"
test -f "${RUNNER_TEMP}/build_js_packages/flow-estree/dist/index.js"
test ! -e packages/flow-parser/dist
test ! -e packages/flow-estree/dist
cp -R "${RUNNER_TEMP}/build_js_packages/flow-parser/dist" packages/flow-parser/dist
cp -R "${RUNNER_TEMP}/build_js_packages/flow-estree/dist" packages/flow-estree/dist
- name: Pack flow-estree
run: |
test -f packages/flow-estree/dist/index.js
make dist/npm-flow-estree.tgz
- name: Pack flow-parser
run: |
test -f packages/flow-parser/dist/index.js
make dist/npm-flow-parser.tgz
- name: Pack flow-remove-types and flow-node
run: |
rm -rf packages/flow-node
cp -r packages/flow-remove-types/ packages/flow-node/
sed -i '0,/flow-remove-types/s//flow-node/' packages/flow-node/package.json
make dist/npm-flow-remove-types.tgz
make dist/npm-flow-node.tgz
- name: Pack flow-upgrade
run: |
cd packages/flow-upgrade
yarn install
yarn build
yarn test
cd ../..
make dist/npm-flow-upgrade.tgz
- uses: actions/upload-artifact@v4.4.0
with:
name: npm_pack
path: |
dist/npm-flow-estree.tgz
dist/npm-flow-parser.tgz
dist/npm-flow-node.tgz
dist/npm-flow-remove-types.tgz
dist/npm-flow-upgrade.tgz
- name: Deploy to npm
if: contains(github.event_name, 'push') && startsWith( github.ref, 'refs/tags/v' )
run: .circleci/deploy_npm.sh
website_deploy:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-22.04
needs:
- build_and_test
- build_flow_js
steps:
- uses: actions/checkout@v3.6.0
with:
# Full history so Docusaurus's `showLastUpdateTime` can find the real
# last-touched commit for each doc page; the default shallow clone
# only sees HEAD and makes every page show the deploy date.
fetch-depth: 0
- uses: actions/download-artifact@v4.1.7
with:
name: build_and_test_rust_port_bin
path: bin/rust-port-linux
- uses: actions/download-artifact@v4.1.7
with:
name: build_js_rust_port_bin
path: dist
- run: chmod +x bin/rust-port-linux/flow
- uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: Node cache
uses: actions/cache@v4
with:
key: v2-website-${{ github.ref_name }}-${{ hashFiles('website/yarn.lock') }}
path: website/node_modules
- name: Install yarn deps
run: cd website && yarn install
- name: Build website
run: PATH=${{ github.workspace }}/bin/rust-port-linux:$PATH .circleci/build_website.sh
- name: Publish website to GitHub Pages
run: |-
cd website
yarn add gh-pages
yarn gh-pages -d build -u "flow-bot <flow-bot@users.noreply.github.com>" --repo https://${FLOW_BOT_TOKEN}@github.com/facebook/flow.git --no-history
# Deploy jobs
github_upload:
if: contains(github.event_name, 'push') && startsWith( github.ref, 'refs/tags/v' )
runs-on: ubuntu-22.04
needs:
- build_and_test
- build_linux_arm64
- build_macos_arm64
- build_win
steps:
- uses: actions/checkout@v3.6.0
- uses: actions/download-artifact@v4.1.7
with:
name: build_and_test_rust_port_dist
path: dist
- name: Upload Linux binary (x86_64)
run: .circleci/github_upload.sh dist/flow-linux64.zip "flow-linux64-${{ github.ref_name }}.zip"
- uses: actions/download-artifact@v4.1.7
with:
name: build_rust_port_linux_arm64_dist
path: dist
- name: Upload Linux binary (arm64)
run: .circleci/github_upload.sh dist/flow-linux64-arm64.zip "flow-linux-arm64-${{ github.ref_name }}.zip"
- uses: actions/download-artifact@v4.1.7
with:
name: build_rust_port_macos_arm64_dist
path: dist
- name: Upload Mac binary (arm64)
run: .circleci/github_upload.sh dist/flow-osx-arm64.zip "flow-osx-arm64-${{ github.ref_name }}.zip"
- uses: actions/download-artifact@v4.1.7
with:
name: build_rust_port_win_dist
path: dist
- name: Upload Windows binary
run: .circleci/github_upload.sh dist/flow-win64.zip "flow-win64-${{ github.ref_name }}.zip"
flow_bin_deploy:
if: contains(github.event_name, 'push') && startsWith( github.ref, 'refs/tags/v' )
runs-on: ubuntu-22.04
needs:
- github_upload
steps:
- uses: actions/checkout@v3.6.0
- name: Deploy flow-bin
run: .circleci/deploy_flow_bin.sh
- uses: facebook/dotslash-publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
config: .github/dotslash-config.json
tag: ${{ github.ref_name }}
- name: Fill release notes
run: bash .github/scripts/update_github_release_notes.sh
try_flow_deploy:
if: contains(github.event_name, 'push') && startsWith( github.ref, 'refs/tags/v' )
runs-on: ubuntu-22.04
needs:
- build_flow_js
steps:
- uses: actions/checkout@v3.6.0
- uses: actions/download-artifact@v4.1.7
with:
name: build_js_rust_port_bin
path: dist
- name: Assemble files
run: |
cp dist/flow.js packages/try-flow-website-js/flow.js
cp -r lib packages/try-flow-website-js/flowlib
make dist/npm-try-flow-website-js.tgz
- name: Deploy to NPM
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
npm publish ./dist/npm-try-flow-website-js.tgz