Skip to content
Open
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
3f44ec7
feat(util): add the e2e-util crate and the @e2e-dev/util package (ENG…
kdy1 Nov 27, 2026
c36a190
test(util): hold the addon to the reference on browser screenshots, a…
kdy1 Nov 27, 2026
08eddb4
perf(util): benchmark the addon against the JavaScript it replaces (E…
kdy1 Nov 27, 2026
56463e3
feat(core): move screenshot pixel work to @e2e-dev/util (ENG-1543)
kdy1 Nov 27, 2026
7cc4667
docs: describe crates/ and @e2e-dev/util (ENG-1543)
kdy1 Nov 27, 2026
742ef45
ci: build and check the Rust workspace, and pack @e2e-dev/util in the…
kdy1 Nov 27, 2026
48e51d9
fix(util): refuse oversized images before allocating, and copy input …
kdy1 Nov 27, 2026
731eeda
fix(core): report a screenshot that does not decode as UNSUPPORTED_CA…
kdy1 Nov 27, 2026
54a7615
fix(util): keep images alive through their native calls, and credit p…
kdy1 Nov 27, 2026
1be7541
ci: build @e2e-dev/util where core is built alone, and run the addon …
kdy1 Nov 27, 2026
fd70466
ci: build @e2e-dev/util and its addon before core in the Electron job…
kdy1 Nov 28, 2026
8f28554
feat(util): ship the addon in eight platform packages (ENG-1543)
kdy1 Nov 28, 2026
30546f6
ci: build, check, and load @e2e-dev/util's addon on each platform, an…
kdy1 Nov 28, 2026
a8f34ae
fix(ci): keep the example install script's comment free of apostrophe…
kdy1 Nov 28, 2026
a6b1d20
fix(e2e): fail a cut-off screenshot as unreadable before reporting a …
kdy1 Nov 28, 2026
89fda23
chore(util): carry the notice of the FreeBSD cube root the addon port…
kdy1 Nov 28, 2026
ba5b9af
test(util): list tracked PNGs NUL-separated in the equivalence suite …
kdy1 Nov 28, 2026
6447c3f
fix(util): leave sockets out of the report that tells glibc from musl…
kdy1 Nov 28, 2026
34b3cce
ci: run the benchmarks when .cargo/config.toml changes (ENG-1543)
kdy1 Nov 28, 2026
11f9863
ci: keep the pack job's comment above the pack job in examples.yml (E…
kdy1 Nov 28, 2026
6cd96d9
chore(mobile): restore the escaped contributor name in package.json (…
kdy1 Nov 28, 2026
204e1fa
docs: say the build needs rustup, and build util before core in the f…
kdy1 Nov 28, 2026
f826185
perf(util): compare pixels through a view of each image, not a copy (…
kdy1 Nov 28, 2026
880d438
perf(util): check the size of NativeImage.fromRgba's input before cop…
kdy1 Nov 28, 2026
d81d2a2
fix(core): keep no locator screenshot when the attempt is cancelled d…
kdy1 Nov 28, 2026
c120e1a
docs: say mobile loads the util addon with the engine, and which util…
kdy1 Nov 28, 2026
5a0d9c7
build: opt the desktop crate out of the workspace lints explicitly (E…
kdy1 Nov 28, 2026
e1b0428
fix(e2e): write no screenshot when the attempt is cancelled during it…
kdy1 Nov 28, 2026
f9f106e
docs: say what a mobile project without the util addon fails with (EN…
kdy1 Nov 28, 2026
255be46
fix(mobile): keep no screenshot when the operation is cancelled while…
kdy1 Nov 28, 2026
5c7b8da
test(e2e): cancel the screenshot tests inside the native call they co…
kdy1 Nov 28, 2026
9f74741
fix(scripts): leave an addon in place when place-native is given the …
kdy1 Nov 28, 2026
847f55d
fix(scripts): pack the install smoke's util platform package from a c…
kdy1 Nov 28, 2026
8156758
fix(scripts): import the installed util package by file URL in the in…
kdy1 Nov 28, 2026
59e4166
docs(changeset): say how a mobile project fails on a platform with no…
kdy1 Nov 28, 2026
fa2b3ec
fix(mobile): race screenshot masking with cancellation only, not the …
kdy1 Nov 28, 2026
ae9d0a9
ci: register the util-native runner labels with actionlint (ENG-1543)
kdy1 Nov 28, 2026
cad1ca6
fix(util): type the addon's returned bytes as Uint8Array, not Buffer …
kdy1 Nov 28, 2026
72a731d
fix(util): report a checkout build that fails to load, not the absent…
kdy1 Nov 28, 2026
88b84b7
perf(util): start NAPI-RS's runtime with one scheduler thread, not on…
kdy1 Nov 28, 2026
3456fed
fix(util): time the old mobile mask as the engine ran it in the bench…
kdy1 Nov 28, 2026
dc63510
fix(util): report the size of the addon the benchmark loaded (ENG-1543)
kdy1 Nov 28, 2026
c1c97ef
docs: name UTIL_NATIVE_DIR in AGENTS.md's canary steps (ENG-1543)
kdy1 Nov 28, 2026
d36e098
fix(util): report a platform package without its addon as failing to …
kdy1 Nov 28, 2026
d307e62
fix(util): keep a checkout build's load failure as the cause beside a…
kdy1 Nov 28, 2026
929a10f
fix(util): give install advice only when the platform package is not …
kdy1 Nov 28, 2026
a11940e
fix(util): compare two buffers on both sides of the identical-image b…
kdy1 Nov 28, 2026
b351a56
fix(util): keep util's benchmark from importing @e2e-dev/mobile (ENG-…
kdy1 Nov 28, 2026
0b3d7f0
docs: name the screenshot calls that need the util addon (ENG-1543)
kdy1 Nov 28, 2026
7fefac7
docs: say when core loads the util addon: on pixel work, not every sc…
kdy1 Nov 28, 2026
dc28639
ci(util): build the glibc addons on glibc 2.28, not Ubuntu 22.04 (ENG…
kdy1 Nov 28, 2026
2d4251b
Merge origin/main into kdy1/rust-e2e-util-package (ENG-1543)
kdy1 Nov 29, 2026
493396a
fix(util): point util's vitest at the vite main now pins (ENG-1543)
kdy1 Nov 29, 2026
bc26254
fix(core): stop waiting for native image work once the attempt is can…
kdy1 Nov 30, 2026
2314f31
refactor(util): keep Rgba's fields private behind checked constructor…
kdy1 Nov 30, 2026
366b566
test(util): hold processPng's PNG output and fromRgba's size check to…
kdy1 Nov 30, 2026
b131721
test(util): expect the platform package's failure only where one exis…
kdy1 Nov 30, 2026
fac602f
fix(util): refuse a --runs the benchmark cannot use, and drop the p95…
kdy1 Nov 30, 2026
625eb1f
ci: run the benchmarks for util's crates only, not every crate (ENG-1…
kdy1 Nov 30, 2026
3e2e79f
docs(util): state that the macOS builds need macOS 13 or later (ENG-1…
kdy1 Nov 30, 2026
4269fcc
docs(util): say the comparison is bit-exact with pixelmatch on Node 2…
kdy1 Nov 30, 2026
34b1445
Merge origin/main into kdy1/rust-e2e-util-package (ENG-1543)
kdy1 Nov 30, 2026
321fd01
fix(core): end a judgment's wait for model-sized pixels at its deadli…
kdy1 Nov 30, 2026
16c74c9
refactor(core): make every image call take the signal that ends its w…
kdy1 Dec 1, 2026
b670afd
Merge origin/main into kdy1/rust-e2e-util-package (ENG-1543)
kdy1 Dec 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# How the Node addons in crates/ link their C runtime on the targets where the default does not fit an addon.

# musl defaults to a static C runtime, with which rustc drops a cdylib; the addon links the musl that the Node
# process loading it already has.
[target.x86_64-unknown-linux-musl]
rustflags = ["-C", "target-feature=-crt-static"]

[target.aarch64-unknown-linux-musl]
rustflags = ["-C", "target-feature=-crt-static"]

# MSVC defaults to the C runtime DLLs of the Visual C++ Redistributable, which a Windows machine with Node may not
# have; the addon carries its own.
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]

[target.aarch64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"@e2e-dev/desktop",
"@e2e-dev/desktop-darwin-arm64",
"@e2e-dev/desktop-darwin-x64"
],
[
"@e2e-dev/util",
"@e2e-dev/util-darwin-arm64",
"@e2e-dev/util-darwin-x64",
"@e2e-dev/util-linux-arm64-gnu",
"@e2e-dev/util-linux-arm64-musl",
"@e2e-dev/util-linux-x64-gnu",
"@e2e-dev/util-linux-x64-musl",
"@e2e-dev/util-win32-arm64-msvc",
"@e2e-dev/util-win32-x64-msvc"
]
],
"linked": [],
Expand Down
16 changes: 16 additions & 0 deletions .changeset/native-image-util.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@e2e-dev/util': patch
'@e2e-dev/util-darwin-arm64': patch
'@e2e-dev/util-darwin-x64': patch
'@e2e-dev/util-linux-arm64-gnu': patch
'@e2e-dev/util-linux-arm64-musl': patch
'@e2e-dev/util-linux-x64-gnu': patch
'@e2e-dev/util-linux-x64-musl': patch
'@e2e-dev/util-win32-arm64-msvc': patch
'@e2e-dev/util-win32-x64-msvc': patch
'@e2e-dev/core': patch
'e2e': patch
'@e2e-dev/mobile': patch
---

Screenshot pixel work (PNG decoding and encoding, resizing for the model, `toHaveScreenshot` captures and comparisons, `locator.screenshot()` crops, and mobile masking) now runs in the new `@e2e-dev/util` native addon, off the JavaScript thread. npm installs its build for your platform with it, from `@e2e-dev/util-<platform>`: macOS on arm64 and x64, Linux on x64 and arm64 with glibc 2.28 or later or with musl, and Windows on x64 and arm64. On any other platform, `toHaveScreenshot`, `locator.screenshot()`, and an agent screenshot the runner has to resize fail with `IMAGE_CODEC_UNAVAILABLE`, naming the platforms there are (a plain `app.screenshot()` saves the engine's PNG and still works), and a config that uses `@e2e-dev/mobile` fails to load, since the engine loads the addon when it loads. The output is byte for byte what `@napi-rs/image` and `pixelmatch` produced, so stored screenshots do not change. `@napi-rs/image` and `pixelmatch` are no longer dependencies.
8 changes: 8 additions & 0 deletions .fallowrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@
"ignoreDependencies": [
"@e2e-dev/desktop-darwin-arm64",
"@e2e-dev/desktop-darwin-x64",
"@e2e-dev/util-darwin-arm64",
"@e2e-dev/util-darwin-x64",
"@e2e-dev/util-linux-arm64-gnu",
"@e2e-dev/util-linux-arm64-musl",
"@e2e-dev/util-linux-x64-gnu",
"@e2e-dev/util-linux-x64-musl",
"@e2e-dev/util-win32-arm64-msvc",
"@e2e-dev/util-win32-x64-msvc",
"e2e",
"@e2e-dev/web",
"@openrouter/ai-sdk-provider",
Expand Down
1 change: 1 addition & 0 deletions .github/actionlint.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
self-hosted-runner:
labels:
- blacksmith-4vcpu-ubuntu-2404
- blacksmith-4vcpu-ubuntu-2404-arm
- blacksmith-6vcpu-macos-26
16 changes: 13 additions & 3 deletions .github/actions/example-packages/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ description: >-
Installs an example's dependencies with e2e, @e2e-dev/web, and
@e2e-dev/mobile swapped for the tarballs the examples workflow packed from
main, so the example runs this checkout's packages instead of the npm
releases its package.json names. @e2e-dev/core, which they all build on, comes
from its tarball through an override, since e2e names its exact snapshot.
releases its package.json names. @e2e-dev/core, which they all build on,
@e2e-dev/util, which core depends on, and util's platform packages come
from their tarballs through overrides, since e2e, core, and util name their
exact snapshots.

inputs:
agent-device-version:
Expand Down Expand Up @@ -46,7 +48,15 @@ runs:
console.log(`${name}: ${manifest[field][name]}`);
}
}
manifest.overrides = { ...manifest.overrides, "@e2e-dev/core": `file:${process.env.PACKED}/core.tgz` };
// Every platform package of @e2e-dev/util, which names their exact snapshots too; npm skips the ones
// whose os, cpu, and libc do not match this runner. No apostrophes here: this script is single-quoted.
const platforms = fs.readdirSync(process.env.PACKED).flatMap((file) => /^util-(.+)\.tgz$/.exec(file)?.[1] ?? []);
manifest.overrides = {
...manifest.overrides,
"@e2e-dev/core": `file:${process.env.PACKED}/core.tgz`,
"@e2e-dev/util": `file:${process.env.PACKED}/util.tgz`,
...Object.fromEntries(platforms.map((platform) => [`@e2e-dev/util-${platform}`, `file:${process.env.PACKED}/util-${platform}.tgz`])),
Comment thread
kdy1 marked this conversation as resolved.
Resolved
};
fs.writeFileSync("package.json", `${JSON.stringify(manifest, null, 2)}\n`);
'
if [ -n "$AGENT_DEVICE_VERSION" ]; then
Expand Down
19 changes: 16 additions & 3 deletions .github/actions/load-x64-addon/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Load the x64 desktop addon
name: Load an x64 addon
description: >-
Loads the desktop driver's x64 build in an x86_64 Node under Rosetta on an
arm64 Mac, and fails unless it loads and answers status().
Loads a native addon's x64 build in an x86_64 Node under Rosetta on an
arm64 Mac, and fails unless it loads and answers: the desktop driver's
status(), or the probe script given.

# No Intel Mac runner is in use, so Rosetta stands in for one: it runs the
# official darwin-x64 Node of the version setup-node installed, checked
Expand All @@ -11,6 +12,12 @@ inputs:
addon:
description: Path of the x64 addon, relative to the workspace.
required: true
probe:
description: >-
A script, relative to the workspace, that the x86_64 Node runs with the
addon's path as its argument and that exits non-zero when the addon
does not work. Without one, the desktop driver's status() is checked.
default: ''

runs:
using: composite
Expand Down Expand Up @@ -44,8 +51,14 @@ runs:
env:
NODE_X64: ${{ steps.node.outputs.path }}
ADDON: ${{ inputs.addon }}
PROBE: ${{ inputs.probe }}
run: |
set -euo pipefail
if [ -n "$PROBE" ]; then
arch -x86_64 "$NODE_X64" -e "if (process.arch !== 'x64') throw new Error('Node runs as ' + process.arch + ', not x64')"
arch -x86_64 "$NODE_X64" "$GITHUB_WORKSPACE/$PROBE" "$GITHUB_WORKSPACE/$ADDON"
exit 0
fi
arch -x86_64 "$NODE_X64" -e "
if (process.arch !== 'x64') throw new Error('Node runs as ' + process.arch + ', not x64');
const status = require(require('node:path').resolve(process.argv[1])).status();
Expand Down
46 changes: 34 additions & 12 deletions .github/actions/rust-toolchain/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ description: >-
# at sh.rustup.rs. The toolchain itself stays pinned in rust-toolchain.toml.
# To move to a newer rustup, take the version from
# https://static.rust-lang.org/rustup/release-stable.toml and each checksum
# from https://static.rust-lang.org/rustup/archive/<version>/<target>/rustup-init.sha256.
# from https://static.rust-lang.org/rustup/archive/<version>/<target>/rustup-init.sha256
# (`rustup-init.exe.sha256` on Windows). `.github/scripts/build-musl.sh` pins the
# musl installers of the same version, and `.github/scripts/build-glibc.sh` the
# Linux ones again, for its container.
runs:
using: composite
steps:
Expand All @@ -19,29 +22,48 @@ runs:
RUSTUP_VERSION: 1.29.3
SHA256_AARCH64_APPLE_DARWIN: 63752a1919a3a4793173ec70f8f212621a7ce38ba6a246095984482f4de20f9f
SHA256_X86_64_APPLE_DARWIN: bc107f1fb0228de7fa32413c89c1b305cea9cd256e94b01150cd054128145429
SHA256_X86_64_UNKNOWN_LINUX_GNU: b1c8cb14e30889e7e2999e6b69e62d9e9b9ffc0f4df8180564d306d9680e6c55
SHA256_AARCH64_UNKNOWN_LINUX_GNU: 9f608c142e0e38a78957d0661ba1dfaf0b6fb37184cfaa4b9a0aa57af6184282
SHA256_X86_64_PC_WINDOWS_MSVC: 38027d51d69a5d05493627a0634dbea52d6cd793c8f072d2373d3f4163eec7db
SHA256_AARCH64_PC_WINDOWS_MSVC: 407e0d72f81d26a01f9d032b8317908cbb2917ba22765474b682b41390792ad9
run: |
set -euo pipefail
if command -v rustup >/dev/null; then
exit 0
fi
case "$(uname -s) $(uname -m)" in
"Darwin arm64") target=aarch64-apple-darwin sha256="$SHA256_AARCH64_APPLE_DARWIN" ;;
"Darwin x86_64") target=x86_64-apple-darwin sha256="$SHA256_X86_64_APPLE_DARWIN" ;;
*) echo "no pinned rustup-init for $(uname -s) $(uname -m)" >&2; exit 1 ;;
# The runner's own names: `uname -m` reads x86_64 in the emulated Git Bash of an arm64 Windows runner.
exe=
case "$RUNNER_OS $RUNNER_ARCH" in
"macOS ARM64") target=aarch64-apple-darwin sha256="$SHA256_AARCH64_APPLE_DARWIN" ;;
"macOS X64") target=x86_64-apple-darwin sha256="$SHA256_X86_64_APPLE_DARWIN" ;;
"Linux X64") target=x86_64-unknown-linux-gnu sha256="$SHA256_X86_64_UNKNOWN_LINUX_GNU" ;;
"Linux ARM64") target=aarch64-unknown-linux-gnu sha256="$SHA256_AARCH64_UNKNOWN_LINUX_GNU" ;;
"Windows X64") target=x86_64-pc-windows-msvc sha256="$SHA256_X86_64_PC_WINDOWS_MSVC" exe=.exe ;;
"Windows ARM64") target=aarch64-pc-windows-msvc sha256="$SHA256_AARCH64_PC_WINDOWS_MSVC" exe=.exe ;;
*) echo "no pinned rustup-init for $RUNNER_OS $RUNNER_ARCH" >&2; exit 1 ;;
esac
dir="$RUNNER_TEMP/rustup-init"
mkdir -p "$dir"
curl --proto '=https' --tlsv1.2 -sSf --retry 3 -o "$dir/rustup-init" \
"https://static.rust-lang.org/rustup/archive/$RUSTUP_VERSION/$target/rustup-init"
echo "$sha256 $dir/rustup-init" | shasum -a 256 -c -
chmod +x "$dir/rustup-init"
"$dir/rustup-init" -y --no-modify-path --default-toolchain none
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
curl --proto '=https' --tlsv1.2 -sSf --retry 3 -o "$dir/rustup-init$exe" \
"https://static.rust-lang.org/rustup/archive/$RUSTUP_VERSION/$target/rustup-init$exe"
if command -v sha256sum >/dev/null; then
echo "$sha256 $dir/rustup-init$exe" | sha256sum -c -
else
echo "$sha256 $dir/rustup-init$exe" | shasum -a 256 -c -
fi
chmod +x "$dir/rustup-init$exe"
"$dir/rustup-init$exe" -y --no-modify-path --default-toolchain none
# GITHUB_PATH takes a Windows path on Windows, which Git Bash's $HOME is not.
bin="$HOME/.cargo/bin"
if command -v cygpath >/dev/null; then bin="$(cygpath -w "$bin")"; fi
echo "$bin" >> "$GITHUB_PATH"
# The pinned toolchain's own cargo, first on PATH: a rustup that was already there, such as Homebrew's, may put no
# cargo on PATH, and a standalone cargo there may lack the targets rust-toolchain.toml pins.
- name: Put cargo on PATH
shell: bash
run: |
set -euo pipefail
rustup toolchain install
dirname "$(rustup which cargo)" >> "$GITHUB_PATH"
# Either separator: rustup prints a Windows path on Windows, which `dirname` in Git Bash does not split.
cargo_path="$(rustup which cargo)"
echo "${cargo_path%[/\\]*}" >> "$GITHUB_PATH"
8 changes: 8 additions & 0 deletions .github/filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ runner: &runner
- '.github/scripts/agent-device.cjs'
- 'packages/e2e/**'
- 'packages/core/**'
- 'packages/util/**'
# The suites build @e2e-dev/util's addon only, never the desktop driver.
- 'crates/e2e-util/**'
- 'crates/e2e-util-napi/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'rust-toolchain.toml'
- '.cargo/config.toml'
- '!packages/*/tests/**'
- '!**/*.md'
- 'package.json'
Expand Down
54 changes: 54 additions & 0 deletions .github/scripts/build-glibc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/sh
# Builds a native addon for a glibc target inside a manylinux_2_28 container
# (AlmaLinux 8, glibc 2.28), so the addon asks for no glibc newer than 2.28,
# the oldest that Node 22's and 24's own Linux builds run on (Debian 11,
# Ubuntu 20.04, RHEL 8). It checks the build, leaves it in its package, and,
# given a probe script and its arguments, runs that in the same container,
# so the addon is loaded on glibc 2.28 itself. The workflow runs it as
# docker run --rm -v "$PWD:/work" -w /work quay.io/pypa/manylinux_2_28_<arch>@<digest> sh .github/scripts/build-glibc.sh <addon> <target> [<probe> <args>...]
# on a runner of the target's architecture.
#
# rustup-init is a fixed release checked against the SHA-256 recorded here,
# the same version `.github/actions/rust-toolchain` pins for the other runners.
# The image has no Node, so the scripts run in Node's official build, a fixed
# release checked against the SHA-256 in https://nodejs.org/dist/v<version>/SHASUMS256.txt.
set -eu

