Refactor and improve external URL checks

- Move external URL checks to its own module under `tests/`. This
  separates them from integration test, addressing long runs and
  frequent failures that led to ignoring test results.
- Move `check-desktop-runtime-errors` to `tests/checks` to keep all
  test-related checks into one directory.
- Replace `ts-node` with `vite` for running
  `check-desktop-runtime-errors` to maintain a consistent execution
  environment across checks.
- Implement a timeout for each fetch call.
- Be nice to external sources, wait 5 seconds before sending another
  request to an URL under same domain. This solves rate-limiting issues.
- Instead of running test on every push/pull request, run them only
  weekly.
- Do not run tests on each commit/PR but only scheduled (weekly) to
  minimize noise.
- Fix URLs are not captured correctly inside backticks or parenthesis.
This commit is contained in:
undergroundwires
2023-09-01 00:18:47 +02:00
parent f4d86fccfd
commit 19e42c9c52
43 changed files with 400 additions and 449 deletions

View File

@@ -0,0 +1,36 @@
import { log } from './utils/log';
export enum CommandLineFlag {
ForceRebuild,
TakeScreenshot,
}
export const COMMAND_LINE_FLAGS: {
readonly [key in CommandLineFlag]: string;
} = Object.freeze({
[CommandLineFlag.ForceRebuild]: '--build',
[CommandLineFlag.TakeScreenshot]: '--screenshot',
});
export function logCurrentArgs(): void {
const processArguments = getProcessArguments();
if (!processArguments.length) {
log('No additional arguments provided.');
return;
}
log(`Arguments: ${processArguments.join(', ')}`);
}
export function hasCommandLineFlag(flag: CommandLineFlag): boolean {
return getProcessArguments()
.includes(COMMAND_LINE_FLAGS[flag]);
}
/*
Fetches process arguments dynamically each time the function is called.
This design allows for runtime modifications to process.argv, supporting scenarios
where the command-line arguments might be altered dynamically.
*/
function getProcessArguments(): string[] {
return process.argv.slice(2);
}