forked from wangziqi/gongxue-base
chore: harden h5 launch evidence gate
This commit is contained in:
@@ -143,6 +143,17 @@ assert.ok(
|
||||
'missing import business sampling should be reported as a blocker',
|
||||
);
|
||||
|
||||
const missingTaroStaticSmoke = runGate(tempDir => {
|
||||
const evidence = createEvidence(tempDir);
|
||||
evidence.checks = evidence.checks.filter(item => item.id !== 'taro.h5-static-smoke');
|
||||
return evidence;
|
||||
});
|
||||
assert.notEqual(missingTaroStaticSmoke.status, 0, 'missing H5 static smoke should fail launch gate');
|
||||
assert.ok(
|
||||
missingTaroStaticSmoke.payload.checks?.some(item => item.id === 'check.taro.h5-static-smoke' && item.status === 'blocker'),
|
||||
'missing H5 static smoke should be reported as a blocker',
|
||||
);
|
||||
|
||||
const missingAttestation = runGate(tempDir => {
|
||||
const evidence = createEvidence(tempDir);
|
||||
evidence.attestations = evidence.attestations.filter(item => item.id !== 'backup.snapshot');
|
||||
|
||||
@@ -124,6 +124,25 @@ const gateChecks = [
|
||||
commandIncludes: 'build:taro:h5:platform',
|
||||
summary: { failed: 0 },
|
||||
},
|
||||
{
|
||||
id: 'taro.h5-static-smoke',
|
||||
label: 'Taro H5 static startup smoke',
|
||||
commandIncludes: 'smoke:taro:h5',
|
||||
summary: {
|
||||
fail: 0,
|
||||
portals: 3,
|
||||
tenantResolveRequests: 3,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'taro.h5-release-guardrails',
|
||||
label: 'Taro H5 release artifact guardrails',
|
||||
commandIncludes: 'taro-h5-release-guardrails-test.js',
|
||||
summary: {
|
||||
fail: 0,
|
||||
warn: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'audit.runtime',
|
||||
label: 'Runtime dependency audit',
|
||||
|
||||
@@ -24,6 +24,12 @@ const portals = [
|
||||
},
|
||||
];
|
||||
|
||||
function parseArgs(argv) {
|
||||
return {
|
||||
json: argv.includes('--json'),
|
||||
};
|
||||
}
|
||||
|
||||
const allowedRuntimeConfigKeys = new Set([
|
||||
'portal',
|
||||
'apiBaseUrl',
|
||||
@@ -363,6 +369,7 @@ function summarize(results) {
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const options = parseArgs(process.argv.slice(2));
|
||||
const api = await createMockApiServer();
|
||||
try {
|
||||
const results = [];
|
||||
@@ -370,21 +377,47 @@ async function main() {
|
||||
results.push(await smokePortal(portal, api));
|
||||
}
|
||||
const summary = summarize(results);
|
||||
console.log(`Taro H5 static smoke: ${summary.fail} fail(s), ${summary.pass} pass(es)`);
|
||||
for (const result of results) {
|
||||
console.log(`[PORTAL] ${result.portal} ${result.staticBaseUrl} -> ${result.landingPath}`);
|
||||
for (const check of result.checks) {
|
||||
console.log(`[${check.ok ? 'PASS' : 'FAIL'}] ${check.id}: ${check.detail}`);
|
||||
}
|
||||
}
|
||||
const resolveRequests = api.requests.filter(item => item.path === '/api/tenant/resolve');
|
||||
console.log(`[MOCK API] tenant resolve requests=${resolveRequests.length}`);
|
||||
const payload = {
|
||||
summary: {
|
||||
fail: summary.fail + (resolveRequests.length === portals.length ? 0 : 1),
|
||||
pass: summary.pass + (resolveRequests.length === portals.length ? 1 : 0),
|
||||
portals: portals.length,
|
||||
tenantResolveRequests: resolveRequests.length,
|
||||
},
|
||||
portals: results,
|
||||
checks: [
|
||||
...summary.checks.map(item => ({
|
||||
status: item.ok ? 'pass' : 'fail',
|
||||
id: item.id,
|
||||
detail: item.detail,
|
||||
})),
|
||||
{
|
||||
status: resolveRequests.length === portals.length ? 'pass' : 'fail',
|
||||
id: 'mock_api.tenant_resolve_count',
|
||||
detail: `expected=${portals.length} actual=${resolveRequests.length}`,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
if (options.json) {
|
||||
console.log(JSON.stringify(payload, null, 2));
|
||||
} else {
|
||||
console.log(`Taro H5 static smoke: ${payload.summary.fail} fail(s), ${payload.summary.pass} pass(es)`);
|
||||
for (const result of results) {
|
||||
console.log(`[PORTAL] ${result.portal} ${result.staticBaseUrl} -> ${result.landingPath}`);
|
||||
for (const check of result.checks) {
|
||||
console.log(`[${check.ok ? 'PASS' : 'FAIL'}] ${check.id}: ${check.detail}`);
|
||||
}
|
||||
}
|
||||
console.log(`[MOCK API] tenant resolve requests=${resolveRequests.length}`);
|
||||
}
|
||||
if (resolveRequests.length !== portals.length) {
|
||||
console.log(`[FAIL] mock_api.tenant_resolve_count: expected ${portals.length}, got ${resolveRequests.length}`);
|
||||
if (!options.json) console.log(`[FAIL] mock_api.tenant_resolve_count: expected ${portals.length}, got ${resolveRequests.length}`);
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
}
|
||||
if (summary.fail > 0) process.exitCode = 1;
|
||||
if (payload.summary.fail > 0) process.exitCode = 1;
|
||||
} finally {
|
||||
await api.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user