addon="$1"
target="$2"
shift 2
RUSTUP_VERSION=1.29.3
NODE_VERSION=26.13.1
case "$(uname -m)" in
x86_64)
host=x86_64-unknown-linux-gnu rustup_sha256=b1c8cb14e30889e7e2999e6b69e62d9e9b9ffc0f4df8180564d306d9680e6c55
node_arch=x64 node_sha256=518674de2b621728a5e4486f5fb3b7d2900bb3cc4aa97969edaa463db99f9778 ;;
aarch64)
host=aarch64-unknown-linux-gnu rustup_sha256=9f608c142e0e38a78957d0661ba1dfaf0b6fb37184cfaa4b9a0aa57af6184282
node_arch=arm64 node_sha256=80a330b35415382878df18d41afbd106ea89bfb3be0087d6608e289a14c5cc7d ;;
*) echo "no pinned rustup-init or Node for $(uname -m)" >&2; exit 1 ;;
esac
if [ "$host" != "$target" ]; then
echo "$target builds on a runner of its own architecture, not $host" >&2
exit 1
fi

curl --proto '=https' --tlsv1.2 -sSf --retry 3 -o /tmp/rustup-init \
"https://static.rust-lang.org/rustup/archive/$RUSTUP_VERSION/$host/rustup-init"
echo "$rustup_sha256 /tmp/rustup-init" | sha256sum -c -
chmod +x /tmp/rustup-init
/tmp/rustup-init -y --no-modify-path --default-toolchain none
export PATH="$HOME/.cargo/bin:$PATH"

