fix(aws-lambda): chrome-headless-shell 158 in the arm64 video image, sparticuz 153 in the x86 ZIP (#8155)

* fix(aws-lambda): run chrome-headless-shell 158 in the arm64 video image

The arm64 video image now installs Chrome for Testing's linux-arm64 chrome-headless-shell
158.0.8127.36, pinned by sha256 and fetched with curl -f, as the whole shell folder. The Lambda
Node 22 base has none of the shared libraries the shell links and no fonts, so the image installs
them from the base's repository at the same pinned release. The image sets
HYPERFRAMES_LAMBDA_CHROME_SOURCE and HYPERFRAMES_LAMBDA_CHROME_PATH itself, and the nested video
function no longer passes ChromeSource, which would override them. stage-arm64-image.ts stops
fetching the sparticuz arm64 pack and drops the ZIP's x86 sparticuz Chrome instead.

The x86 handler ZIP stays on @sparticuz/chromium, bumped from 148.0.0 to 153.0.0. It builds at
258,502,222 bytes unzipped, under Lambda's 262,144,000-byte limit and the 248 MiB in-house gate.

Two fixes for --source=chrome-headless-shell:
- build-zip.ts staged only the executable, which exits at launch without its ICU data and .pak
  files. It now stages the whole shell folder at chrome-headless-shell-linux64/.
- Nothing set HYPERFRAMES_LAMBDA_CHROME_PATH, which src/chromium.ts requires for that source.
  The SAM template and the CDK stack now set it to the bundled shell when ChromeSource asks for it.

Drops the unused @types/aws-lambda devDependency, which the dead-code audit reports whenever this
package's manifest changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci(publish): build the Lambda arm64 video image on an ARM runner

The video stage now installs Chrome's system libraries with microdnf, so it runs code for arm64.
The pack job built that image on ubuntu-latest with no emulation, which it could do only while the
stage copied files. A new lambda-video-image job builds it natively on ubuntu-24.04-arm, from the
handler zip whose sha256 the zip job reported, and reports the OCI tarball's sha256. Pack downloads
that tarball, checks the sha256 against the job's, and pins it as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(aws-lambda): fit the comment ratchet and the package size budget

chromium.ts loses the two doc lines on BUNDLED_SHELL_DIR and BUNDLED_SHELL_PATH; the names and the
SAM template's comment already say what they are.

@hyperframes/aws-lambda's unpacked budget goes from 290,508 to 298,000 bytes. The package unpacks to
295,324 bytes, up from the shared chrome-headless-shell staging module the ZIP and image scripts now
import and from the README and docs that describe the two Chrome sources.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
James Russo
2026-11-18 09:07:46 +00:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 3b79b1858e
commit 81d73d2278
27 changed files with 394 additions and 202 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ on:
- "packages/aws-lambda/image/**"
- "packages/aws-lambda/hf-media-linux-aarch64.sha256"
- "packages/aws-lambda/scripts/stage-arm64-image.ts"
# A @sparticuz/chromium bump or a ZIP layout change must re-stage the image.
# A dependency bump or a ZIP layout change must re-stage the image.
- "packages/aws-lambda/package.json"
- "packages/aws-lambda/scripts/build-zip.ts"
- "packages/aws-lambda/scripts/runtimeLock.ts"
+74 -12
View File
@@ -265,11 +265,73 @@ jobs:
path: packages/aws-lambda/dist/handler.zip
if-no-files-found: error
# The video stage installs Chrome's system libraries with microdnf, so it builds on ARM, not under emulation.
lambda-video-image:
name: Lambda video image
needs: [release-source, lambda-arm64-ffmpeg, lambda-handler-zip]
runs-on: ubuntu-24.04-arm
timeout-minutes: 30
permissions:
contents: read
env:
EXPECTED_RELEASE_SHA: ${{ needs.release-source.outputs.sha }}
if: needs.release-source.outputs.sha != ''
outputs:
sha256: ${{ steps.image.outputs.sha256 }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
ref: ${{ env.EXPECTED_RELEASE_SHA }}
persist-credentials: false
- name: Verify immutable release checkout
run: |
ACTUAL_SHA="$(git rev-parse HEAD)"
EXPECTED_COMMIT_SHA="$(git rev-parse "${EXPECTED_RELEASE_SHA}^{commit}")"
if [ "$ACTUAL_SHA" != "$EXPECTED_COMMIT_SHA" ]; then
echo "::error::Expected release commit $EXPECTED_COMMIT_SHA, checked out $ACTUAL_SHA"
exit 1
fi
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
no-cache: true
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: hyperframes-lambda-handler-zip
path: dist/lambda-handler-build
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: hf-media-linux-aarch64
path: dist/hf-media
- name: Build Lambda video image
id: image
env:
EXPECTED_ZIP_SHA256: ${{ needs.lambda-handler-zip.outputs.sha256 }}
run: |
ACTUAL_ZIP_SHA256="$(sha256sum dist/lambda-handler-build/handler.zip | cut -d' ' -f1)"
if [ -z "$EXPECTED_ZIP_SHA256" ] || [ "$ACTUAL_ZIP_SHA256" != "$EXPECTED_ZIP_SHA256" ]; then
echo "::error::Lambda handler zip sha256 $ACTUAL_ZIP_SHA256 does not match the build job's $EXPECTED_ZIP_SHA256"
exit 1
fi
bun packages/aws-lambda/scripts/stage-arm64-image.ts --zip=dist/lambda-handler-build/handler.zip \
--ffmpeg=dist/hf-media/hf-media-linux-aarch64.tar.gz --out=dist/arm64-image
# OCI export needs a docker-container builder; no attestations, so index.json lists one image.
docker buildx create --use
docker buildx build --progress=plain --platform linux/arm64 --target video \
--provenance=false --sbom=false --build-context task=dist/arm64-image/task \
--output type=oci,dest=dist/hyperframes-lambda-video-arm64.oci.tar packages/aws-lambda/image
echo "sha256=$(sha256sum dist/hyperframes-lambda-video-arm64.oci.tar | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: hyperframes-lambda-video-arm64
overwrite: true
path: dist/hyperframes-lambda-video-arm64.oci.tar
if-no-files-found: error
pack:
name: Build and pack
outputs:
bundle_id: ${{ steps.previous_bundle.outputs.artifact || steps.bundle.outputs.artifact-id }}
needs: [release-source, lambda-arm64-ffmpeg, lambda-handler-zip]
needs: [release-source, lambda-handler-zip, lambda-video-image]
runs-on: ubuntu-latest
timeout-minutes: 30
# Every build and lifecycle script of the release commit runs here, with a
@@ -385,24 +447,24 @@ jobs:
rm -rf dist/lambda-handler-build
bun packages/aws-lambda/scripts/pin-handler-zip.ts
# lambda-video-image built it on ARM from the same zip sha pinned above.
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
if: steps.previous_bundle.outputs.artifact == ''
with:
name: hf-media-linux-aarch64
path: dist/hf-media
name: hyperframes-lambda-video-arm64
path: dist
# Built from the zip pinned above. The video stage only copies files, so no emulation is needed.
- name: Build Lambda video image
- name: Pin Lambda video image
if: steps.previous_bundle.outputs.artifact == ''
id: lambda_video_image
env:
EXPECTED_SHA256: ${{ needs.lambda-video-image.outputs.sha256 }}
run: |
bun packages/aws-lambda/scripts/stage-arm64-image.ts --zip=dist/hyperframes-lambda-handler.zip \
--ffmpeg=dist/hf-media/hf-media-linux-aarch64.tar.gz --out=dist/arm64-image
# OCI export needs a docker-container builder; no attestations, so index.json lists one image.
docker buildx create --use
docker buildx build --progress=plain --platform linux/arm64 --target video \
--provenance=false --sbom=false --build-context task=dist/arm64-image/task \
--output type=oci,dest=dist/hyperframes-lambda-video-arm64.oci.tar packages/aws-lambda/image
ACTUAL_SHA256="$(sha256sum dist/hyperframes-lambda-video-arm64.oci.tar | cut -d' ' -f1)"
if [ -z "$EXPECTED_SHA256" ] || [ "$ACTUAL_SHA256" != "$EXPECTED_SHA256" ]; then
echo "::error::Lambda video image sha256 $ACTUAL_SHA256 does not match the build job's $EXPECTED_SHA256"
exit 1
fi
bun packages/aws-lambda/scripts/pin-handler-zip.ts --video-image
- run: bun run verify:packed-manifests