Files
Epicnabbo-Catalogus-Updated…/src/lib/deploy-workflow-contract.test.ts
T
openhands fabd160250 fix(ci): bound Docker build cache with BuildKit cache mounts
- Move the pnpm store, apk and .next caches into --mount=type=cache so
  dependencies are shared across builds instead of duplicated in fresh
  image layers (was the source of unbounded disk growth).
- Replace the deprecated --keep-storage prune flag in ci-deploy.sh with
  the working --max-used-space=4g (buildx v0.37 renamed the flag). The
  deprecated flag silently did nothing, so the BuildKit cache kept
  growing unbounded (was 15.86GB); it is now capped at 4GB after every
  deploy.
2026-09-08 15:39:13 +02:00

42 lines
1.8 KiB
TypeScript

import { readFileSync } from "node:fs";
import { expect, it } from "vitest";
const workflow = readFileSync(".gitea/workflows/ci.yaml", "utf8");
const deploy = readFileSync("scripts/ci-deploy.sh", "utf8");
it("uses two test workers and runs smoke checks in the deployment transaction", () => {
expect(workflow).toContain("pnpm test --maxWorkers=2");
expect(workflow).not.toContain("\n e2e:");
expect(workflow).toContain("bash scripts/ci-deploy.sh");
expect(deploy).toContain(
"PLAYWRIGHT_BASE_URL=http://127.0.0.1:3002 pnpm test:e2e",
);
});
it("locks CI and scheduled deployments using the same production lock", () => {
expect(deploy).toContain('exec 9>"$deploy_dir/.deploy.lock"');
expect(deploy).toContain("flock -w 1800 9");
const scheduled = readFileSync("scripts/docker-update.sh", "utf8");
expect(scheduled).toContain('exec 9>"$DIR/.deploy.lock"');
expect(scheduled.indexOf("flock -w 1800 9")).toBeLessThan(
scheduled.indexOf("git pull --ff-only"),
);
});
it("preserves production runtime configuration and recent cache", () => {
expect(deploy).toContain("--net=host");
expect(deploy).toContain("--restart always");
expect(deploy).toContain("/var/www/Gamedata:/var/www/Gamedata");
expect(deploy).toContain("/app/storage");
expect(deploy).not.toContain("--env-file");
expect(deploy).toContain(
'docker builder prune -af --filter "until=72h" --max-used-space=4g',
);
expect(deploy).not.toContain("docker volume prune");
});
it("builds the checked out source without fetching a moving remote branch", () => {
const dockerfile = readFileSync("Dockerfile", "utf8");
expect(dockerfile).toContain("COPY . .");
expect(dockerfile).not.toMatch(
/^ADD\s+https?:\/\/.*(?:repository|branches)/m,
);
expect(dockerfile).not.toMatch(/^RUN\s+git\s+(?:pull|fetch|clone)\b/m);
});