Run vitest without coverage by default (pnpm test) and add pnpm test:coverage which enforces the coverage thresholds. CI keeps using the coverage run so thresholds are still enforced on every push.
42 lines
1.8 KiB
TypeScript
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:coverage --maxWorkers=2");
|
|
expect(workflow).not.toContain("\n e2e:");
|
|
expect(workflow).toContain("bash scripts/ci-deploy.sh");
|
|
expect(deploy).toContain(
|
|
"node scripts/verify-deployed-release.mjs http://127.0.0.1:3002/api/health",
|
|
);
|
|
});
|
|
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);
|
|
});
|