mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 11:26:02 +00:00
- build-zip --source=chrome-headless-shell stages only the repo's pinned build (managedChromeVersion) and only when its folder matches the pinned digest (isPinnedHeadlessShell), instead of the newest folder in the cache. The folder cannot fit a ZIP function, so lambda deploy refuses --chrome-source chrome-headless-shell up front on either arch, and the docs say the arm64 video image is where the shell runs. - build-zip prints the headroom under the unzipped gate, and a new "Lambda handler ZIP" workflow builds the ZIP on PRs that touch the code it bundles, so growth fails before merge rather than in the release job. - The arm64 image keeps @sparticuz/chromium's fonts and fonts.conf from the handler ZIP (FONTCONFIG_PATH=/var/task/fonts) instead of liberation-fonts, so text falls back to the same fonts as on x86. The image workflow renders a mixed-script page on both arches and fails when any line resolves to different platform fonts. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
191 lines
7.9 KiB
YAML
191 lines
7.9 KiB
YAML
name: Lambda arm64 image
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
# Builds the arm64 Lambda video function image: the native ffmpeg on two separate ARM runners (each runs
|
|
# the codec check, the tarballs must match), then the image from the x86 handler ZIP, smoke-run on ARM.
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- "packages/aws-lambda/image/**"
|
|
- "packages/aws-lambda/hf-media-linux-aarch64.sha256"
|
|
- "packages/aws-lambda/scripts/stage-arm64-image.ts"
|
|
# 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"
|
|
- "packages/aws-lambda/scripts/runtime-lock/**"
|
|
- ".github/workflows/lambda-arm64-image.yml"
|
|
# On main it also seeds publish.yml's ffmpeg cache.
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- "packages/aws-lambda/image/**"
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: lambda-arm64-image-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
changes:
|
|
name: Detect changes
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 4
|
|
outputs:
|
|
release_only: ${{ steps.release.outputs.release_only }}
|
|
steps:
|
|
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Find a release-only diff
|
|
id: release
|
|
uses: ./.github/actions/release-only-diff
|
|
|
|
ffmpeg:
|
|
name: ffmpeg ${{ matrix.copy }}
|
|
needs: changes
|
|
# A release PR changes versions and notes only; a failed change detection must not skip the build.
|
|
if: ${{ !cancelled() && needs.changes.outputs.release_only != 'true' }}
|
|
runs-on: ubuntu-24.04-arm
|
|
timeout-minutes: 90
|
|
strategy:
|
|
matrix:
|
|
copy: [a, b]
|
|
steps:
|
|
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
- name: Build and check
|
|
run: >-
|
|
docker buildx build --progress=plain --platform linux/arm64 --target artifact
|
|
--output type=local,dest=out packages/aws-lambda/image
|
|
- run: cat out/hf-media-check.txt && sha256sum out/*.tar.gz
|
|
# The reviewed digest of the build; a tarball from the cache or this run that differs fails here.
|
|
- name: Check the tarball against its committed digest
|
|
working-directory: out
|
|
run: sha256sum hf-media-linux-aarch64.tar.gz && sha256sum --strict -c ../packages/aws-lambda/hf-media-linux-aarch64.sha256
|
|
# Same path and key as publish.yml's lambda-arm64-ffmpeg job reads.
|
|
- if: matrix.copy == 'a' && github.ref == 'refs/heads/main'
|
|
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
|
|
with:
|
|
path: out/
|
|
key: hf-media-linux-aarch64-${{ hashFiles('packages/aws-lambda/image/**') }}
|
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
|
with:
|
|
name: hf-media-${{ matrix.copy }}
|
|
path: out/
|
|
retention-days: 7
|
|
|
|
reproducible:
|
|
name: ffmpeg builds match
|
|
needs: ffmpeg
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
steps:
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
|
|
- run: cmp hf-media-a/hf-media-linux-aarch64.tar.gz hf-media-b/hf-media-linux-aarch64.tar.gz
|
|
|
|
handler-zip:
|
|
name: Handler ZIP
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
steps:
|
|
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
- run: bun install --frozen-lockfile
|
|
- run: bun run build
|
|
- run: bun run --cwd packages/aws-lambda build:zip
|
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
|
with:
|
|
name: handler-zip
|
|
path: packages/aws-lambda/dist/handler.zip
|
|
retention-days: 7
|
|
|
|
image:
|
|
name: Image smoke
|
|
needs: [ffmpeg, handler-zip]
|
|
runs-on: ubuntu-24.04-arm
|
|
timeout-minutes: 20
|
|
steps:
|
|
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
|
|
with:
|
|
path: artifacts
|
|
- name: Stage /var/task
|
|
run: >-
|
|
bun packages/aws-lambda/scripts/stage-arm64-image.ts
|
|
--zip=artifacts/handler-zip/handler.zip
|
|
--ffmpeg=artifacts/hf-media-a/hf-media-linux-aarch64.tar.gz --out=staged
|
|
- name: Build image
|
|
run: >-
|
|
docker buildx build --progress=plain --platform linux/arm64 --target video
|
|
--build-context task=staged/task --load -t hf-video:ci packages/aws-lambda/image
|
|
- name: ffmpeg and Chrome run under the image's own Lambda runtime
|
|
run: |
|
|
docker run -d --name hf-smoke -p 9001:8080 \
|
|
-v "$PWD/packages/aws-lambda/image/smoke-video.mjs:/var/task/smoke-video.mjs:ro" \
|
|
hf-video:ci smoke-video.handler
|
|
reply=$(curl -sS --retry 30 --retry-all-errors --retry-delay 1 \
|
|
-d '{}' http://localhost:9001/2015-03-31/functions/function/invocations)
|
|
docker logs hf-smoke
|
|
jq 'del(.textPng)' <<<"$reply"
|
|
jq -e '.arch == "arm64" and .screenshotBytes > 0 and (.ffmpeg | startswith("ffmpeg version 7.0.2"))' <<<"$reply"
|
|
mkdir text && jq -S .fonts <<<"$reply" >text/fonts.json && jq -r .textPng <<<"$reply" | base64 -d >text/text.png
|
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
|
with:
|
|
name: text-arm64
|
|
path: text/
|
|
retention-days: 7
|
|
- name: The Lambda runtime loads the handler
|
|
run: |
|
|
docker run -d --name hf-video -p 9000:8080 hf-video:ci
|
|
reply=$(curl -sS --retry 30 --retry-all-errors --retry-delay 1 \
|
|
-d '{"Action":"not-an-action"}' http://localhost:9000/2015-03-31/functions/function/invocations)
|
|
docker logs hf-video
|
|
echo "$reply"
|
|
grep -q 'no recognised Action' <<<"$reply"
|
|
|
|
# The x86 function: the handler ZIP on the same base, running its @sparticuz/chromium.
|
|
x86-text:
|
|
name: x86 text render
|
|
needs: handler-zip
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
steps:
|
|
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
|
|
with:
|
|
name: handler-zip
|
|
path: artifacts
|
|
- name: The handler ZIP renders the text page under the Lambda runtime
|
|
run: |
|
|
unzip -q artifacts/handler.zip -d task
|
|
cp packages/aws-lambda/image/smoke-video.mjs task/
|
|
base=$(sed -n 's/^ARG BASE=//p' packages/aws-lambda/image/Dockerfile)
|
|
docker run -d --name hf-x86 --platform linux/amd64 -p 9002:8080 -v "$PWD/task:/var/task:ro" \
|
|
"$base" smoke-video.handler
|
|
reply=$(curl -sS --retry 30 --retry-all-errors --retry-delay 1 \
|
|
-d '{}' http://localhost:9002/2015-03-31/functions/function/invocations)
|
|
docker logs hf-x86
|
|
jq 'del(.textPng)' <<<"$reply"
|
|
jq -e '.arch == "x64" and .screenshotBytes > 0' <<<"$reply"
|
|
mkdir text && jq -S .fonts <<<"$reply" >text/fonts.json && jq -r .textPng <<<"$reply" | base64 -d >text/text.png
|
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
|
with:
|
|
name: text-x86
|
|
path: text/
|
|
retention-days: 7
|
|
|
|
# --video-arch picks which of the two renders a stack's frames, so each line must resolve to the same fonts on both.
|
|
text-compare:
|
|
name: Text fonts match across arches
|
|
needs: [image, x86-text]
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
steps:
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
|
|
with:
|
|
pattern: text-*
|
|
- run: cat text-arm64/fonts.json && diff text-x86/fonts.json text-arm64/fonts.json
|