node_dir="node-v$NODE_VERSION-linux-$node_arch"
curl --proto '=https' --tlsv1.2 -sSf --retry 3 -o "/tmp/$node_dir.tar.gz" \
"https://nodejs.org/dist/v$NODE_VERSION/$node_dir.tar.gz"
echo "$node_sha256 /tmp/$node_dir.tar.gz" | sha256sum -c -
tar -xzf "/tmp/$node_dir.tar.gz" -C /tmp
export PATH="/tmp/$node_dir/bin:$PATH"

node scripts/native/build-native.ts "$addon" --target "$target"
node scripts/native/check-build.ts "$addon" "$target"
if [ "$#" -gt 0 ]; then
node "$@"
fi
35 changes: 35 additions & 0 deletions .github/scripts/build-musl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh
# Builds a native addon for a musl target inside an Alpine container, where
# the addon links the musl a user's Node there runs on, and checks the build
# and leaves it in its package for the next step to load. The workflow runs it as
# docker run --rm -v "$PWD:/work" -w /work node:<version>-alpine@<digest> sh .github/scripts/build-musl.sh <addon> <target>
# on a runner of the target's architecture.
#
# rustup-init is a fixed release checked against the SHA-256 recorded here,
# the same version `.github/actions/rust-toolchain` pins for the other runners.
set -eu

