--no-bail for verify-data-integrity script

This commit is contained in:
Konstantin Wohlwend 2026-01-28 13:53:27 -08:00
parent c932c493c5
commit 4c22b37fdf
6 changed files with 53 additions and 9 deletions

View File

@ -215,7 +215,7 @@ jobs:
run: pnpm test
- name: Verify data integrity
run: pnpm run verify-data-integrity
run: pnpm run verify-data-integrity --no-bail
- name: Print Docker Compose logs
if: always()

View File

@ -156,7 +156,7 @@ jobs:
run: pnpm test ${{ matrix.freestyle-mode == 'prod' && '--min-workers=1 --max-workers=1' || '' }}
- name: Verify data integrity
run: pnpm run verify-data-integrity
run: pnpm run verify-data-integrity --no-bail
- name: Print Docker Compose logs
if: always()

View File

@ -150,7 +150,7 @@ jobs:
run: pnpm test
- name: Verify data integrity
run: pnpm run verify-data-integrity
run: pnpm run verify-data-integrity --no-bail
- name: Print Docker Compose logs
if: always()

View File

@ -156,7 +156,7 @@ jobs:
run: pnpm test
- name: Verify data integrity
run: pnpm run verify-data-integrity
run: pnpm run verify-data-integrity --no-bail
- name: Print Docker Compose logs
if: always()

View File

@ -21,8 +21,6 @@ const USE_MOCK_STRIPE_API = STRIPE_SECRET_KEY === "sk_test_mockstripekey";
let targetOutputData: OutputData | undefined = undefined;
const currentOutputData: OutputData = {};
const recurse = createRecurse();
async function main() {
console.log();
console.log();
@ -80,6 +78,13 @@ async function main() {
const shouldVerifyOutput = flags.includes("--verify-output");
const shouldSkipNeon = flags.includes("--skip-neon");
const recentFirst = flags.includes("--recent-first");
const noBail = flags.includes("--no-bail");
const { recurse, collectedErrors } = createRecurse({ noBail });
if (noBail) {
console.log(`Running in no-bail mode: will continue on errors and report all at the end.`);
}
if (shouldSaveOutput) {
console.log(`Will save output to ${OUTPUT_FILE_PATH}`);
@ -318,6 +323,27 @@ async function main() {
console.log(`Output saved to ${OUTPUT_FILE_PATH}`);
}
// Report collected errors if in no-bail mode
if (collectedErrors.length > 0) {
console.log();
console.log();
console.log();
console.log();
console.log("===================================================");
console.log(`\x1b[41mFAILED\x1b[0m! Found ${collectedErrors.length} error(s):`);
console.log();
for (let i = 0; i < collectedErrors.length; i++) {
const { context, error } = collectedErrors[i];
console.log(`--- Error ${i + 1}/${collectedErrors.length} ---`);
console.log(`Context: ${context}`);
console.error(error);
console.log();
}
console.log("===================================================");
console.log();
process.exit(1);
}
console.log();
console.log();
console.log();

View File

@ -1,15 +1,23 @@
export type RecurseFunction = (progressPrefix: string, inner: (recurse: RecurseFunction) => Promise<void>) => Promise<void>;
export function createRecurse(): RecurseFunction {
export type CollectedError = {
context: string,
error: unknown,
};
export function createRecurse(options: { noBail: boolean }): { recurse: RecurseFunction, collectedErrors: CollectedError[] } {
let lastProgress = performance.now() - 9999999999;
const collectedErrors: CollectedError[] = [];
const _recurse = async (
progressPrefix: string | ((...args: any[]) => void),
inner: Parameters<RecurseFunction>[1],
contextPath: string = "",
): Promise<void> => {
const progressFunc = typeof progressPrefix === "function" ? progressPrefix : (...args: any[]) => {
console.log(`${progressPrefix}`, ...args);
};
const currentContext = typeof progressPrefix === "string" ? progressPrefix : contextPath;
if (performance.now() - lastProgress > 1000) {
progressFunc();
lastProgress = performance.now();
@ -19,14 +27,24 @@ export function createRecurse(): RecurseFunction {
(progressPrefix, inner) => _recurse(
(...args) => progressFunc(progressPrefix, ...args),
inner,
`${currentContext} > ${typeof progressPrefix === "string" ? progressPrefix : ""}`,
),
);
} catch (error) {
progressFunc(`\x1b[41mERROR\x1b[0m!`);
throw error;
if (options.noBail) {
collectedErrors.push({
context: currentContext,
error,
});
} else {
throw error;
}
}
};
return _recurse;
const recurse: RecurseFunction = (progressPrefix, inner) => _recurse(progressPrefix, inner, progressPrefix);
return { recurse, collectedErrors };
}