## Problem and outcome / 问题与结果 An otherwise published release could leave its AtomGit downloads incomplete when the platform had not yet synchronized its Git tag, or when a larger package exceeded the upload deadline. Recovery previously required a manual workflow run. The existing mirror workflow now checks every three hours and after CI completion. It only resumes the latest published release, locates its original CI artifacts, and retains the existing full-download checksum verification. Complete or deferred mirrors use a sparse tooling checkout and skip dependency installation and artifact downloads. Git synchronization remains entirely with AtomGit; publication waits for the matching synchronized commit and tag and never creates or changes Git references. Increase only the signed upload deadline from three to ten minutes, following the observed 51 MB APK timeout. Metadata/read timeouts, retry counts and the workflow's 30-minute limit remain unchanged. ## Verification / 验证 - 58 focused mirror/publisher tests, TypeScript, documentation and diff checks passed. - Actual AtomGit readiness was checked against the v2.6.1 source and tag. Fixtures include the provider's four automatic source archives and distinguish them from uploaded packages. - The release planner returns `publish: false`. This workflow resumes existing verified packages and performs no software build. ## Impact / 影响 Release automation only. Source synchronization belongs to AtomGit; Release and attachment completion belong to this workflow. Missing original artifacts or conflicting source identities remain explicit failures and never cause a published version to be rebuilt or overwritten.
55 lines
3.6 KiB
TypeScript
55 lines
3.6 KiB
TypeScript
import { expect, test, vi } from "vitest";
|
|
import { mirrorReadiness, mirrorSourceReady, readMirror } from "../scripts/release-mirror-ready.mjs";
|
|
|
|
const revision = "a".repeat(40), version = "v2.6.1";
|
|
const asset = { name: "piik-app-fixture.zip", state: "uploaded", size: 1024, digest: `sha256:${"b".repeat(64)}` };
|
|
const source = { tag_name: version, target_commitish: revision, draft: false, prerelease: false, assets: [asset] };
|
|
const mirror = { tag_name: version, prerelease: false, body: `<!-- piik-source: ${revision} -->`, assets: [{
|
|
type: "attach", name: asset.name, size: asset.size, browser_download_url: `https://atomgit.com/TNTcraftHIM/Piik/releases/download/${version}/${asset.name}`,
|
|
}, ...["zip", "tar.gz", "tar.bz2", "tar"].map(extension => ({ type: "source", name: `${version}.${extension}` }))] };
|
|
|
|
test("a completed stable mirror needs only its metadata and no source search or package download", async () => {
|
|
const read = vi.fn(async () => mirror);
|
|
expect(await mirrorReadiness(source, read)).toEqual({ status: "complete", version, revision });
|
|
expect(read.mock.calls).toEqual([[`/releases/tags/${version}`]]);
|
|
});
|
|
|
|
test.each(["commit", "tag"])("missing synced %s defers without a Git mutation", async missing => {
|
|
const read = vi.fn(async (path: string) => path.startsWith("/releases/") ? null
|
|
: path.startsWith("/commits/") ? missing === "commit" ? null : { sha: revision } : []);
|
|
expect(await mirrorReadiness(source, read)).toEqual({ status: "deferred", version, revision });
|
|
});
|
|
|
|
test("a pending release resumes only after its exact tag and source exist", async () => {
|
|
const read = vi.fn(async (path: string) => path.startsWith("/releases/") ? { ...mirror, prerelease: true, assets: [] }
|
|
: path.startsWith("/commits/") ? { sha: revision } : [{ name: version, commit: { sha: revision } }]);
|
|
expect(await mirrorReadiness(source, read)).toEqual({ status: "ready", version, revision });
|
|
expect(read.mock.calls.every(([path]) => path.startsWith("/releases/") || path.startsWith("/commits/") || path.startsWith("/tags?"))).toBe(true);
|
|
});
|
|
|
|
test("a missing attachment in a published release and a conflicting tag fail rather than silently repairing identity", async () => {
|
|
await expect(mirrorReadiness(source, async () => ({ ...mirror, assets: [] }))).rejects.toThrow("incomplete");
|
|
await expect(mirrorSourceReady(version, revision, async (path: string) => path.startsWith("/commits/")
|
|
? { sha: revision } : [{ name: version, commit: { sha: "c".repeat(40) } }])).rejects.toThrow("another source");
|
|
});
|
|
|
|
test("a provider source archive cannot stand in for a published package", async () => {
|
|
await expect(mirrorReadiness(source, async () => ({ ...mirror,
|
|
assets: mirror.assets.map(asset => ({ ...asset, type: "source" })),
|
|
}))).rejects.toThrow("incomplete");
|
|
});
|
|
|
|
test("a truncated tag inventory fails after ten pages rather than claiming the source is absent", async () => {
|
|
const read = vi.fn(async (path: string) => path.startsWith("/commits/") ? { sha: revision }
|
|
: Array.from({ length: 100 }, (_, index) => ({ name: `other-${index}`, commit: { sha: revision } })));
|
|
await expect(mirrorSourceReady(version, revision, read)).rejects.toThrow("exceeds 10 pages");
|
|
expect(read).toHaveBeenCalledTimes(11);
|
|
expect(read.mock.calls.at(-1)).toEqual(["/tags?per_page=100&page=10"]);
|
|
});
|
|
|
|
test("readiness treats an unavailable API as failure, not pending synchronization", async () => {
|
|
vi.stubGlobal("fetch", vi.fn(async () => new Response(null, { status: 503 })));
|
|
try { await expect(readMirror("/commits/" + revision)).rejects.toThrow("HTTP 503"); }
|
|
finally { vi.unstubAllGlobals(); }
|
|
});
|