Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -12,15 +12,19 @@ import {
const WORKFLOW_PATH = ".gitea/workflows/ci.yml";
const SENTRY_REUSABLE_WORKFLOW_PATH = ".gitea/workflows/_sentry-release.yml";
const REQUIRED_PNPM_VERSION = "10.33.0";
const REQUIRED_PNPM_VERSION = "11.12.0";
const QUALITY_GROUP_RUNNER_PATH = "scripts/ci/run-quality-groups.sh";
const QUALITY_GROUP_RUNNER_COMMAND = `bash ${QUALITY_GROUP_RUNNER_PATH}`;
const WEB_SOURCEMAPS_ARTIFACT_NAME = "web-client-sourcemaps";
const WEB_SOURCEMAPS_PATH = "apps/web/build/client";
const WEB_SOURCEMAPS_VALIDATE_COMMAND = "test -n \"$(find apps/web/build/client -type f -name '*.map' -print -quit)\"";
const WEB_SOURCEMAPS_PATH = "apps/web/build-sourcemaps";
const WEB_SOURCEMAPS_VALIDATE_COMMAND =
"test -n \"$(find apps/web/build-sourcemaps/core -type f -name '*.map' -print -quit)\" && test -n \"$(find apps/web/build-sourcemaps/portal -type f -name '*.map' -print -quit)\"";
const REQUIRED_COMMANDS_IN_ORDER = [
"pnpm run verify:github-ci-workflow",
"pnpm run verify:gitea-ci-workflow",
"pnpm run verify:deploy-workflow",
"pnpm run verify:deploy-readiness",
"pnpm run verify:licenses",
"pnpm audit --prod --audit-level high",
"pnpm run verify:ci-baseline",
"pnpm run verify:source-health",
"pnpm run verify:eslint-baseline",
@@ -39,17 +43,10 @@ const REQUIRED_COMMANDS_IN_ORDER = [
"pnpm run test:hot-swap",
"pnpm run verify:a11y-coverage",
"pnpm run test:a11y",
"pnpm run verify:porting-docs-baseline",
"pnpm run verify:production-docs",
"pnpm run verify:release-docs",
"pnpm run verify:docs-links",
"pnpm typecheck",
"pnpm lint",
"pnpm run test:foundation",
"pnpm run test:packages",
"pnpm test",
QUALITY_GROUP_RUNNER_COMMAND,
"pnpm run build:ci",
"pnpm run verify:bundle-size",
"pnpm run verify:runtime-closures -- --runtime=web",
"pnpm run verify:production-seed-artifact",
];
// The former monolithic "quality" job is split into parallel jobs to cut CI wallclock.
@@ -61,10 +58,11 @@ const REQUIRED_COMMANDS_IN_ORDER = [
// verify-1, the two heavy accessibility checks (a11y-coverage + a11y smoke) in verify-2.
const QUALITY_SPLIT_JOBS = ["verify-1", "verify-2", "typecheck-test", "build"];
const QUALITY_JOB_BY_COMMAND = {
"pnpm run verify:github-ci-workflow": "verify-1",
"pnpm run verify:gitea-ci-workflow": "verify-1",
"pnpm run verify:deploy-workflow": "verify-1",
"pnpm run verify:deploy-readiness": "verify-1",
"pnpm run verify:licenses": "verify-1",
"pnpm audit --prod --audit-level high": "verify-1",
"pnpm run verify:ci-baseline": "verify-1",
"pnpm run verify:source-health": "verify-1",
"pnpm run verify:eslint-baseline": "verify-1",
@@ -83,17 +81,10 @@ const QUALITY_JOB_BY_COMMAND = {
"pnpm run test:hot-swap": "verify-1",
"pnpm run verify:a11y-coverage": "verify-2",
"pnpm run test:a11y": "verify-2",
"pnpm run verify:porting-docs-baseline": "verify-2",
"pnpm run verify:production-docs": "verify-2",
"pnpm run verify:release-docs": "verify-2",
"pnpm run verify:docs-links": "verify-2",
"pnpm typecheck": "typecheck-test",
"pnpm lint": "typecheck-test",
"pnpm run test:foundation": "typecheck-test",
"pnpm run test:packages": "typecheck-test",
"pnpm test": "typecheck-test",
[QUALITY_GROUP_RUNNER_COMMAND]: "typecheck-test",
"pnpm run build:ci": "build",
"pnpm run verify:bundle-size": "build",
"pnpm run verify:runtime-closures -- --runtime=web": "build",
"pnpm run verify:production-seed-artifact": "build",
};
const SERVICE_JOB_CONTRACTS = {
@@ -104,6 +95,25 @@ const SERVICE_JOB_CONTRACTS = {
"pnpm --filter @hivegrid/api typecheck",
"pnpm exec vitest run apps/api/src",
"pnpm --filter @hivegrid/api build",
"pnpm run verify:runtime-closures -- --runtime=api",
],
},
mcp: {
label: "mcp",
commands: [
"pnpm --filter @hivegrid/mcp typecheck",
"pnpm --filter @hivegrid/mcp test",
"pnpm --filter @hivegrid/mcp build",
"pnpm run verify:runtime-closures -- --runtime=mcp",
],
},
hocuspocus: {
label: "hocuspocus",
commands: [
"pnpm --filter @hivegrid/hocuspocus typecheck",
"pnpm --filter @hivegrid/hocuspocus test",
"pnpm --filter @hivegrid/hocuspocus build",
"pnpm run verify:runtime-closures -- --runtime=hocuspocus",
],
},
worker: {
@@ -113,6 +123,7 @@ const SERVICE_JOB_CONTRACTS = {
"pnpm --filter @hivegrid/worker exec vitest run",
"pnpm run verify:workflow-outbox-native",
"pnpm --filter @hivegrid/worker build",
"pnpm run verify:runtime-closures -- --runtime=worker",
"pnpm --filter @hivegrid/worker health",
],
},
@@ -121,24 +132,39 @@ const DATABASE_JOB = "database";
const DATABASE_STATUS_COMMAND = "pnpm run verify:db-migrate-status:staging";
const DATABASE_GENERATE_COMMAND = "pnpm run db:generate";
const DATABASE_PARITY_COMMAND = "pnpm run verify:migrations-parity";
const DATABASE_BASELINE_EQUIVALENCE_COMMAND = "pnpm run verify:prisma-baseline-equivalence";
const DATABASE_TENANT_POLICY_COMMAND = "pnpm run verify:tenant-policy-contract";
const DATABASE_RLS_READINESS_COMMAND = "pnpm run verify:rls-release-readiness";
const DATABASE_RLS_LIVE_COMMAND = "pnpm run verify:rls-live";
const DATABASE_RLS_MIGRATION_CHAIN_PARITY_ENV = "HIVEGRID_RLS_REQUIRE_MIGRATION_CHAIN_PARITY";
const DATABASE_RLS_MIGRATION_CHAIN_PARITY_VALUE = '"1"';
const STAGING_SSH_HOST_VAR = "${{ vars.COOLIFY_STAGING_SSH_HOST }}";
const STAGING_SSH_USER_VAR = "${{ vars.COOLIFY_STAGING_SSH_USER }}";
const STAGING_WEB_RESOURCE_UUID_VAR = "${{ vars.COOLIFY_STAGING_WEB_RESOURCE_UUID }}";
const STAGING_SSH_KEY_SECRET = "${{ secrets.COOLIFY_STAGING_SSH_KEY }}";
const FORBIDDEN_DATABASE_MUTATION_PATTERN = /\b(?:prisma\s+migrate\s+deploy|migrate:deploy|db:deploy|db:push|prisma\s+db\s+push|seed)\b/i;
const DOCKER_SMOKE_JOB = "docker-smoke";
const DOCKER_SMOKE_SUITE_PATH = "scripts/ci/docker-smoke-suite.sh";
const DOCKER_SMOKE_TIMEOUT_RUNNER_PATH = "scripts/lib/run-command-with-timeout.mjs";
// Empty: docker-smoke intentionally has no needs so it runs in parallel with the quality
// phase (it builds images from source, no cross-job artifact dependency). See ci.yml.
const DOCKER_SMOKE_NEEDS = [];
const DOCKER_SMOKE_TARGETS = ["web", "api", "worker"];
const DOCKER_SMOKE_ROOT_TARGETS = ["web", "api", "mcp", "worker", "portal-domain-controller"];
const DOCKER_SMOKE_TARGETS = [...DOCKER_SMOKE_ROOT_TARGETS, "hocuspocus"];
const DOCKER_WEB_TAG = dockerImageTag("web");
const DOCKER_API_TAG = dockerImageTag("api");
const DOCKER_WORKER_TAG = dockerImageTag("worker");
const DOCKER_WEB_ARTIFACT_COMMAND = `docker run --rm --entrypoint /bin/sh ${DOCKER_WEB_TAG} -lc 'test -f /myapp/apps/web/build/server/index.js && test -d /myapp/apps/web/build/client && test -f /myapp/build/server-runtime/server.js'`;
const DOCKER_MCP_TAG = dockerImageTag("mcp");
const DOCKER_HOCUSPOCUS_TAG = dockerImageTag("hocuspocus");
const DOCKER_WEB_ARTIFACT_COMMAND = `docker run --rm --entrypoint /bin/sh ${DOCKER_WEB_TAG} -lc 'test -f /myapp/apps/web/build/server/index.js && test -d /myapp/apps/web/build/client && test -f /myapp/apps/web/build-portal/server/index.js && test -d /myapp/apps/web/build-portal/client && test -f /myapp/build/server-runtime/server.js'`;
const DOCKER_WEB_RUNTIME_COMMAND = `bash scripts/docker-web-runtime-smoke.sh ${DOCKER_WEB_TAG}`;
const DOCKER_API_RUNTIME_COMMAND = `bash scripts/docker-api-runtime-smoke.sh ${DOCKER_API_TAG}`;
const DOCKER_WORKER_RUNTIME_COMMAND = `bash scripts/docker-worker-runtime-smoke.sh ${DOCKER_WORKER_TAG}`;
const DOCKER_SMOKE_REVISION_ARG_PATTERN = /(?:^|\s)--build-arg(?:=|\s+)APP_REVISION=ci-smoke-revision(?:\s|$)/;
const DOCKER_MCP_RUNTIME_COMMAND = `bash scripts/docker-mcp-runtime-smoke.sh ${DOCKER_MCP_TAG}`;
const DOCKER_HOCUSPOCUS_RUNTIME_COMMAND = `bash scripts/docker-hocuspocus-runtime-smoke.sh ${DOCKER_HOCUSPOCUS_TAG}`;
const DOCKER_SMOKE_REVISION_ARG_PATTERN = /(?:^|\s)--build-arg(?:=|\s+)APP_REVISION=0123456789abcdef0123456789abcdef01234567(?:\s|$)/;
const DOCKER_SMOKE_HOCUSPOCUS_ARG_PATTERN = /(?:^|\s)--build-arg(?:=|\s+)VITE_HOCUSPOCUS_URL=wss:\/\/collab\.invalid(?:\s|$)/;
const DOCKER_SMOKE_FAKE_REVISION = "0123456789abcdef0123456789abcdef01234567";
const REQUIRED_RUNNER = CI_RUNNER_LABEL;
const FORBIDDEN_E2E_PATTERN = /\b(playwright|cypress|browser|test:e2e|e2e)\b/i;
const FORBIDDEN_DOCKER_PUBLISH_PATTERN = /\b(?:docker\s+(?:login|push)|docker\s+buildx\s+build[^\n]*--push|docker\s+build[^\n]*--push|publish)\b/i;
@@ -192,7 +218,7 @@ function getJobSection(content, jobName) {
}
function hasCheckoutStep(section) {
return /uses:\s*actions\/checkout@v\d+/.test(section);
return /uses:\s*actions\/checkout@(?:v\d+|[0-9a-f]{40})/.test(section);
}
function hasCorepackSetup(section) {
@@ -211,11 +237,15 @@ function hasPnpmStoreSetup(section) {
return /pnpm\s+config\s+set\s+store-dir\b/.test(section) || /path:\s*\.pnpm-store\b/.test(section);
}
function countOccurrences(source, token) {
return source.split(token).length - 1;
}
function checkWorkflowConcurrency(content) {
const concurrencyBlock = content.match(/^concurrency:\s*\n((?:^[ \t].*(?:\n|$))*)/mu)?.[1] ?? "";
if (
/^concurrency:\s*$/m.test(content) &&
/^\s+group:\s*\$\{\{\s*github\.workflow\s*\}\}-\$\{\{\s*github\.event\.pull_request\.number\s*\|\|\s*github\.ref\s*\}\}\s*$/m.test(content) &&
/^\s+cancel-in-progress:\s*true\s*$/m.test(content)
/^\s*group:\s*\$\{\{\s*github\.workflow\s*\}\}-\$\{\{\s*github\.event\.pull_request\.number\s*\|\|\s*github\.ref\s*\}\}\s*$/m.test(concurrencyBlock) &&
/^\s*cancel-in-progress:\s*true\s*$/m.test(concurrencyBlock)
) {
return { passes: [`${WORKFLOW_PATH}: CI concurrency cancels superseded pull request and branch runs`], failures: [], observations: [] };
}
@@ -255,8 +285,8 @@ function getNeedsValues(section) {
return [];
}
function hasDockerBuildxSetup(section) {
return /uses:\s*docker\/setup-buildx-action@v\d+/.test(section);
function hasDockerBuildxSetupAction(section) {
return /uses:\s*docker\/setup-buildx-action@(?:v\d+|[0-9a-f]{40})/.test(section);
}
function getRunCommands(section) {
@@ -306,7 +336,7 @@ function getExecutableRunCommandEntries(section) {
command
.split(/\r?\n/)
.map((line, offset) => ({ lineNumber: lineNumber + offset, command: stripExecutableShellLine(line) }))
.filter(({ command }) => command.length > 0 && !command.startsWith("#")),
.filter(({ command }) => command.length > 0 && !command.startsWith("#"))
);
}
@@ -317,7 +347,7 @@ function getExecutableRunCommandBlocks(section) {
.split(/\r?\n/)
.map((line) => stripExecutableShellLine(line))
.filter((line) => line.length > 0 && !line.startsWith("#"))
.join("\n"),
.join("\n")
)
.filter(Boolean);
}
@@ -405,18 +435,18 @@ function getStepForRunCommand(section, predicate) {
function hasUploadSourcemapsArtifactStep(section) {
return getAllStepBlocks(section).some(
(step) =>
/uses:\s*actions\/upload-artifact@v[34]/i.test(step) &&
/uses:\s*actions\/upload-artifact@(?:v[34]|[0-9a-f]{40})/i.test(step) &&
new RegExp(`^\\s*name:\\s*${escapeRegExp(WEB_SOURCEMAPS_ARTIFACT_NAME)}\\s*$`, "m").test(step) &&
new RegExp(`^\\s*path:\\s*${escapeRegExp(WEB_SOURCEMAPS_PATH)}\\s*$`, "m").test(step) &&
/^\s*if-no-files-found:\s*error\s*$/m.test(step) &&
/^\s*retention-days:\s*7\s*$/m.test(step),
/^\s*retention-days:\s*7\s*$/m.test(step)
);
}
function hasReusableSourcemapsArtifactContract(content) {
return (
/^\s+sourcemaps-artifact:\s*$/m.test(content) &&
/uses:\s*actions\/download-artifact@v[34]/i.test(content) &&
/uses:\s*actions\/download-artifact@(?:v[34]|[0-9a-f]{40})/i.test(content) &&
/^\s*if:\s*\$\{\{\s*inputs\.sourcemaps-artifact\s*!=\s*'none'\s*\}\}\s*$/m.test(content) &&
/^\s*name:\s*\$\{\{\s*inputs\.sourcemaps-artifact\s*\}\}\s*$/m.test(content) &&
/^\s*path:\s*\$\{\{\s*inputs\.sourcemaps-path\s*\}\}\s*$/m.test(content)
@@ -433,13 +463,13 @@ function countExecutableCommandOccurrences(section, expectedCommand) {
function hasDockerTargetBuild(section, target) {
return getExecutableRunCommandEntries(section).some(
({ command }) => /\bdocker\s+(?:buildx\s+build|build)\b/.test(command) && new RegExp(`(?:^|\\s)--target(?:=|\\s+)${target}(?:\\s|$)`).test(command),
({ command }) => /\bdocker\s+(?:buildx\s+build|build)\b/.test(command) && new RegExp(`(?:^|\\s)--target(?:=|\\s+)${target}(?:\\s|$)`).test(command)
);
}
function getDockerTargetBuild(section, target) {
return getExecutableRunCommandEntries(section).find(
({ command }) => /\bdocker\s+(?:buildx\s+build|build)\b/.test(command) && new RegExp(`(?:^|\\s)--target(?:=|\\s+)${target}(?:\\s|$)`).test(command),
({ command }) => /\bdocker\s+(?:buildx\s+build|build)\b/.test(command) && new RegExp(`(?:^|\\s)--target(?:=|\\s+)${target}(?:\\s|$)`).test(command)
)?.command;
}
@@ -463,15 +493,67 @@ function hasWorkerDockerRuntimeValidation(section) {
return getExecutableRunCommandEntries(section).some(({ command }) => command === DOCKER_WORKER_RUNTIME_COMMAND);
}
function hasParallelDockerTargetBuilds(section) {
return getRunCommands(section).some(({ command }) => {
const hasEveryTarget = DOCKER_SMOKE_TARGETS.every((target) =>
new RegExp(`\\bdocker\\s+(?:buildx\\s+build|build)\\b[^\\n]*--target(?:=|\\s+)${target}(?:\\s|$)[^\\n]*&`, "u").test(command),
);
const capturesEveryPid = DOCKER_SMOKE_TARGETS.every((target) => new RegExp(`\\b${target}_pid=\\$!`, "u").test(command));
const waitsForEveryPid = DOCKER_SMOKE_TARGETS.every((target) => new RegExp(`\\bwait\\s+"\\$${target}_pid"`, "u").test(command));
function hasMcpDockerRuntimeValidation(section) {
return getExecutableRunCommandEntries(section).some(({ command }) => command === DOCKER_MCP_RUNTIME_COMMAND);
}
return hasEveryTarget && capturesEveryPid && waitsForEveryPid;
function hasHocuspocusDockerRuntimeValidation(section) {
return getExecutableRunCommandEntries(section).some(({ command }) => command === DOCKER_HOCUSPOCUS_RUNTIME_COMMAND);
}
function hasSerializedRootDockerTargetBuildsWithParallelHocuspocus(section) {
return getRunCommands(section).some(({ command }) => {
const lines = command
.split(/\r?\n/u)
.map((line) => stripExecutableShellLine(line))
.filter(Boolean);
const rootBuildIndexes = DOCKER_SMOKE_ROOT_TARGETS.map((target) =>
lines.findIndex(
(line) =>
/\bdocker\s+(?:buildx\s+build|build)\b/u.test(line) &&
new RegExp(`(?:^|\\s)--target(?:=|\\s+)${escapeRegExp(target)}(?:\\s|$)`, "u").test(line)
)
);
if (rootBuildIndexes.some((index) => index === -1)) return false;
if (rootBuildIndexes.some((index, position) => position > 0 && index <= rootBuildIndexes[position - 1])) return false;
const firstRootBuild = rootBuildIndexes[0];
const lastRootBuild = rootBuildIndexes.at(-1);
const rootGroupOpen = lines.lastIndexOf("(", firstRootBuild);
const rootGroupClose = lines.indexOf(") &", lastRootBuild + 1);
const rootBuildsAreSerialized = rootBuildIndexes.every((index) => !/&\s*$/u.test(lines[index]));
const rootGroupIsFailFast = lines.slice(rootGroupOpen + 1, firstRootBuild).includes("set -euo pipefail");
const hocuspocusBuildIndex = lines.findIndex(
(line) =>
/\bdocker\s+(?:buildx\s+build|build)\b/u.test(line) &&
/(?:^|\s)--target(?:=|\s+)hocuspocus(?:\s|$)/u.test(line) &&
/&\s*$/u.test(line)
);
const rootPidCaptureIndex = lines.indexOf("root_targets_pid=$!");
const hocuspocusPidCaptureIndex = lines.indexOf("hocuspocus_pid=$!");
const statusInitializationIndex = lines.indexOf("status=0");
const rootWaitIndex = lines.indexOf('wait "$root_targets_pid" || status=$?');
const hocuspocusWaitIndex = lines.indexOf('wait "$hocuspocus_pid" || status=$?');
const failureExitIndex = lines.indexOf('exit "$status"');
const capturesAndWaitsInOrder =
rootPidCaptureIndex === rootGroupClose + 1 &&
hocuspocusBuildIndex === rootPidCaptureIndex + 1 &&
hocuspocusPidCaptureIndex === hocuspocusBuildIndex + 1 &&
statusInitializationIndex === hocuspocusPidCaptureIndex + 1 &&
rootWaitIndex === statusInitializationIndex + 1 &&
hocuspocusWaitIndex === rootWaitIndex + 1 &&
failureExitIndex === hocuspocusWaitIndex + 1 &&
failureExitIndex === lines.length - 1;
return (
rootGroupOpen !== -1 &&
rootGroupClose > lastRootBuild &&
rootBuildsAreSerialized &&
rootGroupIsFailFast &&
hocuspocusBuildIndex > rootGroupClose &&
capturesAndWaitsInOrder
);
});
}
@@ -479,14 +561,23 @@ function includesCommand(section, command) {
return getExecutableRunCommandEntries(section).some(({ command: executableCommand }) => matchesExecutableCommand(executableCommand, command));
}
function getRequiredStepSofteningReason(step) {
function getRequiredStepSofteningReason(step, { allowedIf = [] } = {}) {
if (!step) {
return "";
}
if (/^\s*continue-on-error:\s*true\s*$/im.test(step) || /^\s*if:\s*(?:always\(\)|\$\{\{\s*always\(\)\s*\}\})\s*$/im.test(step)) {
if (/^\s*continue-on-error:\s*true\s*$/im.test(step)) {
return "continue-on-error or always()";
}
const ifValue = step
.match(/^\s*if:\s*([^\n]+)\s*$/im)?.[1]
?.trim()
.replace(/^\$\{\{\s*/, "")
.replace(/\s*\}\}$/, "")
.trim();
if (ifValue && !allowedIf.includes(ifValue)) {
return "conditional execution";
}
const lines = getExecutableShellLines(getRunTextFromStep(step));
const block = lines.join("\n");
@@ -509,7 +600,8 @@ function getRequiredStepSofteningReason(step) {
function getRequiredCommandSofteningReason(section, command) {
const step = getStepForRunCommand(section, (line) => line.includes(command));
return getRequiredStepSofteningReason(step);
const allowedIf = command === DATABASE_STATUS_COMMAND ? ["gitea.event_name != 'pull_request'"] : [];
return getRequiredStepSofteningReason(step, { allowedIf });
}
function getRunCommandLines(section) {
@@ -684,6 +776,91 @@ export function checkOrderedQualityGates(content) {
return { passes, failures, observations: [] };
}
export function checkQualityGroupRunner(rootDir) {
const passes = [];
const failures = [];
const source = readOptionalFile(rootDir, QUALITY_GROUP_RUNNER_PATH);
if (!source) {
return { passes, failures: [`${QUALITY_GROUP_RUNNER_PATH}: missing parallel quality group runner`], observations: [] };
}
const prismaPrepareIndex = source.indexOf("pnpm run db:generate");
const firstGroupStartIndex = source.indexOf('start_group "typecheck-lint" run_typecheck_lint');
if (prismaPrepareIndex >= 0 && firstGroupStartIndex > prismaPrepareIndex) {
passes.push(`${QUALITY_GROUP_RUNNER_PATH}: Prisma client generation completes before parallel test readers start`);
} else {
failures.push(`${QUALITY_GROUP_RUNNER_PATH}: must generate the Prisma client before starting parallel quality groups`);
}
const typecheckLintSource = source.match(/run_typecheck_lint\(\)\s*\{([\s\S]*?)^\}/m)?.[1] ?? "";
const typecheckLintCommands = [
"pnpm --filter @hivegrid/portal-domain-controller typecheck",
"pnpm --filter @hivegrid/web typegen",
"node ../../scripts/typecheck-web.mjs",
"pnpm lint",
];
const typecheckLintIndexes = typecheckLintCommands.map((command) => typecheckLintSource.indexOf(command));
if (typecheckLintIndexes.every((index) => index >= 0) && typecheckLintIndexes.every((index, position) => position === 0 || index > typecheckLintIndexes[position - 1])) {
passes.push(`${QUALITY_GROUP_RUNNER_PATH}: typecheck-lint group preserves controller typecheck, generated web typecheck, then lint order`);
} else {
failures.push(`${QUALITY_GROUP_RUNNER_PATH}: typecheck-lint group must run controller typecheck, web typegen/typecheck, and lint in order`);
}
const foundationPackagesSource = source.match(/run_foundation_packages\(\)\s*\{([\s\S]*?)^\}/m)?.[1] ?? "";
const foundationCommand = "pnpm run test:foundation --maxWorkers=2";
const packageCommand = "PNPM_CONFIG_WORKSPACE_CONCURRENCY=2 pnpm run test:packages --maxWorkers=1";
if (
foundationPackagesSource.indexOf(foundationCommand) >= 0 &&
foundationPackagesSource.indexOf(packageCommand) > foundationPackagesSource.indexOf(foundationCommand)
) {
passes.push(`${QUALITY_GROUP_RUNNER_PATH}: foundation/package tests preserve order with bounded Vitest and workspace concurrency`);
} else {
failures.push(`${QUALITY_GROUP_RUNNER_PATH}: foundation/package tests must keep the exact bounded worker and workspace-concurrency commands`);
}
const coreTestsSource = source.match(/run_core_tests\(\)\s*\{([\s\S]*?)^\}/m)?.[1] ?? "";
if (/^\s*pnpm run test --maxWorkers=4\s*$/m.test(coreTestsSource)) {
passes.push(`${QUALITY_GROUP_RUNNER_PATH}: core-tests group runs the canonical suite with four workers`);
} else {
failures.push(`${QUALITY_GROUP_RUNNER_PATH}: core-tests group must run pnpm run test --maxWorkers=4`);
}
const requiredStarts = [
'start_group "typecheck-lint" run_typecheck_lint',
'start_group "foundation-packages" run_foundation_packages',
'start_group "core-tests" run_core_tests',
];
const hasExactlyThreeStarts = (source.match(/^start_group\s+/gm) ?? []).length === 3 && requiredStarts.every((line) => source.includes(line));
const startsInBackground = /start_group\(\)[\s\S]*?\)\s*&[\s\S]*?QUALITY_GROUP_NAMES\+=\("\$name"\)[\s\S]*?QUALITY_GROUP_PIDS\+=\("\$!"\)/.test(source);
if (hasExactlyThreeStarts && startsInBackground) {
passes.push(`${QUALITY_GROUP_RUNNER_PATH}: exactly three named quality groups start concurrently with captured PIDs`);
} else {
failures.push(`${QUALITY_GROUP_RUNNER_PATH}: must start exactly three named background groups and capture every PID`);
}
const aggregatesEveryResult =
/for index in "\$\{!QUALITY_GROUP_PIDS\[@\]\}"; do/.test(source) &&
/if wait "\$pid"; then/.test(source) &&
/QUALITY_FAILED=1/.test(source) &&
/exit "\$QUALITY_FAILED"/.test(source) &&
/\[quality-groups\] PASS \$name/.test(source) &&
/\[quality-groups\] FAIL \$name \(exit \$status\)/.test(source);
if (aggregatesEveryResult) {
passes.push(`${QUALITY_GROUP_RUNNER_PATH}: every named PID is waited and any group failure propagates after full aggregation`);
} else {
failures.push(`${QUALITY_GROUP_RUNNER_PATH}: must wait every named PID, report its status, and propagate aggregate failure`);
}
if (/^set -euo pipefail$/m.test(source) && /trap terminate_groups HUP INT TERM/.test(source)) {
passes.push(`${QUALITY_GROUP_RUNNER_PATH}: strict shell mode and bounded child termination remain enabled`);
} else {
failures.push(`${QUALITY_GROUP_RUNNER_PATH}: must use strict shell mode and terminate child groups on interruption`);
}
return { passes, failures, observations: [] };
}
export function checkSentrySourcemapWorkflow(rootDir) {
const passes = [];
const failures = [];
@@ -843,6 +1020,44 @@ export function checkDatabaseJob(content) {
}
}
for (const command of [
DATABASE_TENANT_POLICY_COMMAND,
DATABASE_RLS_READINESS_COMMAND,
DATABASE_BASELINE_EQUIVALENCE_COMMAND,
DATABASE_RLS_LIVE_COMMAND,
]) {
if (includesCommand(section, command)) {
const softeningReason = getRequiredCommandSofteningReason(section, command);
if (softeningReason) {
failures.push(`${WORKFLOW_PATH}: database job "${DATABASE_JOB}" command "${command}" must not use ${softeningReason}`);
} else {
passes.push(`${WORKFLOW_PATH}: database job "${DATABASE_JOB}" includes command "${command}"`);
}
} else {
const softeningReason = getRequiredCommandSofteningReason(section, command);
if (softeningReason) {
failures.push(`${WORKFLOW_PATH}: database job "${DATABASE_JOB}" command "${command}" must not use ${softeningReason}`);
} else {
failures.push(`${WORKFLOW_PATH}: database job "${DATABASE_JOB}" missing command "${command}"`);
}
}
}
if (
hasStepLevelEnvValue(
section,
DATABASE_RLS_LIVE_COMMAND,
DATABASE_RLS_MIGRATION_CHAIN_PARITY_ENV,
DATABASE_RLS_MIGRATION_CHAIN_PARITY_VALUE,
)
) {
passes.push(`${WORKFLOW_PATH}: live RLS gate requires strict migration-chain parity`);
} else {
failures.push(
`${WORKFLOW_PATH}: live RLS gate must set ${DATABASE_RLS_MIGRATION_CHAIN_PARITY_ENV}: ${DATABASE_RLS_MIGRATION_CHAIN_PARITY_VALUE}`,
);
}
if (includesCommand(section, DATABASE_STATUS_COMMAND)) {
const softeningReason = getRequiredCommandSofteningReason(section, DATABASE_STATUS_COMMAND);
if (softeningReason) {
@@ -862,25 +1077,33 @@ export function checkDatabaseJob(content) {
if (hasStepLevelEnvValue(section, DATABASE_STATUS_COMMAND, "COOLIFY_STAGING_SSH_HOST", STAGING_SSH_HOST_VAR)) {
passes.push(`${WORKFLOW_PATH}: database job "${DATABASE_JOB}" scopes staging SSH host to the migrate-status step`);
} else {
failures.push(`${WORKFLOW_PATH}: database job "${DATABASE_JOB}" must set COOLIFY_STAGING_SSH_HOST: \${{ vars.COOLIFY_STAGING_SSH_HOST }} on the migrate-status step`);
failures.push(
`${WORKFLOW_PATH}: database job "${DATABASE_JOB}" must set COOLIFY_STAGING_SSH_HOST: \${{ vars.COOLIFY_STAGING_SSH_HOST }} on the migrate-status step`
);
}
if (hasStepLevelEnvValue(section, DATABASE_STATUS_COMMAND, "COOLIFY_STAGING_SSH_USER", STAGING_SSH_USER_VAR)) {
passes.push(`${WORKFLOW_PATH}: database job "${DATABASE_JOB}" scopes staging SSH user to the migrate-status step`);
} else {
failures.push(`${WORKFLOW_PATH}: database job "${DATABASE_JOB}" must set COOLIFY_STAGING_SSH_USER: \${{ vars.COOLIFY_STAGING_SSH_USER }} on the migrate-status step`);
failures.push(
`${WORKFLOW_PATH}: database job "${DATABASE_JOB}" must set COOLIFY_STAGING_SSH_USER: \${{ vars.COOLIFY_STAGING_SSH_USER }} on the migrate-status step`
);
}
if (hasStepLevelEnvValue(section, DATABASE_STATUS_COMMAND, "COOLIFY_STAGING_WEB_RESOURCE_UUID", STAGING_WEB_RESOURCE_UUID_VAR)) {
passes.push(`${WORKFLOW_PATH}: database job "${DATABASE_JOB}" scopes staging web resource UUID to the migrate-status step`);
} else {
failures.push(`${WORKFLOW_PATH}: database job "${DATABASE_JOB}" must set COOLIFY_STAGING_WEB_RESOURCE_UUID: \${{ vars.COOLIFY_STAGING_WEB_RESOURCE_UUID }} on the migrate-status step`);
failures.push(
`${WORKFLOW_PATH}: database job "${DATABASE_JOB}" must set COOLIFY_STAGING_WEB_RESOURCE_UUID: \${{ vars.COOLIFY_STAGING_WEB_RESOURCE_UUID }} on the migrate-status step`
);
}
if (hasStepLevelEnvValue(section, DATABASE_STATUS_COMMAND, "COOLIFY_STAGING_SSH_KEY", STAGING_SSH_KEY_SECRET)) {
passes.push(`${WORKFLOW_PATH}: database job "${DATABASE_JOB}" scopes staging SSH key to the migrate-status step`);
} else {
failures.push(`${WORKFLOW_PATH}: database job "${DATABASE_JOB}" must set COOLIFY_STAGING_SSH_KEY: \${{ secrets.COOLIFY_STAGING_SSH_KEY }} on the migrate-status step`);
failures.push(
`${WORKFLOW_PATH}: database job "${DATABASE_JOB}" must set COOLIFY_STAGING_SSH_KEY: \${{ secrets.COOLIFY_STAGING_SSH_KEY }} on the migrate-status step`
);
}
if (section.includes("secrets.DATABASE_URL")) {
@@ -912,7 +1135,196 @@ export function checkDatabaseJob(content) {
return { passes, failures, observations: [] };
}
export function checkDockerSmokeJob(content) {
function checkIsolatedDockerSmokeSuite(section, suiteSource) {
const passes = [];
const failures = [];
if (!/^ concurrency:\s*$/m.test(section)) {
passes.push(`${WORKFLOW_PATH}: run-scoped Docker smokes may execute concurrently across refs`);
} else {
failures.push(`${WORKFLOW_PATH}: Docker smoke must not use job-level concurrency after cache and runtime resources are isolated`);
}
if (/^ DOCKER_SMOKE_RUN_ID:\s*\$\{\{\s*gitea\.run_id\s*\}\}-\$\{\{\s*gitea\.run_attempt\s*\}\}\s*$/m.test(section)) {
passes.push(`${WORKFLOW_PATH}: Docker smoke resources are scoped by Gitea run and attempt`);
} else {
failures.push(`${WORKFLOW_PATH}: Docker smoke must set DOCKER_SMOKE_RUN_ID from gitea.run_id and gitea.run_attempt`);
}
if (/^ DOCKER_SMOKE_REVISION:\s*\$\{\{\s*gitea\.sha\s*\}\}\s*$/m.test(section)) {
passes.push(`${WORKFLOW_PATH}: Docker smoke uses the triggering Git SHA as image revision`);
} else {
failures.push(`${WORKFLOW_PATH}: Docker smoke must set DOCKER_SMOKE_REVISION from gitea.sha`);
}
if (/^ DOCKER_SMOKE_SUITE_TIMEOUT_SECONDS:\s*["']?2520["']?\s*$/m.test(section)) {
passes.push(`${WORKFLOW_PATH}: Docker smoke has an authoritative 42-minute suite hard cap`);
} else {
failures.push(`${WORKFLOW_PATH}: Docker smoke must set the suite hard cap to 2520 seconds`);
}
const suiteStep = getStepForRunCommand(section, (line) => line.includes(`${DOCKER_SMOKE_SUITE_PATH} all`));
const suiteStepText = getRunTextFromStep(suiteStep);
const suiteSofteningReason = getRequiredStepSofteningReason(suiteStep);
if (suiteSofteningReason) {
failures.push(`${WORKFLOW_PATH}: Docker smoke suite must not use ${suiteSofteningReason}`);
} else if (
suiteStepText.includes(`node ${DOCKER_SMOKE_TIMEOUT_RUNNER_PATH}`) &&
suiteStepText.includes("--stage docker-smoke:suite") &&
suiteStepText.includes('--timeout-seconds "$DOCKER_SMOKE_SUITE_TIMEOUT_SECONDS"') &&
suiteStepText.includes("--grace-seconds 45") &&
suiteStepText.includes(`-- bash ${DOCKER_SMOKE_SUITE_PATH} all`)
) {
passes.push(`${WORKFLOW_PATH}: Docker smoke suite is guarded by the portable process-group hard timeout`);
} else {
failures.push(`${WORKFLOW_PATH}: Docker smoke must invoke the isolated suite through ${DOCKER_SMOKE_TIMEOUT_RUNNER_PATH}`);
}
if (suiteSource.includes(DOCKER_SMOKE_FAKE_REVISION)) {
failures.push(`${DOCKER_SMOKE_SUITE_PATH}: fixed fake image revisions are forbidden`);
} else if (suiteSource.includes('--build-arg "APP_REVISION=${DOCKER_SMOKE_REVISION}"')) {
passes.push(`${DOCKER_SMOKE_SUITE_PATH}: every Docker build receives the concrete workflow revision`);
} else {
failures.push(`${DOCKER_SMOKE_SUITE_PATH}: Docker builds must pass DOCKER_SMOKE_REVISION as APP_REVISION`);
}
if (suiteSource.includes('docker compose --env-file .env.test config --quiet')) {
passes.push(`${DOCKER_SMOKE_SUITE_PATH}: Compose validation uses a non-secret fixture without rendering resolved values`);
} else {
failures.push(`${DOCKER_SMOKE_SUITE_PATH}: Compose validation must use .env.test and --quiet to prevent credential disclosure`);
}
const imageVariables = {
web: "WEB_IMAGE",
worker: "WORKER_IMAGE",
api: "API_IMAGE",
mcp: "MCP_IMAGE",
hocuspocus: "HOCUSPOCUS_IMAGE",
"portal-domain-controller": "PORTAL_CONTROLLER_IMAGE",
};
for (const [target, variable] of Object.entries(imageVariables)) {
const expected = `${variable}="hivegrid-${target}:smoke-\${DOCKER_SMOKE_RUN_ID}"`;
if (suiteSource.includes(expected)) {
passes.push(`${DOCKER_SMOKE_SUITE_PATH}: ${target} image tag is run-specific`);
} else {
failures.push(`${DOCKER_SMOKE_SUITE_PATH}: ${target} image tag must include DOCKER_SMOKE_RUN_ID`);
}
}
if (/hivegrid-(?:web|worker|api|mcp|hocuspocus|portal-domain-controller):smoke(?:["'\s]|$)/u.test(suiteSource)) {
failures.push(`${DOCKER_SMOKE_SUITE_PATH}: global :smoke image tags are forbidden`);
} else {
passes.push(`${DOCKER_SMOKE_SUITE_PATH}: no global Docker smoke image tags remain`);
}
if (
suiteSource.includes('WEB_ARTIFACT_CONTAINER_NAME="hivegrid-web-artifact-smoke-${DOCKER_SMOKE_RUN_ID}"') &&
suiteSource.includes('docker run --rm --name "$WEB_ARTIFACT_CONTAINER_NAME"') &&
suiteSource.includes('docker_smoke_cleanup_container "suite:cleanup:web-artifact" "$WEB_ARTIFACT_CONTAINER_NAME"') &&
suiteSource.includes("docker_smoke_install_cleanup_traps cleanup")
) {
passes.push(`${DOCKER_SMOKE_SUITE_PATH}: artifact one-shot is run-scoped and cleanup-addressable`);
} else {
failures.push(`${DOCKER_SMOKE_SUITE_PATH}: web artifact validation must use a run-scoped named container and bounded cleanup trap`);
}
if (suiteSource.includes('export DOCKER_SMOKE_MIGRATOR_IMAGE="$WEB_IMAGE"')) {
passes.push(`${DOCKER_SMOKE_SUITE_PATH}: service smokes use the run-specific web migrator image`);
} else {
failures.push(`${DOCKER_SMOKE_SUITE_PATH}: service smokes must receive the run-specific web migrator image`);
}
const allBlock = suiteSource.match(/\n all\)\n([\s\S]*?)\n ;;/u)?.[1] ?? "";
const buildWave = "run_parallel_wave builds \\\n build_web build_worker build_api build_mcp build_hocuspocus build_portal_controller";
const runtimeWave =
"run_parallel_wave runtimes \\\n validate_web validate_worker validate_api validate_mcp validate_hocuspocus validate_portal_controller";
const buildWaveIndex = allBlock.indexOf(buildWave);
const runtimeWaveIndex = allBlock.indexOf(runtimeWave);
if (buildWaveIndex >= 0 && runtimeWaveIndex > buildWaveIndex) {
passes.push(`${DOCKER_SMOKE_SUITE_PATH}: all images build in parallel before the isolated runtime wave`);
} else {
failures.push(`${DOCKER_SMOKE_SUITE_PATH}: all-target mode must complete the six-target build wave before the six-target runtime wave`);
}
const parallelHelper = suiteSource.match(/run_parallel_wave\(\) \{([\s\S]*?)\n\}/u)?.[1] ?? "";
if (
parallelHelper.includes('"$task" &') &&
parallelHelper.includes('pids+=("$!")') &&
parallelHelper.includes('for index in "${!pids[@]}"; do') &&
parallelHelper.includes('if wait "${pids[$index]}"; then') &&
parallelHelper.includes('return "$status"')
) {
passes.push(`${DOCKER_SMOKE_SUITE_PATH}: parallel waves collect every child result and propagate failures`);
} else {
failures.push(`${DOCKER_SMOKE_SUITE_PATH}: parallel waves must track, await, and propagate every child result`);
}
for (const target of ["worker", "api", "mcp", "hocuspocus"]) {
const branch = suiteSource.match(new RegExp(`\\n ${target}\\)\\n([\\s\\S]*?)\\n ;;`, "u"))?.[1] ?? "";
if (branch.includes("ensure_web_migrator_image") && branch.includes(`build_and_validate_${target}`)) {
passes.push(`${DOCKER_SMOKE_SUITE_PATH}: ${target} has an exact single-target retry path`);
} else {
failures.push(`${DOCKER_SMOKE_SUITE_PATH}: ${target} must support a single-target retry with the matching migrator image`);
}
}
const requiredStages = [
'docker_smoke_run "compose:config"',
'docker_smoke_run "build:${target}"',
'docker_smoke_run "build:hocuspocus"',
'docker_smoke_run "artifacts:web"',
'docker_smoke_run_with_grace "runtime:web"',
'docker_smoke_run_with_grace "runtime:worker"',
'docker_smoke_run_with_grace "runtime:api"',
'docker_smoke_run_with_grace "runtime:mcp"',
'docker_smoke_run_with_grace "runtime:hocuspocus"',
'docker_smoke_run_with_grace "runtime:portal-domain-controller"',
];
const missingStages = requiredStages.filter((stage) => !suiteSource.includes(stage));
if (missingStages.length === 0) {
passes.push(`${DOCKER_SMOKE_SUITE_PATH}: every build and runtime phase has a command-level timeout`);
} else {
failures.push(`${DOCKER_SMOKE_SUITE_PATH}: missing timeout stages: ${missingStages.join(", ")}`);
}
const runtimeGraceCount = countOccurrences(suiteSource, '"$DOCKER_SMOKE_RUNTIME_GRACE_SECONDS"');
if (/DOCKER_SMOKE_RUNTIME_GRACE_SECONDS="\$\{DOCKER_SMOKE_RUNTIME_GRACE_SECONDS:-30\}"/u.test(suiteSource) && runtimeGraceCount === 6) {
passes.push(`${DOCKER_SMOKE_SUITE_PATH}: runtime termination reserves a bounded cleanup grace window`);
} else {
failures.push(`${DOCKER_SMOKE_SUITE_PATH}: every runtime wrapper must reserve the 30-second cleanup grace window`);
}
const requiredRuntimeScripts = [
"docker-web-runtime-smoke.sh",
"docker-worker-runtime-smoke.sh",
"docker-api-runtime-smoke.sh",
"docker-mcp-runtime-smoke.sh",
"docker-hocuspocus-runtime-smoke.sh",
"docker-portal-domain-controller-runtime-smoke.sh",
];
const missingRuntimeScripts = requiredRuntimeScripts.filter((name) => !suiteSource.includes(name));
if (missingRuntimeScripts.length === 0) {
passes.push(`${DOCKER_SMOKE_SUITE_PATH}: all Docker runtime surfaces remain covered`);
} else {
failures.push(`${DOCKER_SMOKE_SUITE_PATH}: missing runtime smokes: ${missingRuntimeScripts.join(", ")}`);
}
if (suiteSource.indexOf('docker_smoke_run "compose:config"') < suiteSource.lastIndexOf('case "$TARGET" in')) {
passes.push(`${DOCKER_SMOKE_SUITE_PATH}: Compose config fails before any image build`);
} else {
failures.push(`${DOCKER_SMOKE_SUITE_PATH}: Compose config must run before image builds`);
}
if (FORBIDDEN_DOCKER_PUBLISH_PATTERN.test(suiteSource)) {
failures.push(`${DOCKER_SMOKE_SUITE_PATH}: registry publishing is forbidden in Docker smoke`);
} else {
passes.push(`${DOCKER_SMOKE_SUITE_PATH}: no registry login/push/publish commands are present`);
}
return { passes, failures, observations: [] };
}
export function checkDockerSmokeJob(content, rootDir = process.cwd()) {
const passes = [];
const failures = [];
const section = getJobSection(content, DOCKER_SMOKE_JOB);
@@ -966,22 +1378,64 @@ export function checkDockerSmokeJob(content) {
passes.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" does not run "pnpm install --frozen-lockfile"`);
}
if (hasDockerBuildxSetup(section)) {
passes.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" sets up Docker Buildx`);
if (hasDockerBuildxSetupAction(section)) {
failures.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" must not use docker/setup-buildx-action`);
} else {
failures.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" missing Docker Buildx setup`);
passes.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" does not create an unused Buildx builder`);
}
if (/^ DOCKER_BUILDKIT:\s*["']?1["']?\s*$/m.test(section)) {
passes.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" enables BuildKit explicitly with DOCKER_BUILDKIT=1`);
} else {
failures.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" must set job-level DOCKER_BUILDKIT: "1"`);
}
if (/^ DOCKER_SMOKE_COMMAND_TIMEOUT_SECONDS:\s*["']?90["']?\s*$/m.test(section)) {
passes.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" allows loaded-runner commands up to 90 seconds`);
} else {
failures.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" must set job-level DOCKER_SMOKE_COMMAND_TIMEOUT_SECONDS: "90"`);
}
if (/^ DOCKER_SMOKE_ARTIFACT_TIMEOUT_SECONDS:\s*["']?180["']?\s*$/m.test(section)) {
passes.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" allows loaded-runner artifact checks up to 180 seconds`);
} else {
failures.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" must set job-level DOCKER_SMOKE_ARTIFACT_TIMEOUT_SECONDS: "180"`);
}
if (section.includes(DOCKER_SMOKE_SUITE_PATH)) {
const suiteSource = readOptionalFile(rootDir, DOCKER_SMOKE_SUITE_PATH);
if (suiteSource === null) {
failures.push(`${DOCKER_SMOKE_SUITE_PATH}: missing required isolated Docker smoke suite`);
return { passes, failures, observations: [] };
}
const isolated = checkIsolatedDockerSmokeSuite(section, suiteSource);
return {
passes: [...passes, ...isolated.passes],
failures: [...failures, ...isolated.failures],
observations: isolated.observations,
};
}
for (const target of DOCKER_SMOKE_TARGETS) {
if (hasDockerTargetBuild(section, target)) {
const targetBuild = getDockerTargetBuild(section, target) ?? "";
const targetBuildPattern = (line) => /\bdocker\s+(?:buildx\s+build|build)\b/.test(line) && new RegExp(`(?:^|\\s)--target(?:=|\\s+)${target}(?:\\s|$)`).test(line);
const targetBuildPattern = (line) =>
/\bdocker\s+(?:buildx\s+build|build)\b/.test(line) && new RegExp(`(?:^|\\s)--target(?:=|\\s+)${target}(?:\\s|$)`).test(line);
const softeningReason = getRequiredStepSofteningReason(getStepForRunCommand(section, targetBuildPattern));
if (softeningReason) {
failures.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" build for target "${target}" must not use ${softeningReason}`);
} else if (!DOCKER_SMOKE_REVISION_ARG_PATTERN.test(targetBuild)) {
failures.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" build for target "${target}" must pass --build-arg APP_REVISION=ci-smoke-revision`);
failures.push(
`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" build for target "${target}" must pass --build-arg APP_REVISION=0123456789abcdef0123456789abcdef01234567`
);
} else if (target === "web" && !DOCKER_SMOKE_HOCUSPOCUS_ARG_PATTERN.test(targetBuild)) {
failures.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" web build must exercise --build-arg VITE_HOCUSPOCUS_URL=wss://collab.invalid`);
} else if (target === "hocuspocus" && !/--file(?:=|\s+)apps\/hocuspocus\/Dockerfile(?:\s|$)/u.test(targetBuild)) {
failures.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" must build Hocuspocus from apps/hocuspocus/Dockerfile`);
} else {
if (target === "web") {
passes.push(`${WORKFLOW_PATH}: Docker smoke web build exercises the public Hocuspocus URL build arg`);
}
passes.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" builds Docker target "${target}"`);
}
} else {
@@ -989,10 +1443,12 @@ export function checkDockerSmokeJob(content) {
}
}
if (hasParallelDockerTargetBuilds(section)) {
passes.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" builds Docker targets in parallel`);
if (hasSerializedRootDockerTargetBuildsWithParallelHocuspocus(section)) {
passes.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" serializes root Docker targets while Hocuspocus builds in parallel`);
} else {
failures.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" must build web, api, and worker Docker targets in one parallel bash step`);
failures.push(
`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" must serialize root Docker targets and propagate failures while Hocuspocus builds in parallel`
);
}
if (hasDockerComposeConfig(section)) {
@@ -1075,6 +1531,38 @@ export function checkDockerSmokeJob(content) {
}
}
if (hasMcpDockerRuntimeValidation(section)) {
const softeningReason = getRequiredCommandSofteningReason(section, DOCKER_MCP_RUNTIME_COMMAND);
if (softeningReason) {
failures.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" command "${DOCKER_MCP_RUNTIME_COMMAND}" must not use ${softeningReason}`);
} else {
passes.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" validates MCP Docker runtime`);
}
} else {
const softeningReason = getRequiredCommandSofteningReason(section, DOCKER_MCP_RUNTIME_COMMAND);
if (softeningReason) {
failures.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" command "${DOCKER_MCP_RUNTIME_COMMAND}" must not use ${softeningReason}`);
} else {
failures.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" missing command "${DOCKER_MCP_RUNTIME_COMMAND}"`);
}
}
if (hasHocuspocusDockerRuntimeValidation(section)) {
const softeningReason = getRequiredCommandSofteningReason(section, DOCKER_HOCUSPOCUS_RUNTIME_COMMAND);
if (softeningReason) {
failures.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" command "${DOCKER_HOCUSPOCUS_RUNTIME_COMMAND}" must not use ${softeningReason}`);
} else {
passes.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" validates Hocuspocus Docker runtime`);
}
} else {
const softeningReason = getRequiredCommandSofteningReason(section, DOCKER_HOCUSPOCUS_RUNTIME_COMMAND);
if (softeningReason) {
failures.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" command "${DOCKER_HOCUSPOCUS_RUNTIME_COMMAND}" must not use ${softeningReason}`);
} else {
failures.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" missing command "${DOCKER_HOCUSPOCUS_RUNTIME_COMMAND}"`);
}
}
const forbiddenLine = getRunCommandLines(section).find((line) => FORBIDDEN_DOCKER_PUBLISH_PATTERN.test(line));
if (forbiddenLine) {
failures.push(`${WORKFLOW_PATH}: Docker smoke job "${DOCKER_SMOKE_JOB}" contains forbidden publish command: ${forbiddenLine.trim()}`);
@@ -1099,7 +1587,10 @@ export function checkWorkflowRunners(content) {
}
for (const { line, lineNumber } of runnerLines) {
const runner = line.replace(/^\s*runs-on:\s*/, "").trim().replace(/^['\"]|['\"]$/g, "");
const runner = line
.replace(/^\s*runs-on:\s*/, "")
.trim()
.replace(/^['\"]|['\"]$/g, "");
if (runner === REQUIRED_RUNNER) {
passes.push(`${WORKFLOW_PATH}:${lineNumber}: runner is "${REQUIRED_RUNNER}"`);
} else {
@@ -1163,9 +1654,10 @@ export function verifyGiteaCiWorkflow(rootDir = process.cwd()) {
checkPnpmSetup(content),
checkWorkflowRunners(content),
checkOrderedQualityGates(content),
checkQualityGroupRunner(rootDir),
checkServiceJobs(content),
checkDatabaseJob(content),
checkDockerSmokeJob(content),
checkDockerSmokeJob(content, rootDir),
checkSentrySourcemapWorkflow(rootDir),
checkForbiddenE2eCommands(content),
checkGiteaVariableNames(content),
@@ -1177,7 +1669,7 @@ export function verifyGiteaCiWorkflow(rootDir = process.cwd()) {
failures: [...result.failures, ...check.failures],
observations: [...result.observations, ...check.observations],
}),
{ passes: [], failures: [], observations: [] },
{ passes: [], failures: [], observations: [] }
);
}