import { describe, expect, it } from "vitest"; import { ciBuildEnvironmentFailures, LOCAL_BUILD_IDENTITY, localBuildEnvironment, } from "../../scripts/lib/build-environment.ts"; import visualConfig from "../../playwright.visual.config.ts"; /** * 1103/11-08. The workflow sets CI=true and the CI build identity for every * job. A build a test makes of a copy is a local build: it used to inherit * CI=true and be checked as a release build. Inside vitest, whose config * drops VITE_COMMIT_SHA (11-07), that failed with "missing required CI build * environment: VITE_COMMIT_SHA"; the visual goldens' build failed on its * local commit id "local". */ const CI_JOB = Object.freeze({ CI: "true", VITE_BUILD_ID: "gitea-41-1", RELEASE_ID: "refs/heads/fix/example-41-1", CI_RUNNER_IMAGE: `local/runner@sha256:${"a".repeat(64)}`, SOURCE_DATE_EPOCH: "1793700000", PATH: "/usr/bin", }); describe("local build environment (1103/11-08)", () => { it("is not checked as a CI build, whatever CI identity the job has", () => { const local = localBuildEnvironment(CI_JOB); expect(ciBuildEnvironmentFailures(local)).toEqual([]); expect(local).not.toHaveProperty("CI"); expect(local).not.toHaveProperty("VITE_BUILD_ID"); expect(local["PATH"]).toBe("/usr/bin"); }); it("keeps a CI job's own release build checked", () => { expect(ciBuildEnvironmentFailures(CI_JOB)).toContain( "missing required CI build environment: VITE_COMMIT_SHA", ); }); it("starts the visual goldens' build as a local build inside a CI job", () => { const webServer = visualConfig.webServer; const env = Array.isArray(webServer) ? undefined : webServer?.env; // Playwright merges a web server's env over the runner's process.env. expect(ciBuildEnvironmentFailures({ ...CI_JOB, ...env })).toEqual([]); expect(env).toMatchObject(LOCAL_BUILD_IDENTITY); }); });