first commit
All checks were successful
Verify and publish Calio container / build-and-push (push) Successful in 1m4s
All checks were successful
Verify and publish Calio container / build-and-push (push) Successful in 1m4s
This commit is contained in:
commit
6fc0a01c56
51 changed files with 11319 additions and 0 deletions
50
tests/publishing.test.js
Normal file
50
tests/publishing.test.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { publicationPlan, publishImage } from "../scripts/publish-image.js";
|
||||
const base = {
|
||||
CI_EVENT: "push",
|
||||
REPOSITORY: "Elijah/Calio",
|
||||
COMMIT_SHA: "a".repeat(40),
|
||||
TARGET_REF: "refs/heads/main",
|
||||
MAIN_BRANCH: "main",
|
||||
};
|
||||
test("each push publishes a commit image; only main promotes latest", () => {
|
||||
const main = publicationPlan(base);
|
||||
assert.equal(main.image, "git.elijahkuntz.com/elijah/calio");
|
||||
assert.deepEqual(main.tags, [base.COMMIT_SHA]);
|
||||
assert.equal(main.latest, true);
|
||||
const branch = publicationPlan({
|
||||
...base,
|
||||
TARGET_REF: "refs/heads/codex/new-ui",
|
||||
});
|
||||
assert.equal(branch.latest, false);
|
||||
assert.deepEqual(branch.tags, [base.COMMIT_SHA]);
|
||||
});
|
||||
test("release tags add a version without overwriting main latest", () => {
|
||||
assert.deepEqual(
|
||||
publicationPlan({ ...base, TARGET_REF: "refs/tags/v0.1.0" }).tags,
|
||||
[base.COMMIT_SHA, "v0.1.0"],
|
||||
);
|
||||
assert.equal(
|
||||
publicationPlan({ ...base, TARGET_REF: "refs/tags/v0.1.0" }).latest,
|
||||
false,
|
||||
);
|
||||
assert.deepEqual(
|
||||
publicationPlan({ ...base, TARGET_REF: "refs/tags/test/snapshot" }).tags,
|
||||
[base.COMMIT_SHA],
|
||||
);
|
||||
});
|
||||
test("PRs never publish or require registry secrets; missing publishing credentials fail clearly", () => {
|
||||
assert.equal(publicationPlan({ ...base, CI_EVENT: "pull_request" }), null);
|
||||
assert.throws(() => publishImage(base), /FORGEJO_PAT/);
|
||||
});
|
||||
test("invalid image names and commit identifiers cannot enter Docker command arguments", () => {
|
||||
assert.throws(
|
||||
() => publicationPlan({ ...base, REPOSITORY: "bad/name;command" }),
|
||||
/REPOSITORY/,
|
||||
);
|
||||
assert.throws(
|
||||
() => publicationPlan({ ...base, COMMIT_SHA: "--help" }),
|
||||
/commit ID/,
|
||||
);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue