Skip to content

Commit af026c9

Browse files
authored
Merge branch 'next' into test/pm-arborist-validate-lockfile-json
2 parents 2148b05 + 1165169 commit af026c9

115 files changed

Lines changed: 3370 additions & 207 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/pack-release.yml

Lines changed: 145 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,31 @@ on:
88

99
env:
1010
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
11+
PACK_NATIVE_BUILDER_IMAGE: utoo-pack-native-builder:release
12+
PACK_WINDOWS_BUILDER_IMAGE: utoo-pack-windows-builder:release
1113

1214
jobs:
1315
build:
1416
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref_name, 'utoopack-v')
17+
permissions:
18+
contents: read
1519
strategy:
1620
fail-fast: true
1721
matrix:
1822
settings:
1923
- host: macos-latest
2024
target: aarch64-apple-darwin
25+
binding: pack.darwin-arm64.node
2126
build: |
2227
npm run build:binding --workspace=@utoo/pack -- --target aarch64-apple-darwin
2328
- host: macos-latest
2429
target: x86_64-apple-darwin
30+
binding: pack.darwin-x64.node
2531
build: |
2632
npm run build:binding --workspace=@utoo/pack -- --target x86_64-apple-darwin
2733
- host: ubuntu-latest
2834
target: aarch64-unknown-linux-gnu
35+
binding: pack.linux-arm64-gnu.node
2936
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
3037
build: |
3138
apt-get update && apt-get install -y libc6-dev-arm64-cross libgcc-s1-arm64-cross &&
@@ -35,22 +42,13 @@ jobs:
3542
npm run build:binding --workspace=@utoo/pack -- --target aarch64-unknown-linux-gnu
3643
- host: ubuntu-latest
3744
target: aarch64-unknown-linux-musl
38-
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
39-
# Note: export RUSTFLAGS for musl need inject especially: https://github.com/utooland/utoo/pull/1980
40-
build: |
41-
set -ex &&
42-
rm /etc/apk/repositories &&
43-
echo "https://dl-cdn.alpinelinux.org/alpine/v3.21/main" >> /etc/apk/repositories &&
44-
echo "https://dl-cdn.alpinelinux.org/alpine/v3.21/community" >> /etc/apk/repositories &&
45-
apk update &&
46-
apk add --no-cache libc6-compat pkgconfig dav1d libdav1d dav1d-dev clang-static llvm-dev &&
47-
rustup install nightly-2026-07-29 &&
48-
rustup default nightly-2026-07-29 &&
49-
rustup target add aarch64-unknown-linux-musl &&
50-
export RUSTFLAGS='--cfg tokio_unstable -Zshare-generics=y -Zthreads=8 -Zunstable-options -Csymbol-mangling-version=v0 -Clinker-flavor=gnu-lld-cc -Clink-self-contained=+linker' &&
51-
npm run build:binding --workspace=@utoo/pack -- --target aarch64-unknown-linux-musl
45+
binding: pack.linux-arm64-musl.node
46+
elf_machine: AArch64
47+
file_arch_pattern: ARM aarch64|aarch64
48+
musl_builder: true
5249
- host: ubuntu-latest
5350
target: x86_64-unknown-linux-gnu
51+
binding: pack.linux-x64-gnu.node
5452
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
5553
build: |
5654
apt-get update &&
@@ -60,38 +58,28 @@ jobs:
6058
npm run build:binding --workspace=@utoo/pack -- --target x86_64-unknown-linux-gnu
6159
- host: ubuntu-latest
6260
target: x86_64-unknown-linux-musl
63-
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
64-
# Note: export RUSTFLAGS for musl need inject especially: https://github.com/utooland/utoo/pull/1980
65-
build: |
66-
set -ex &&
67-
rm /etc/apk/repositories &&
68-
echo "https://dl-cdn.alpinelinux.org/alpine/v3.21/main" >> /etc/apk/repositories &&
69-
echo "https://dl-cdn.alpinelinux.org/alpine/v3.21/community" >> /etc/apk/repositories &&
70-
apk update &&
71-
apk add --no-cache libc6-compat pkgconfig dav1d libdav1d dav1d-dev clang-static llvm-dev &&
72-
rustup install nightly-2026-07-29 &&
73-
rustup default nightly-2026-07-29 &&
74-
rustup target add x86_64-unknown-linux-musl &&
75-
export RUSTFLAGS='--cfg tokio_unstable -Zshare-generics=y -Zthreads=8 -Csymbol-mangling-version=v0' &&
76-
npm run build:binding --workspace=@utoo/pack -- --target x86_64-unknown-linux-musl
61+
binding: pack.linux-x64-musl.node
62+
elf_machine: Advanced Micro Devices X86-64
63+
file_arch_pattern: x86-64
64+
musl_builder: true
7765
# swc_plugin_runner not supported on aarch64 windows now
7866
# - host: windows-latest
7967
# target: aarch64-pc-windows-msvc
8068
# build: |
8169
# git config --system core.longpaths true &&
8270
# rustup target add aarch64-pc-windows-msvc &&
8371
# npm run build:binding --workspace=@utoo/pack -- --target aarch64-pc-windows-msvc
84-
- host: windows-latest
85-
build: |
86-
git config --system core.longpaths true &&
87-
npm run build:binding --workspace=@utoo/pack -- --target x86_64-pc-windows-msvc
72+
- host: ubuntu-latest
73+
binding: pack.win32-x64-msvc.node
74+
windows_builder: true
8875
target: x86_64-pc-windows-msvc
8976
name: utoopack-release-${{ matrix.settings.target }} - node@22
9077
runs-on: ${{ matrix.settings.host }}
9178
steps:
92-
- uses: actions/checkout@v6
93-
- name: Init git submodules
94-
run: git submodule update --init --recursive --depth 1
79+
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
80+
with:
81+
fetch-depth: 100
82+
persist-credentials: false
9583
- name: Free disk space
9684
if: matrix.settings.host == 'ubuntu-latest'
9785
run: |
@@ -103,31 +91,68 @@ jobs:
10391
sudo rm -rf /usr/local/share/powershell
10492
sudo rm -rf /usr/share/miniconda
10593
sudo docker image prune --all --force
94+
- name: Set up Docker Buildx
95+
if: matrix.settings.musl_builder || matrix.settings.windows_builder
96+
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
97+
with:
98+
# Buildx requires this daemon-side entitlement for its isolated
99+
# container driver. The build command deliberately does not grant it.
100+
buildkitd-flags: --allow-insecure-entitlement=network.host
101+
driver-opts: image=moby/buildkit@sha256:63db51c9b30208a7c2b1c40392c7ebb9ce2f85ba238a18a85420f8f5ea2d4684
102+
# Build before the large submodule and node_modules exist so they never
103+
# enter the Docker build context.
104+
- name: Build native builder image
105+
if: matrix.settings.musl_builder
106+
run: |
107+
docker buildx build \
108+
--load \
109+
--provenance=false \
110+
--tag "$PACK_NATIVE_BUILDER_IMAGE" \
111+
--file scripts/pack-native-builder.Dockerfile \
112+
.
113+
- name: Build Windows builder image
114+
if: matrix.settings.windows_builder
115+
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.0.0
116+
env:
117+
# The publish job downloads every artifact as a platform binding.
118+
DOCKER_BUILD_RECORD_UPLOAD: "false"
119+
with:
120+
context: .
121+
file: scripts/pack-windows-builder.Dockerfile
122+
load: true
123+
provenance: false
124+
tags: ${{ env.PACK_WINDOWS_BUILDER_IMAGE }}
125+
cache-from: type=gha,scope=utoo-pack-windows-builder-v1
126+
- name: Init git submodules
127+
run: git submodule update --init --recursive --depth 1
106128
- name: Set up QEMU
107129
if: matrix.settings.docker && contains(matrix.settings.target, 'aarch64')
108-
uses: docker/setup-qemu-action@v4
130+
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
131+
with:
132+
cache-image: false
133+
image: docker.io/tonistiigi/binfmt@sha256:400a4873b838d1b89194d982c45e5fb3cda4593fbfd7e08a02e76b03b21166f0
134+
platforms: arm64
109135
- name: Setup node
110-
uses: actions/setup-node@v6
136+
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
111137
if: ${{ !matrix.settings.docker }}
112138
with:
113139
node-version: 22.14.0
114140
package-manager-cache: false
115141
- name: Install
116-
uses: dtolnay/rust-toolchain@stable
117-
if: ${{ !matrix.settings.docker }}
142+
uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable
143+
if: ${{ !matrix.settings.docker && !matrix.settings.musl_builder && !matrix.settings.windows_builder }}
118144
with:
119145
toolchain: nightly-2026-07-29
120146
targets: ${{ matrix.settings.target }}
121147
# - name: Cache cargo
122148
# uses: Swatinem/rust-cache@v2
123149
# with:
124150
# shared-key: pack-release-${{ matrix.settings.target }}
125-
- name: Setup toolchain
126-
run: ${{ matrix.settings.setup }}
127-
if: ${{ matrix.settings.setup }}
128-
shell: bash
129151
- name: Setup Utoo
130-
uses: utooland/setup-utoo@v1
152+
uses: utooland/setup-utoo@e7aa4d726a17f79f68aed736476ea5bd68f8ba52 # v1
153+
with:
154+
cache-utoo: false
155+
utoo-version: 1.1.7
131156