addon="$1"
target="$2"
RUSTUP_VERSION=1.29.3
case "$(uname -m)" in
x86_64) host=x86_64-unknown-linux-musl sha256=1552169aba2836777136ccff7a381e95c17233b5d8250cd5e10ae3cb971bfcfc ;;
aarch64) host=aarch64-unknown-linux-musl sha256=956deacdc27ab82ae7ac821d5d3e9e95e4795d476d17efe99743bb8531ca1031 ;;
*) echo "no pinned rustup-init for $(uname -m)" >&2; exit 1 ;;
esac
if [ "$host" != "$target" ]; then
echo "$target builds on a runner of its own architecture, not $host" >&2
exit 1
fi

# The linker and C runtime objects a cdylib needs.
apk add --no-cache build-base curl
curl --proto '=https' --tlsv1.2 -sSf --retry 3 -o /tmp/rustup-init \
"https://static.rust-lang.org/rustup/archive/$RUSTUP_VERSION/$host/rustup-init"
echo "$sha256 /tmp/rustup-init" | sha256sum -c -
chmod +x /tmp/rustup-init
/tmp/rustup-init -y --no-modify-path --default-toolchain none
export PATH="$HOME/.cargo/bin:$PATH"

node scripts/native/build-native.ts "$addon" --target "$target"
node scripts/native/check-build.ts "$addon" "$target"
21 changes: 20 additions & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,19 @@ concurrency:
cancel-in-progress: false

