test: allow headroom for shell fixture subprocesses

This commit is contained in:
gitea committed 2026-10-20 23:00:39 +08:00
1 parent fac81b08e8
commit 48ab35a8ac
2 files changed
+21 -19

No files matched your search

+13 -12
View File
@@ -8,6 +8,7 @@ import { parse } from "yaml";
import { bumpVersion } from "./bump-version.js";
import { verifyReleaseTag } from "./verify-release.js";
// Shell fixtures start several processes; allow headroom on a busy host.
const roots: string[] = [];
afterEach(() => { for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }); });
@@ -72,7 +73,7 @@ esac
`, { mode: 0o755 });
const workflow = parse(readFileSync(join(import.meta.dir, "../.github/workflows/release.yml"), "utf8"));
const step = workflow.jobs["build-and-publish"].steps.find((s: { name?: string }) => s.name === "Publish Gitea Release");
return { ...f, files, run: () => spawnSync("bash", ["-eo", "pipefail", "-c", step.run], { cwd: f.root, env: { ...process.env, PATH: `${tools}:${process.env.PATH}`, GITEA_TOKEN: "fixture", GITEA_RETRY_DELAY: "0", GITEA_HOST: "https://example.test", GITEA_REPO: "test/repo", RELEASE_TAG: "v1.0.0", MIRROR_ONLY: String(mirrorOnly), GITHUB_REPOSITORY: "test/repo", MIRROR_FIXTURE: f.root, MIRROR_MODE: mode }, encoding: "utf8", timeout: 5000 }) };
return { ...f, files, run: () => spawnSync("bash", ["-eo", "pipefail", "-c", step.run], { cwd: f.root, env: { ...process.env, PATH: `${tools}:${process.env.PATH}`, GITEA_TOKEN: "fixture", GITEA_RETRY_DELAY: "0", GITEA_HOST: "https://example.test", GITEA_REPO: "test/repo", RELEASE_TAG: "v1.0.0", MIRROR_ONLY: String(mirrorOnly), GITHUB_REPOSITORY: "test/repo", MIRROR_FIXTURE: f.root, MIRROR_MODE: mode }, encoding: "utf8", timeout: 30_000 }) };
}
describe("release preparation and publication guards", () => {
@@ -86,7 +87,7 @@ describe("release preparation and publication guards", () => {
for (const version of ["1.0.0", "0.9.9", "1.0.01", "1.0.1-rc.01", "invalid"]) expect(() => bumpVersion(f.root, version, () => {})).toThrow();
expect(f.version()).toBe("1.0.0");
expect(f.git("status", "--porcelain")).toBe("");
});
}, 60_000);
test("bump updates sources on its release branch and explicitly invokes regeneration", () => {
const f = repository();
@@ -97,7 +98,7 @@ describe("release preparation and publication guards", () => {
expect(f.version()).toBe("1.0.1");
expect(readFileSync(join(f.root, "skills/hose-use/SKILL.md"), "utf8")).toContain("version: 1.0.1");
expect(parse(readFileSync(join(f.root, "specs/openapi/openapi.yaml"), "utf8")).info.version).toBe("1.0.1");
});
}, 60_000);
test("an existing release tag cannot be reused during bump", () => {
const f = repository();
@@ -105,7 +106,7 @@ describe("release preparation and publication guards", () => {
f.git("tag", "v1.0.1");
expect(() => bumpVersion(f.root, "patch", () => {})).toThrow("already exists");
expect(f.version()).toBe("1.0.0");
});
}, 60_000);
test("publication validates the actual HEAD, main ancestry and package version", () => {
const f = repository();
@@ -120,7 +121,7 @@ describe("release preparation and publication guards", () => {
expect(() => verifyReleaseTag(f.root, "v1.0.0")).toThrow("exact tagged commit");
f.git("tag", "v1.0.1");
expect(() => verifyReleaseTag(f.root, "v1.0.1")).toThrow("ancestor");
});
}, 60_000);
test("workflows validate committed versions before generation and ship the checksum manifest", () => {
const root = join(import.meta.dir, "..");
@@ -140,7 +141,7 @@ describe("release preparation and publication guards", () => {
for (const name of ["Compile multi-target binaries", "Package release archives", "Publish GitHub Release"]) {
expect(steps.find((s: { name?: string }) => s.name === name).if).toBe("${{ !inputs.mirror_only }}");
}
});
}, 60_000);
test("a failed background Gitea upload makes the Release step fail", () => {
const f = repository();
@@ -159,11 +160,11 @@ for arg in "$@"; do
done
exit 22
`, { mode: 0o755 });
const result = spawnSync("bash", ["-eo", "pipefail", "-c", step.run], { cwd: f.root, env: { ...process.env, PATH: `${join(f.root, "tools")}:${process.env.PATH}`, GITEA_TOKEN: "fixture", GITEA_RETRY_DELAY: "0", GITEA_HOST: "https://example.test", GITEA_REPO: "test/repo", RELEASE_TAG: "v1.0.0" }, encoding: "utf8", timeout: 5000 });
const result = spawnSync("bash", ["-eo", "pipefail", "-c", step.run], { cwd: f.root, env: { ...process.env, PATH: `${join(f.root, "tools")}:${process.env.PATH}`, GITEA_TOKEN: "fixture", GITEA_RETRY_DELAY: "0", GITEA_HOST: "https://example.test", GITEA_REPO: "test/repo", RELEASE_TAG: "v1.0.0" }, encoding: "utf8", timeout: 30_000 });
expect(result.status).toBe(1);
expect(result.stdout).toContain("assets failed to upload");
expect(result.stdout).not.toContain("Successfully published");
});
}, 60_000);
test("transient asset upload failures are retried", () => {
const f = mirrorFixture("retry");
@@ -171,20 +172,20 @@ exit 22
expect(result.status).toBe(0);
for (const name of f.files) expect(readFileSync(join(f.root, `count-${name}`), "utf8")).toBe("2");
expect(result.stdout).toContain("attempt 2/3");
});
}, 60_000);
test("correct mirror assets are verified and retained without uploading replacements", () => {
const f = mirrorFixture("skip");
const result = f.run();
expect(result.status).toBe(0);
expect(result.stdout.match(/already matches SHA-256/g)).toHaveLength(f.files.length);
});
}, 60_000);
test("mirror-only recovery downloads and verifies the existing GitHub assets", () => {
const f = mirrorFixture("skip", true);
expect(f.run().status).toBe(0);
expect(readFileSync(join(f.root, "gh.log"), "utf8")).toContain("release download v1.0.0");
});
}, 60_000);
test("asset transfers never exceed two concurrent workers", () => {
const f = mirrorFixture("concurrency");
@@ -196,5 +197,5 @@ exit 22
}
expect(active).toBe(0);
expect(peak).toBeLessThanOrEqual(2);
});
}, 60_000);
});