132157
- name: Clear install-node for musl builds
133158
if: ${{ contains(matrix.settings.target, 'musl') }}
@@ -142,7 +167,7 @@ jobs:
142167
- name: Install dependencies
143168
run: utoo install
144169
- name: Setup node x86
145-
uses: actions/setup-node@v6
170+
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
146171
with:
147172
package-manager-cache: false
148173
- name: Build in docker
@@ -160,15 +185,79 @@ jobs:
160185
-w /build \
161186
${{ matrix.settings.docker }} \
162187
/bin/sh /build/build_script.sh
188+
- name: Verify NAPI CLI version
189+
if: matrix.settings.musl_builder || matrix.settings.windows_builder
190+
run: test "$(node -p 'require("@napi-rs/cli/package.json").version')" = "2.18.4"
191+
- name: Build musl binding
192+
if: matrix.settings.musl_builder
193+
env:
194+
BINDING: packages/pack/src/${{ matrix.settings.binding }}
195+
TARGET: ${{ matrix.settings.target }}
196+
run: |
197+
rm -f "$BINDING"
198+
docker run --rm \
199+
--env CI=1 \
200+
--env CARGO_INCREMENTAL=0 \
201+
--env CARGO_TERM_COLOR=always \
202+
--env RUST_BACKTRACE=1 \
203+
--env TARGET \
204+
--volume "$GITHUB_WORKSPACE:/build" \
205+
--workdir /build \
206+
"$PACK_NATIVE_BUILDER_IMAGE" \
207+
/bin/bash /build/scripts/pack-native-build.sh
208+
- name: Check generated binding files
209+
if: matrix.settings.musl_builder
210+
run: git diff --exit-code -- packages/pack/src/binding.js packages/pack/src/binding.d.ts
211+
- name: Verify musl ELF target and loader
212+
if: matrix.settings.musl_builder
213+
env:
214+
BINDING: packages/pack/src/${{ matrix.settings.binding }}
215+
EXPECTED_ELF_MACHINE: ${{ matrix.settings.elf_machine }}
216+
EXPECTED_FILE_ARCH: ${{ matrix.settings.file_arch_pattern }}
217+
run: |
218+
set -euo pipefail
219+
test -s "$BINDING"
220+
221+
file_output=$(file --brief "$BINDING")
222+
echo "$file_output"
223+
grep -Eq "ELF 64-bit LSB shared object.*(${EXPECTED_FILE_ARCH})" <<<"$file_output"
224+
225+
machine=$(readelf --file-header "$BINDING" | sed -n 's/^[[:space:]]*Machine:[[:space:]]*//p')
226+
test "$machine" = "$EXPECTED_ELF_MACHINE"
227+
228+
dynamic_section=$(readelf --dynamic "$BINDING")
229+
echo "$dynamic_section"
230+
! grep -q 'libc\.so\.6' <<<"$dynamic_section"
231+
232+
program_headers=$(readelf --program-headers "$BINDING")
233+
! grep -Eq '/lib(64)?/(ld-linux|ld64)|ld-linux-' <<<"$program_headers"
163234
- name: Build
164235
run: ${{ matrix.settings.build }}
165-
if: ${{ !matrix.settings.docker }}
236+
if: ${{ !matrix.settings.docker && !matrix.settings.musl_builder && !matrix.settings.windows_builder }}
166237
shell: bash
238+
- name: Build Windows binding
239+
if: matrix.settings.windows_builder
240+
env:
241+
TARGET: ${{ matrix.settings.target }}
242+
run: |
243+
docker run --rm \
244+
--env CI=1 \
245+
--env CARGO_INCREMENTAL=0 \
246+
--env CARGO_TERM_COLOR=always \
247+
--env RUST_BACKTRACE=1 \
248+
--env TARGET \
249+
--volume "$GITHUB_WORKSPACE:/build" \
250+
--workdir /build \
251+
"$PACK_WINDOWS_BUILDER_IMAGE" \
252+
/bin/bash /build/scripts/pack-windows-build.sh
253+
- name: Check generated Windows binding files
254+
if: matrix.settings.windows_builder
255+
run: git diff --exit-code -- packages/pack/src/binding.js packages/pack/src/binding.d.ts
167256
- name: Upload artifact
168-
uses: actions/upload-artifact@v7
257+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
169258
with:
170259
name: pack-${{ matrix.settings.target }}
171-
path: ./packages/pack/src/pack.*.node
260+
path: ./packages/pack/src/${{ matrix.settings.binding }}
172261
if-no-files-found: error
173262
publish:
174263
if: github.event_name == 'push' && startsWith(github.ref_name, 'utoopack-v')
@@ -181,22 +270,26 @@ jobs:
181270
needs:
182271
- build
183272
steps:
184-
- uses: actions/checkout@v6
273+
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
185274
with:
275+
persist-credentials: false
186276
ref: ${{ github.ref_name }}
187277
- name: Setup node
188-
uses: actions/setup-node@v6
278+
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
189279
with:
190280
node-version: 22.14.0
191281
package-manager-cache: false
192282
registry-url: "https://registry.npmjs.org"
193283
- name: Setup Utoo
194-
uses: utooland/setup-utoo@v1
284+
uses: utooland/setup-utoo@e7aa4d726a17f79f68aed736476ea5bd68f8ba52 # v1
285+
with:
286+
cache-utoo: false
287+
utoo-version: 1.1.7
195288

