forked from servo/mozjs
-
Notifications
You must be signed in to change notification settings - Fork 1
429 lines (409 loc) · 15.1 KB
/
Copy pathbuild.yml
File metadata and controls
429 lines (409 loc) · 15.1 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
name: Rust
on:
workflow_call:
inputs:
release:
required: true
type: boolean
rust_version:
required: false
# Keep the default in sync with `rust-toolchain.toml` and servo's MSRV!
default: "1.85.0"
type: string
env:
RUST_BACKTRACE: 1
SHELL: /bin/bash
CARGO_INCREMENTAL: 0
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MOZJS_CREATE_ARCHIVE: 1
jobs:
mac:
strategy:
fail-fast: false
matrix:
features: ["debugmozjs", '""']
platform:
- { target: aarch64-apple-darwin, os: macos-14 }
- { target: x86_64-apple-darwin, os: macos-13 }
runs-on: ${{ matrix.platform.os }}
env:
RUSTC_WRAPPER: sccache
CCACHE: sccache
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@v4
- name: Install deps
run: |
# Unlink and re-link to prevent errors when github mac runner images
# https://github.com/actions/setup-python/issues/577
brew list -1 | grep python | while read formula; do brew unlink $formula; brew link --overwrite $formula; done
brew install llvm yasm
- uses: dtolnay/rust-toolchain@master
id: toolchain
with:
toolchain: ${{ inputs.rust_version }}
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Build
run: |
cargo +${{ steps.toolchain.outputs.name }} build --verbose --features ${{ matrix.features }}
cargo +${{ steps.toolchain.outputs.name }} test --tests --examples --verbose --features ${{ matrix.features }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
if: ${{ inputs.release && matrix.features != 'debugmozjs' }}
with:
subject-path: ./target/libmozjs-${{ matrix.platform.target }}.tar.gz
- name: Upload artifact
if: ${{ matrix.features != 'debugmozjs' }}
uses: actions/upload-artifact@v4
with:
path: ./target/libmozjs-${{ matrix.platform.target }}.tar.gz
name: libmozjs-${{ matrix.platform.target }}.tar.gz
linux:
env:
RUSTC_WRAPPER: "sccache"
CCACHE: sccache
SCCACHE_GHA_ENABLED: "true"
runs-on: ubuntu-22.04 # Needed for artifacts to work on older systems (due to glibc)
strategy:
fail-fast: false
matrix:
features: ["debugmozjs", '""']
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
id: toolchain
with:
toolchain: ${{ inputs.rust_version }}
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v2
with:
directory: ${{ runner.temp }}/llvm
version: "16.0"
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Build
run: |
cargo +${{ steps.toolchain.outputs.name }} build --verbose --features ${{ matrix.features }}
cargo +${{ steps.toolchain.outputs.name }} test --tests --examples --verbose --features ${{ matrix.features }}
- name: Check wrappers integrity
# we generate wrappers only without debugmozjs
if: ${{ matrix.features != 'debugmozjs' }}
run: |
bash ./mozjs/src/generate_wrappers.sh
git add --all .
git diff --staged --no-ext-diff --exit-code
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
if: ${{ inputs.release && matrix.features != 'debugmozjs' }}
with:
subject-path: ./target/libmozjs-x86_64-unknown-linux-gnu.tar.gz
- name: Upload artifact
if: ${{ matrix.features != 'debugmozjs' }}
uses: actions/upload-artifact@v4
with:
path: ./target/libmozjs-x86_64-unknown-linux-gnu.tar.gz
name: libmozjs-x86_64-unknown-linux-gnu.tar.gz
windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
features: ["debugmozjs", '""']
target: ["x86_64-pc-windows-msvc", "aarch64-pc-windows-msvc"]
env:
LINKER: "lld-link.exe"
CC: "clang-cl"
CXX: "clang-cl"
MOZTOOLS_PATH: "${{ github.workspace }}\\target\\dependencies\\moztools-4.0"
CCACHE: sccache
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
id: toolchain
with:
toolchain: ${{ inputs.rust_version }}
targets: ${{ matrix.target }}
- name: Install deps
run: |
curl -SL "https://github.com/servo/servo-build-deps/releases/download/msvc-deps/moztools-4.0.zip" --create-dirs -o target/dependencies/moztools.zip
cd target/dependencies && unzip -qo moztools.zip -d .
- name: Install LLVM 19
run: |
# MSVC has headers that require clang-19.
# remove when windows runner updates to llvm 19
iwr -useb get.scoop.sh -outfile 'install.ps1'
.\install.ps1 -RunAsAdmin
scoop install llvm@19.1.7 --global
# Prepend to path so we override the default LLVM installation in priority
echo "C:\ProgramData\scoop\apps\llvm\current\bin;" + (Get-Content $env:GITHUB_PATH -Raw) | Set-Content $env:GITHUB_PATH
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Build Windows
shell: cmd
run: |
cargo +${{ steps.toolchain.outputs.name }} build --verbose --target ${{ matrix.target }} --features ${{ matrix.features }}
- name: Test Windows
if: ${{ !contains(matrix.target, 'aarch64') }}
shell: cmd
run: |
cargo +${{ steps.toolchain.outputs.name }} test --tests --examples --verbose --target ${{ matrix.target }} --features ${{ matrix.features }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
if: ${{ inputs.release && !contains(matrix.target, 'aarch64') && matrix.features != 'debugmozjs' }}
with:
subject-path: ./target/${{ matrix.target }}/libmozjs-x86_64-pc-windows-msvc.tar.gz
- name: Upload artifact
if: ${{ !contains(matrix.target, 'aarch64') && matrix.features != 'debugmozjs' }}
uses: actions/upload-artifact@v4
with:
path: ./target/${{ matrix.target }}/libmozjs-x86_64-pc-windows-msvc.tar.gz
name: libmozjs-x86_64-pc-windows-msvc.tar.gz
android:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
[
"armv7-linux-androideabi",
"aarch64-linux-android",
"x86_64-linux-android",
]
steps:
- uses: actions/checkout@v4
- name: Install NDK
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r28b
- name: Install Rust
uses: dtolnay/rust-toolchain@master
id: toolchain
with:
toolchain: ${{ inputs.rust_version }}
targets: ${{ matrix.target }}
- name: Build
env:
ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
./android-build cargo +${{ steps.toolchain.outputs.name }} build --target="${{ matrix.target }}"
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
if: ${{ inputs.release }}
with:
subject-path: "./target/libmozjs-${{ matrix.target }}.tar.gz"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
path: ./target/libmozjs-${{ matrix.target }}.tar.gz
name: libmozjs-${{ matrix.target }}.tar.gz
ohos:
name: "OpenHarmony"
runs-on: ubuntu-latest
strategy:
matrix:
target: ["aarch64-unknown-linux-ohos", "x86_64-unknown-linux-ohos"]
steps:
- uses: actions/checkout@v4
- name: Setup OpenHarmony SDK
id: setup_sdk
uses: openharmony-rs/setup-ohos-sdk@v0.1
with:
version: "4.1"
- name: Install Rust
uses: dtolnay/rust-toolchain@master
id: toolchain
with:
toolchain: ${{ inputs.rust_version }}
targets: ${{ matrix.target }}
- name: Build (arch ${{ matrix.target }} )
env:
OHOS_SDK_NATIVE: ${{ steps.setup_sdk.outputs.ohos_sdk_native }}
run: |
./ohos-build cargo +${{ steps.toolchain.outputs.name }} build --target="${{ matrix.target }}"
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
if: ${{ inputs.release }}
with:
subject-path: "./target/libmozjs-${{ matrix.target }}.tar.gz"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
path: ./target/libmozjs-${{ matrix.target }}.tar.gz
name: libmozjs-${{ matrix.target }}.tar.gz
wasi:
name: wasm32-${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- wasip1
- wasip2
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
id: toolchain
with:
toolchain: "1.85.0"
targets: "wasm32-${{ matrix.target }}"
- uses: bytecodealliance/actions/wasmtime/setup@v1
- name: Install WASI-SDK
run: |
cd /tmp
curl --retry 5 --retry-all-errors -OL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz
tar -xzf wasi-sdk-25.0-x86_64-linux.tar.gz
mv wasi-sdk-25.0-x86_64-linux wasi-sdk
- name: Build
run: |
cargo +${{ steps.toolchain.outputs.name }} build --target=wasm32-${{ matrix.target }}
env:
WASI_SDK_PATH: "/tmp/wasi-sdk"
- name: Test
run: |
export CARGO_TARGET_WASM32_WASIP1_RUNNER="wasmtime run --dir=$PWD::/cwd"
export CARGO_TARGET_WASM32_WASIP2_RUNNER="wasmtime run --dir=$PWD::/cwd"
cargo +${{ steps.toolchain.outputs.name }} test --tests --examples --target=wasm32-${{ matrix.target }}
env:
WASI_SDK_PATH: "/tmp/wasi-sdk"
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
if: ${{ inputs.release }}
with:
subject-path: "./target/libmozjs-wasm32-${{ matrix.target }}.tar.gz"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
path: ./target/libmozjs-wasm32-${{ matrix.target }}.tar.gz
name: libmozjs-wasm32-${{ matrix.target }}.tar.gz
linux-cross-compile:
name: linux (${{ matrix.target }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
container: ghcr.io/servo/cross-${{ matrix.target }}:main
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
id: toolchain
with:
toolchain: ${{ inputs.rust_version }}
targets: ${{ matrix.target }}
- run: cargo +${{ steps.toolchain.outputs.name }} test --tests --examples --target ${{ matrix.target }}
integrity:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: dtolnay/rust-toolchain@master
id: toolchain
with:
toolchain: ${{ inputs.rust_version }}
components: "rustfmt"
- name: Check Rust formatting
run: cargo +${{ steps.toolchain.outputs.name }} fmt --check
- name: Check C++ formatting
uses: jidicula/clang-format-action@v4.11.0
with:
clang-format-version: "18"
exclude-regex: mozjs-sys\/mozjs
- name: Get mozjs
run: |
bash ./mozjs-sys/etc/get_mozjs.sh
- name: Apply patch
run: |
python3 ./mozjs-sys/etc/update.py --no-commit mozjs.tar.xz
# Run `git add` here to force CRLF converted into LF
# so that we can check diff properly in next run
git add --all mozjs-sys
- name: Check patch integrity
working-directory: ./mozjs-sys
# Because we've added files in previous run, we need to
# check diff with `--staged`.
run: |
git diff --staged --no-ext-diff --exit-code
- name: Detect need for mozjs-sys version bump
if: ${{ github.event_name == 'pull_request' }}
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
needs_mozjs_sys_bump:
- 'mozjs-sys/src/*.cpp'
- 'mozjs-sys/mozjs/**'
- 'mozjs-sys/*'
- name: Ensure mozjs-sys version is bumped
if: ${{ github.event_name == 'pull_request' && steps.changes.outputs.needs_mozjs_sys_bump == 'true' }}
run: |
git fetch origin main
CHANGED=$(git diff origin/main -- mozjs-sys/Cargo.toml | grep '^+\s*version\s*=' || true)
if [ -n "$CHANGED" ]; then
echo "✅ mozjs-sys version bumped: $CHANGED"
exit 0
else
echo "❌ No mozjs-sys version bump found."
echo "Please bump mozjs-sys version to trigger publishing new artifacts on landing."
exit 1
fi
publish-release:
name: Check version and publish release
runs-on: ubuntu-latest
needs: ["linux", "mac", "windows", "ohos"]
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Publish release if tag doesn't exist
id: check-tag
if: ${{ inputs.release }}
run: |
RELEASE_TAG=mozjs-sys-v$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "mozjs_sys") | .version')
git fetch --tags --quiet
if ! git show-ref --tags --verify --quiet "refs/tags/${RELEASE_TAG}" ; then
gh release create ${RELEASE_TAG} ./*.tar.gz
fi
echo "RELEASE_TAG=${RELEASE_TAG}" >> ${GITHUB_OUTPUT}
outputs:
release-tag: ${{ steps.check-tag.outputs.RELEASE_TAG }}
verify-release:
name: Verify release
needs: publish-release
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
uses: ./.github/workflows/release-check.yml
with:
release-tag: ${{ needs.publish-release.outputs.release-tag }}
rust_version: ${{ inputs.rust_version }}
build_result:
name: Result
runs-on: ubuntu-latest
needs:
[
"android",
"linux",
"linux-cross-compile",
"mac",
"ohos",
"windows",
"integrity",
"publish-release",
"verify-release",
]
if: ${{ always() }}
steps:
- name: Mark the job as successful
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
run: exit 0
- name: Mark the job as unsuccessful
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1