mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 00:18:27 +00:00
fix(aws-lambda): the release ships the arm64 ffmpeg only when it matches its committed digest (#7872)
* fix(aws-lambda): the release ships the arm64 ffmpeg only when it matches its committed digest * style(ci): format the release workflow tests
This commit is contained in:
@@ -9,6 +9,7 @@ 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 @sparticuz/chromium bump or a ZIP layout change must re-stage the image.
|
||||
- "packages/aws-lambda/package.json"
|
||||
@@ -59,6 +60,10 @@ jobs:
|
||||
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
|
||||
|
||||
@@ -52,6 +52,10 @@ jobs:
|
||||
run: >-
|
||||
docker buildx build --progress=plain --platform linux/arm64 --target artifact
|
||||
--output type=local,dest=out packages/aws-lambda/image
|
||||
# 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
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||
with:
|
||||
name: hf-media-linux-aarch64
|
||||
@@ -89,7 +93,10 @@ jobs:
|
||||
echo "::error::Expected release commit $EXPECTED_COMMIT_SHA, checked out $ACTUAL_SHA"
|
||||
exit 1
|
||||
fi
|
||||
# The release installs the bun it downloads, never one restored from the shared cache.
|
||||
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
||||
with:
|
||||
no-cache: true
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
||||
with:
|
||||
node-version: 24
|
||||
@@ -176,7 +183,10 @@ jobs:
|
||||
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
|
||||
run: node scripts/validate-release-channel.mjs
|
||||
|
||||
# The release installs the bun it downloads, never one restored from the shared cache.
|
||||
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
||||
with:
|
||||
no-cache: true
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
||||
with:
|
||||
node-version: 24
|
||||
|
||||
@@ -9,11 +9,9 @@ env:
|
||||
# Measures drag smoothness on a runner with nothing else on it. The bench measures a blank page per case
|
||||
# in the same run, and the box only counts as quiet if that control dropped no frame anywhere.
|
||||
on:
|
||||
# Dispatch on the ref to measure: the run then checks out that ref and writes only that ref's cache.
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
ref:
|
||||
description: Commit, branch or tag to measure
|
||||
default: main
|
||||
filter:
|
||||
description: Case ids to run (a regular expression)
|
||||
default: "^(move|resize|rotate|crop)-(none|tween)-px-r0-root-z100$"
|
||||
@@ -34,13 +32,11 @@ jobs:
|
||||
matrix:
|
||||
run: [1, 2, 3, 4, 5]
|
||||
env:
|
||||
BENCH_REF: ${{ inputs.ref || 'main' }}
|
||||
BENCH_FILTER: ${{ inputs.filter || '^(move|resize|rotate|crop)-(none|tween)-px-r0-root-z100$' }}
|
||||
BENCH_GRID: ${{ inputs.grid || 'pr' }}
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
with:
|
||||
ref: ${{ env.BENCH_REF }}
|
||||
lfs: true
|
||||
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
||||
|
||||
@@ -27,12 +27,8 @@ on:
|
||||
branches: [main]
|
||||
push:
|
||||
branches: [main]
|
||||
# Dispatch on the ref to render: the run then checks out that ref and writes only that ref's cache.
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
ref:
|
||||
description: "Git ref to render (branch / tag / SHA)."
|
||||
required: false
|
||||
default: ""
|
||||
|
||||
concurrency:
|
||||
group: windows-render-${{ github.ref }}
|
||||
@@ -98,7 +94,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
with:
|
||||
ref: ${{ inputs.ref || github.sha }}
|
||||
ref: ${{ github.sha }}
|
||||
- uses: ./.github/actions/preflight
|
||||
|
||||
render-windows:
|
||||
@@ -125,7 +121,7 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
with:
|
||||
ref: ${{ inputs.ref || github.sha }}
|
||||
ref: ${{ github.sha }}
|
||||
lfs: true
|
||||
|
||||
- name: Show platform info
|
||||
@@ -459,7 +455,7 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
with:
|
||||
ref: ${{ inputs.ref || github.sha }}
|
||||
ref: ${{ github.sha }}
|
||||
# Only the engine-cli lanes read an LFS file (engine's ffprobe test parses a producer HDR PNG).
|
||||
lfs: ${{ matrix.process_tests == true }}
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
897b12368d50a60a8141f75dc293b29750925fe74ce8a6f2b21b1f6d83e28e13 hf-media-linux-aarch64.tar.gz
|
||||
@@ -42,3 +42,21 @@ test("preflight installs without downloading ffmpeg or Chrome", () => {
|
||||
assert.ok(ffmpeg >= 0 && ffmpeg < install, "prepare-ffmpeg-bin runs before bun install");
|
||||
assert.equal(steps[install].env?.PUPPETEER_SKIP_DOWNLOAD, "true");
|
||||
});
|
||||
|
||||
// A dispatched run's cache scope is its own ref; a ref chosen by an input would run that code under main's scope.
|
||||
test("no dispatched workflow checks out a ref its inputs choose", () => {
|
||||
const chosen = workflows.flatMap(({ file, doc }) => {
|
||||
const inputs = Object.keys(doc.on?.workflow_dispatch?.inputs ?? {});
|
||||
return Object.entries(doc.jobs ?? {}).flatMap(([name, job]) =>
|
||||
(job.steps ?? [])
|
||||
.filter((step) => step.uses?.startsWith("actions/checkout@"))
|
||||
.filter(
|
||||
(step) =>
|
||||
/\binputs\.|github\.event\.inputs\./.test(String(step.with?.ref ?? "")) ||
|
||||
inputs.includes("ref"),
|
||||
)
|
||||
.map(() => `${file} ${name}`),
|
||||
);
|
||||
});
|
||||
assert.deepEqual([...new Set(chosen)], []);
|
||||
});
|
||||
|
||||
@@ -492,3 +492,48 @@ test("every publish runs in the approval-gated npm-publish environment", () => {
|
||||
["publish"],
|
||||
);
|
||||
});
|
||||
|
||||
const pin = readFileSync(
|
||||
new URL("../packages/aws-lambda/hf-media-linux-aarch64.sha256", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const digestCheck = (steps) =>
|
||||
steps.findIndex((step) => step.name === "Check the tarball against its committed digest");
|
||||
|
||||
test("the Lambda ffmpeg ships only when it matches its committed digest", () => {
|
||||
assert.match(pin, /^[0-9a-f]{64} {2}hf-media-linux-aarch64\.tar\.gz\n$/);
|
||||
const steps = config.jobs["lambda-arm64-ffmpeg"].steps;
|
||||
const at = digestCheck(steps);
|
||||
const upload = steps.findIndex((step) => step.uses?.startsWith("actions/upload-artifact@"));
|
||||
assert.ok(
|
||||
at > 0 && at < upload,
|
||||
"the check runs after the cache or the build, before the upload",
|
||||
);
|
||||
assert.equal(steps[at].if, undefined, "a cache hit and a fresh build are both checked");
|
||||
assert.match(
|
||||
steps[at].run,
|
||||
/sha256sum --strict -c \.\.\/packages\/aws-lambda\/hf-media-linux-aarch64\.sha256$/,
|
||||
);
|
||||
|
||||
const image = parse(
|
||||
readFileSync(new URL("../.github/workflows/lambda-arm64-image.yml", import.meta.url), "utf8"),
|
||||
);
|
||||
assert.ok(
|
||||
digestCheck(image.jobs.ffmpeg.steps) > 0,
|
||||
"a pull request that changes the build must update the digest",
|
||||
);
|
||||
assert.ok(
|
||||
image.on.pull_request.paths.includes("packages/aws-lambda/hf-media-linux-aarch64.sha256"),
|
||||
);
|
||||
});
|
||||
|
||||
test("the release installs no tool restored from the shared cache", () => {
|
||||
const steps = Object.values(config.jobs).flatMap((job) => job.steps ?? []);
|
||||
const bun = steps.filter((step) => step.uses?.startsWith("oven-sh/setup-bun@"));
|
||||
assert.ok(bun.length >= 1);
|
||||
assert.equal(bun.filter((step) => step.with?.["no-cache"] !== true).length, 0);
|
||||
assert.equal(
|
||||
steps.filter((step) => step.uses?.startsWith("actions/setup-node@") && step.with?.cache).length,
|
||||
0,
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user