Skip to content

Commit 4c22b37

Browse files
committed
--no-bail for verify-data-integrity script
1 parent c932c49 commit 4c22b37

6 files changed

Lines changed: 53 additions & 9 deletions

File tree

.github/workflows/db-migration-backwards-compatibility.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ jobs:
215215
run: pnpm test
216216

217217
- name: Verify data integrity
218-
run: pnpm run verify-data-integrity
218+
run: pnpm run verify-data-integrity --no-bail
219219

220220
- name: Print Docker Compose logs
221221
if: always()

.github/workflows/e2e-api-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ jobs:
156156
run: pnpm test ${{ matrix.freestyle-mode == 'prod' && '--min-workers=1 --max-workers=1' || '' }}
157157

158158
- name: Verify data integrity
159-
run: pnpm run verify-data-integrity
159+
run: pnpm run verify-data-integrity --no-bail
160160

161161
- name: Print Docker Compose logs
162162
if: always()

.github/workflows/e2e-custom-base-port-api-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ jobs:
150150
run: pnpm test
151151

152152
- name: Verify data integrity
153-
run: pnpm run verify-data-integrity
153+
run: pnpm run verify-data-integrity --no-bail
154154

155155
- name: Print Docker Compose logs
156156
if: always()

.github/workflows/e2e-source-of-truth-api-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ jobs:
156156
run: pnpm test
157157

158158
- name: Verify data integrity
159-
run: pnpm run verify-data-integrity
159+
run: pnpm run verify-data-integrity --no-bail
160160

161161
- name: Print Docker Compose logs
162162
if: always()

apps/backend/scripts/verify-data-integrity/index.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ const USE_MOCK_STRIPE_API = STRIPE_SECRET_KEY === "sk_test_mockstripekey";
2121
let targetOutputData: OutputData | undefined = undefined;
2222
const currentOutputData: OutputData = {};
2323

24-
const recurse = createRecurse();
25-
2624
async function main() {
2725
console.log();
2826
console.log();
@@ -80,6 +78,13 @@ async function main() {
8078
const shouldVerifyOutput = flags.includes("--verify-output");
8179
const shouldSkipNeon = flags.includes("--skip-neon");
8280
const recentFirst = flags.includes("--recent-first");
81+
const noBail = flags.includes("--no-bail");
82+
83+
const { recurse, collectedErrors } = createRecurse({ noBail });
84+
85+
if (noBail) {
86+
console.log(`Running in no-bail mode: will continue on errors and report all at the end.`);
87+
}
8388

8489
if (shouldSaveOutput) {
8590
console.log(`Will save output to ${OUTPUT_FILE_PATH}`);
@@ -318,6 +323,27 @@ async function main() {
318323
console.log(`Output saved to ${OUTPUT_FILE_PATH}`);
319324
}
320325

326+
// Report collected errors if in no-bail mode
327+
if (collectedErrors.length > 0) {
328+
console.log();
329+
console.log();
330+
console.log();
331+
console.log();
332+
console.log("===================================================");
333+
console.log(`\x1b[41mFAILED\x1b[0m! Found ${collectedErrors.length} error(s):`);
334+
console.log();
335+
for (let i = 0; i < collectedErrors.length; i++) {
336+
const { context, error } = collectedErrors[i];
337+
console.log(`--- Error ${i + 1}/${collectedErrors.length} ---`);
338+
console.log(`Context: ${context}`);
339+
console.error(error);
340+
console.log();
341+
}
342+
console.log("===================================================");
343+
console.log();
344+
process.exit(1);
345+
}
346+
321347
console.log();
322348
console.log();
323349
console.log();
Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
export type RecurseFunction = (progressPrefix: string, inner: (recurse: RecurseFunction) => Promise<void>) => Promise<void>;
22

3-
export function createRecurse(): RecurseFunction {
3+
export type CollectedError = {
4+
context: string,
5+
error: unknown,
6+
};
7+
8+
export function createRecurse(options: { noBail: boolean }): { recurse: RecurseFunction, collectedErrors: CollectedError[] } {
49
let lastProgress = performance.now() - 9999999999;
10+
const collectedErrors: CollectedError[] = [];
511

612
const _recurse = async (
713
progressPrefix: string | ((...args: any[]) => void),
814
inner: Parameters<RecurseFunction>[1],
15+
contextPath: string = "",
916
): Promise<void> => {
1017
const progressFunc = typeof progressPrefix === "function" ? progressPrefix : (...args: any[]) => {
1118
console.log(`${progressPrefix}`, ...args);
1219
};
20+
const currentContext = typeof progressPrefix === "string" ? progressPrefix : contextPath;
1321
if (performance.now() - lastProgress > 1000) {
1422
progressFunc();
1523
lastProgress = performance.now();
@@ -19,14 +27,24 @@ export function createRecurse(): RecurseFunction {
1927
(progressPrefix, inner) => _recurse(
2028
(...args) => progressFunc(progressPrefix, ...args),
2129
inner,
30+
`${currentContext} > ${typeof progressPrefix === "string" ? progressPrefix : ""}`,
2231
),
2332
);
2433
} catch (error) {
2534
progressFunc(`\x1b[41mERROR\x1b[0m!`);
26-
throw error;
35+
if (options.noBail) {
36+
collectedErrors.push({
37+
context: currentContext,
38+
error,
39+
});
40+
} else {
41+
throw error;
42+
}
2743
}
2844
};
2945

30-
return _recurse;
46+
const recurse: RecurseFunction = (progressPrefix, inner) => _recurse(progressPrefix, inner, progressPrefix);
47+
48+
return { recurse, collectedErrors };
3149
}
3250

0 commit comments

Comments
 (0)