mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
--no-bail for verify-data-integrity script
This commit is contained in:
parent
c932c493c5
commit
4c22b37fdf
@ -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()
|
||||
|
||||
2
.github/workflows/e2e-api-tests.yaml
vendored
2
.github/workflows/e2e-api-tests.yaml
vendored
@ -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()
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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 };
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user