6565 env :
6666 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6767
68- - name : Setup
68+ - name : Setup debug build for tests
6969 run : just setup
7070
7171 - name : Install musl tools and rebuild for musl target
@@ -74,16 +74,22 @@ jobs:
7474 sudo apt-get update && sudo apt-get install -y musl-tools
7575 rustup target add x86_64-unknown-linux-musl
7676
77- # Rebuild hyperlight-js NAPI addon targeting musl
77+ # Rebuild hyperlight-js NAPI addon targeting musl in release mode.
7878 hl_dir=$(just resolve-hyperlight-dir)
7979 cd "${hl_dir}/src/js-host-api"
80- npx napi build --platform --target x86_64-unknown-linux-musl
80+ npx napi build --platform --release --strip -- target x86_64-unknown-linux-musl
8181
82- # Rebuild hyperlight-analysis NAPI addon targeting musl
82+ # Rebuild hyperlight-analysis NAPI addon targeting musl in release mode.
8383 cd "$GITHUB_WORKSPACE/src/code-validator/guest"
84- npx napi build --platform --target x86_64-unknown-linux-musl --manifest-path host/Cargo.toml
84+ npx napi build --platform --release --strip -- target x86_64-unknown-linux-musl --manifest-path host/Cargo.toml
8585 node -e "require('fs').readdirSync('host').filter(f=>f.endsWith('.node')).forEach(f=>require('fs').copyFileSync('host/'+f,f))"
8686
87+ # This matrix leg must upload only musl artifacts; the setup step also
88+ # creates host-platform glibc addons, which are supplied by linux-kvm.
89+ rm -f "${hl_dir}/src/js-host-api/"*.linux-x64-gnu.node
90+ rm -f "$GITHUB_WORKSPACE/src/code-validator/guest/host/"*.linux-x64-gnu.node
91+ rm -f "$GITHUB_WORKSPACE/src/code-validator/guest/"*.linux-x64-gnu.node
92+
8793 # Verify musl .node files were actually produced
8894 ls -la "${hl_dir}/src/js-host-api/"*.linux-x64-musl.node
8995 ls -la "$GITHUB_WORKSPACE/src/code-validator/guest/"*linux-x64-musl* || ls -la "$GITHUB_WORKSPACE/src/code-validator/guest/host/"*linux-x64-musl*
@@ -98,6 +104,10 @@ jobs:
98104 if : matrix.run_tests
99105 run : just test
100106
107+ - name : Rebuild native addons for release packaging
108+ if : matrix.run_tests
109+ run : just build-release
110+
101111 # Upload the native .node addons so the publish job can combine them
102112 - name : Upload native addons
103113 uses : actions/upload-artifact@v7
@@ -159,6 +169,18 @@ jobs:
159169 - name : Pack npm tarball
160170 run : npm pack
161171
172+ - name : Check npm package size
173+ run : |
174+ TARBALL=$(ls *.tgz)
175+ UNPACKED=$(npm pack --dry-run --json | node -e 'let data="";process.stdin.on("data",c=>data+=c);process.stdin.on("end",()=>console.log(JSON.parse(data)[0].unpackedSize))')
176+ MAX=$((300 * 1024 * 1024))
177+ echo "Packed tarball: $TARBALL"
178+ echo "Unpacked size: $UNPACKED bytes (limit: $MAX)"
179+ if [ "$UNPACKED" -gt "$MAX" ]; then
180+ echo "❌ npm package is too large"
181+ exit 1
182+ fi
183+
162184 - name : Upload npm tarball
163185 uses : actions/upload-artifact@v7
164186 with :
@@ -260,33 +282,34 @@ jobs:
260282 env :
261283 VERSION : ${{ steps.ver.outputs.version }}
262284 run : |
263- # Poll registry.npmjs.org for up to 5 minutes for the version to
264- # become resolvable. Cloudflare/CouchDB replication is usually fast
265- # but can lag for minutes after a fresh publish.
285+ # Poll registry.npmjs.org for up to 5 minutes for the version metadata
286+ # AND tarball blob to become fetchable. npm can expose dist metadata
287+ # before the tarball URL has propagated through the CDN, so metadata
288+ # visibility alone is not enough for installability.
266289 for i in $(seq 1 30); do
267290 ACTUAL=$(npm view "@hyperlight-dev/hyperagent@$VERSION" version 2>/dev/null || true)
268291 if [ "$ACTUAL" = "$VERSION" ]; then
269- echo "✅ visible after $((i * 10))s"
270- exit 0
292+ TARBALL=$(npm view "@hyperlight-dev/hyperagent@$VERSION" dist.tarball 2>/dev/null || true)
293+ EXPECTED=$(npm view "@hyperlight-dev/hyperagent@$VERSION" dist.shasum 2>/dev/null || true)
294+ TMP=$(mktemp)
295+ if [ -n "$TARBALL" ] && [ -n "$EXPECTED" ] && curl -fsSL "$TARBALL" -o "$TMP"; then
296+ FOUND=$(sha1sum "$TMP" | awk '{print $1}')
297+ rm -f "$TMP"
298+ if [ "$FOUND" = "$EXPECTED" ]; then
299+ echo "✅ metadata and tarball visible after $((i * 10))s ($EXPECTED)"
300+ exit 0
301+ fi
302+ echo "⏳ tarball shasum mismatch on attempt $i — expected $EXPECTED got $FOUND"
303+ else
304+ rm -f "$TMP"
305+ echo "⏳ metadata visible, tarball not fetchable yet (attempt $i)"
306+ fi
271307 fi
272308 sleep 10
273309 done
274- echo "❌ @hyperlight-dev/hyperagent@$VERSION not visible after 300s"
310+ echo "❌ @hyperlight-dev/hyperagent@$VERSION metadata/tarball not installable after 300s"
275311 exit 1
276312
277- - name : Verify tarball blob fetchable + shasum
278- env :
279- VERSION : ${{ steps.ver.outputs.version }}
280- run : |
281- TARBALL=$(npm view "@hyperlight-dev/hyperagent@$VERSION" dist.tarball)
282- EXPECTED=$(npm view "@hyperlight-dev/hyperagent@$VERSION" dist.shasum)
283- ACTUAL=$(curl -sSL --fail "$TARBALL" | sha1sum | awk '{print $1}')
284- if [ "$ACTUAL" != "$EXPECTED" ]; then
285- echo "❌ shasum mismatch — expected $EXPECTED got $ACTUAL"
286- exit 1
287- fi
288- echo "✅ tarball fetchable, shasum matches ($EXPECTED)"
289-
290313 - name : Install + run in ${{ matrix.image }}
291314 env :
292315 VERSION : ${{ steps.ver.outputs.version }}
0 commit comments