jobs:
# Builds the packages once and packs the three an example installs, so every
# @e2e-dev/util's addon for every platform, which `pack` puts in its
# platform packages, so each example installs the build for its runner.
util-native:
if: ${{ github.repository == 'e2e-inc/e2e' }}
uses: ./.github/workflows/util-native.yml

# Builds the packages once and packs the ones an example installs, so every
# job below installs the same main build. Only this repository runs it:
# GitHub turns a fork's schedules off, but a fork's owner can still
# dispatch the workflow, and it would spend their runners and model key.
# Every example job needs this one, so on a fork they all skip with it.
pack:
needs: util-native
if: ${{ github.repository == 'e2e-inc/e2e' }}
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 15
Expand Down Expand Up @@ -88,8 +95,20 @@ jobs:
pnpm run build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: util-native-*
merge-multiple: true
path: ${{ runner.temp }}/util-native
- name: Place the util addon
run: node scripts/native/place-native.ts util "$RUNNER_TEMP/util-native"
- name: Pack
run: |
pnpm --filter @e2e-dev/util pack --out "$RUNNER_TEMP/packed/util.tgz"
for dir in packages/util/npm/*/; do
platform="$(basename "$dir")"
pnpm --dir "$dir" pack --out "$RUNNER_TEMP/packed/util-$platform.tgz"
done
pnpm --filter @e2e-dev/core pack --out "$RUNNER_TEMP/packed/core.tgz"
pnpm --filter e2e pack --out "$RUNNER_TEMP/packed/e2e.tgz"
pnpm --filter @e2e-dev/web pack --out "$RUNNER_TEMP/packed/web.tgz"
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/microbench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ on:
- packages/core/src/**
- packages/core/package.json
- packages/core/tsconfig*.json
- packages/util/src/**
- packages/util/package.json
- packages/util/tsconfig*.json
- packages/mobile/src/**
- packages/mobile/package.json
- packages/mobile/tsconfig*.json
Expand Down Expand Up @@ -85,6 +88,8 @@ jobs:
(
cd "$RUNNER_TEMP/mb/$side"
pnpm install --frozen-lockfile
# Core compiles against @e2e-dev/util's types; a base from before it has no such package.
if [ -d packages/util ]; then pnpm --filter @e2e-dev/util run build; fi
pnpm --filter @e2e-dev/core run build
pnpm --filter e2e run build
pnpm --filter @e2e-dev/mobile run build
Expand Down Expand Up @@ -127,6 +132,8 @@ jobs:
(
cd "$RUNNER_TEMP/mb/$side"
pnpm install --frozen-lockfile
# Core compiles against @e2e-dev/util's types; a base from before it has no such package.
if [ -d packages/util ]; then pnpm --filter @e2e-dev/util run build; fi
pnpm --filter @e2e-dev/core run build
pnpm --filter e2e run build
pnpm --filter @e2e-dev/mobile run build
Expand Down
Loading
Loading