196289
- name: Install dependencies
197290
run: utoo install
198291
- name: Download all artifacts
199-
uses: actions/download-artifact@v8
292+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
200293
with:
201294
path: ./packages/pack/src
202295
- name: Move artifacts
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: utoopack-windows-builder-cache
2+
3+
on:
4+
push:
5+
branches:
6+
- next
7+
paths:
8+
- .github/workflows/pack-release.yml
9+
- .github/workflows/pack-windows-builder-cache.yml
10+
- scripts/pack-windows-builder.Dockerfile
11+
- rust-toolchain.toml
12+
workflow_dispatch:
13+
14+
env:
15+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
16+
17+
jobs:
18+
warm-cache:
19+
# Only trusted runs on the default branch may populate the shared cache.
20+
if: github.ref == 'refs/heads/next'
21+
name: Warm Windows builder cache
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
concurrency:
26+
group: utoo-pack-windows-builder-cache
27+
cancel-in-progress: true
28+
steps:
29+
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
30+
with:
31+
persist-credentials: false
32+
- uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
33+
with:
34+
buildkitd-flags: --allow-insecure-entitlement=network.host
35+
driver-opts: image=moby/buildkit@sha256:63db51c9b30208a7c2b1c40392c7ebb9ce2f85ba238a18a85420f8f5ea2d4684
36+
- name: Warm builder cache
37+
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.0.0
38+
env:
39+
DOCKER_BUILD_RECORD_UPLOAD: "false"
40+
with:
41+
context: .
42+
file: scripts/pack-windows-builder.Dockerfile
43+
outputs: type=cacheonly
44+
provenance: false
45+
cache-from: type=gha,scope=utoo-pack-windows-builder-v1
46+
cache-to: type=gha,scope=utoo-pack-windows-builder-v1,mode=max

0 commit comments

Comments
 (0)