mirror of
https://github.com/multica-ai/multica.git
synced 2026-09-29 16:59:28 +08:00
* ci: scope validation and remove duplicate lifecycle runs
Co-authored-by: multica-agent <github@multica.ai>
* fix(migrations): renumber the Triage validate migration to 489
#8449 and #8436 merged minutes apart and both took 485, so
TestMigrationNumericPrefixesAreUnique fails on main and every PR branched from
it. #8436 owns 485-488, so the single validate file moves to 489.
Renaming an applied migration makes databases that already recorded
485_issue_triage_state_validate run it once more under the new version string.
That is safe here: VALIDATE CONSTRAINT on an already-validated constraint is a
no-op, verified against PostgreSQL 17.
Co-authored-by: multica-agent <github@multica.ai>
(cherry picked from commit 09140a04ae)
* fix(ci): gate installers and reuse frontend quality setup
Co-authored-by: multica-agent <github@multica.ai>
* docs(ci): remove redundant CI overview
Co-authored-by: multica-agent <github@multica.ai>
* refactor(ci): remove unused output and duplicate test fixtures
Co-authored-by: multica-agent <github@multica.ai>
---------
Co-authored-by: Lambda <lambda@multica.ai>
Co-authored-by: multica-agent <github@multica.ai>
Co-authored-by: J <bohan@devv.ai>
53 lines
2.7 KiB
JavaScript
53 lines
2.7 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
import test from "node:test";
|
|
|
|
test("image checks need only a shallow head and the exact base, not full history", (t) => {
|
|
const dir = mkdtempSync(join(tmpdir(), "image-budget-"));
|
|
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
const source = join(dir, "source");
|
|
const checkout = join(dir, "checkout");
|
|
mkdirSync(source);
|
|
const env = {
|
|
...process.env,
|
|
GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null",
|
|
GIT_AUTHOR_NAME: "CI test", GIT_AUTHOR_EMAIL: "ci@example.invalid",
|
|
GIT_COMMITTER_NAME: "CI test", GIT_COMMITTER_EMAIL: "ci@example.invalid",
|
|
};
|
|
const git = (cwd, ...args) => execFileSync("git", args, { cwd, env, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
git(source, "init", "-b", "main");
|
|
writeFileSync(join(source, "existing.png"), Buffer.alloc(400 * 1024));
|
|
git(source, "add", ".");
|
|
git(source, "commit", "-m", "base");
|
|
const base = git(source, "rev-parse", "HEAD");
|
|
// Put an intermediate commit between base and head to prove no ancestry is needed.
|
|
writeFileSync(join(source, "README.md"), "intermediate\n");
|
|
git(source, "add", ".");
|
|
git(source, "commit", "-m", "intermediate");
|
|
const intermediate = git(source, "rev-parse", "HEAD");
|
|
writeFileSync(join(source, "new.png"), Buffer.alloc(350 * 1024));
|
|
git(source, "add", ".");
|
|
git(source, "commit", "-m", "head");
|
|
git(dir, "clone", "--depth=1", pathToFileURL(source).href, checkout);
|
|
git(checkout, "fetch", "--no-tags", "--depth=1", "origin", base);
|
|
assert.equal(git(checkout, "rev-parse", "--is-shallow-repository"), "true");
|
|
assert.notEqual(spawnSync("git", ["cat-file", "-e", intermediate], { cwd: checkout, env }).status, 0);
|
|
|
|
const script = fileURLToPath(new URL("./check-image-budget.mjs", import.meta.url));
|
|
const check = (body = "") => spawnSync(process.execPath, [script, "--base", base], {
|
|
cwd: checkout, env: { ...env, PR_BODY: body }, encoding: "utf8",
|
|
});
|
|
const oversized = check();
|
|
assert.equal(oversized.status, 1, oversized.stderr);
|
|
assert.match(oversized.stdout, /new\.png/);
|
|
assert.doesNotMatch(oversized.stdout, /existing\.png/);
|
|
assert.equal(check("Oversized image exemption: required test fixture").status, 0);
|
|
writeFileSync(join(checkout, "new.png"), Buffer.alloc(100));
|
|
writeFileSync(join(checkout, "existing.png"), Buffer.alloc(350 * 1024));
|
|
assert.equal(check().status, 0, "unchanged or shrinking oversized files should pass");
|
|
});
|