diff --git a/packages/cli/src/commands/pw-test.ts b/packages/cli/src/commands/pw-test.ts index 259e4fb42..0847d125a 100644 --- a/packages/cli/src/commands/pw-test.ts +++ b/packages/cli/src/commands/pw-test.ts @@ -110,6 +110,10 @@ export default class PwTestCommand extends AuthCommand { 'install-command': Flags.string({ description: 'Command to install dependencies before running tests.', }), + 'refresh-cache': Flags.boolean({ + description: 'Force a fresh install of dependencies and update the cached version.', + default: false, + }), } async run (): Promise { @@ -134,6 +138,7 @@ export default class PwTestCommand extends AuthCommand { 'include': includeFlag, 'frequency': frequency, 'install-command': installCommand, + 'refresh-cache': refreshCache, } = flags const { configDirectory, configFilenames } = splitConfigFilePath(configFilename) const pwPathFlag = this.getConfigPath(playwrightFlags) @@ -315,6 +320,7 @@ export default class PwTestCommand extends AuthCommand { // TODO: ADD PROPER RETRY STRATEGY HANDLING null, // testRetryStrategy streamLogs, + refreshCache, ) runner.on(Events.RUN_STARTED, diff --git a/packages/cli/src/commands/test.ts b/packages/cli/src/commands/test.ts index e7b65a0a1..6e7831501 100644 --- a/packages/cli/src/commands/test.ts +++ b/packages/cli/src/commands/test.ts @@ -110,6 +110,10 @@ export default class Test extends AuthCommand { allowNo: true, env: 'CHECKLY_VERIFY_RUNTIME_DEPENDENCIES', }), + 'refresh-cache': Flags.boolean({ + description: 'Force a fresh install of dependencies and update the cached version.', + default: false, + }), } static args = { @@ -144,6 +148,7 @@ export default class Test extends AuthCommand { 'update-snapshots': updateSnapshots, retries, 'verify-runtime-dependencies': verifyRuntimeDependencies, + 'refresh-cache': refreshCache, } = flags const filePatterns = argv as string[] @@ -180,7 +185,7 @@ export default class Test extends AuthCommand { availableRuntimes: availableRuntimes.reduce((acc, runtime) => { acc[runtime.name] = runtime return acc - }, > {}), + }, >{}), defaultRuntimeId: account.runtimeId, verifyRuntimeDependencies, checklyConfigConstructs, @@ -358,6 +363,8 @@ export default class Test extends AuthCommand { updateSnapshots, configDirectory, testRetryStrategy, + undefined, + refreshCache, ) runner.on(Events.RUN_STARTED, diff --git a/packages/cli/src/commands/trigger.ts b/packages/cli/src/commands/trigger.ts index dfe1d0cad..e4fe77f13 100644 --- a/packages/cli/src/commands/trigger.ts +++ b/packages/cli/src/commands/trigger.ts @@ -90,6 +90,10 @@ export default class Trigger extends AuthCommand { 'retries': Flags.integer({ description: `[default: 0, max: ${MAX_RETRIES}] How many times to retry a check run.`, }), + 'refresh-cache': Flags.boolean({ + description: 'Force a fresh install of dependencies and update the cached version.', + default: false, + }), } async run (): Promise { @@ -108,6 +112,7 @@ export default class Trigger extends AuthCommand { 'env-file': envFile, 'test-session-name': testSessionName, retries, + 'refresh-cache': refreshCache, } = flags const envVars = await getEnvs(envFile, env) const { configDirectory, configFilenames } = splitConfigFilePath(configFilename) @@ -143,6 +148,7 @@ export default class Trigger extends AuthCommand { ciInfo.environment, testSessionName, testRetryStrategy, + refreshCache, ) // TODO: This is essentially the same for `checkly test`. Maybe reuse code. runner.on(Events.RUN_STARTED, diff --git a/packages/cli/src/constructs/api-check.ts b/packages/cli/src/constructs/api-check.ts index 23e9f95dc..b9490b184 100644 --- a/packages/cli/src/constructs/api-check.ts +++ b/packages/cli/src/constructs/api-check.ts @@ -11,7 +11,6 @@ import { DeprecatedPropertyDiagnostic, InvalidPropertyValueDiagnostic } from './ import { ApiCheckBundle, ApiCheckBundleProps } from './api-check-bundle' import { Assertion } from './api-assertion' import { validateResponseTimes } from './internal/common-diagnostics' -import { Runtime } from '../runtimes' /** * Default configuration that can be applied to API checks. diff --git a/packages/cli/src/rest/test-sessions.ts b/packages/cli/src/rest/test-sessions.ts index c8c4c46d4..da3ee9f09 100644 --- a/packages/cli/src/rest/test-sessions.ts +++ b/packages/cli/src/rest/test-sessions.ts @@ -15,6 +15,7 @@ type RunTestSessionRequest = { environment?: string | null shouldRecord: boolean streamLogs?: boolean + refreshCache?: boolean } type TriggerTestSessionRequest = { @@ -27,6 +28,7 @@ type TriggerTestSessionRequest = { repoInfo: GitInformation | null environment: string | null testRetryStrategy: RetryStrategy | null + refreshCache?: boolean } export type TestResultsShortLinks = { diff --git a/packages/cli/src/services/test-runner.ts b/packages/cli/src/services/test-runner.ts index 4a03e3cdd..b33d5a581 100644 --- a/packages/cli/src/services/test-runner.ts +++ b/packages/cli/src/services/test-runner.ts @@ -21,6 +21,7 @@ export default class TestRunner extends AbstractCheckRunner { baseDirectory: string testRetryStrategy: RetryStrategy | null streamLogs: boolean + refreshCache: boolean constructor ( accountId: string, @@ -37,6 +38,7 @@ export default class TestRunner extends AbstractCheckRunner { baseDirectory: string, testRetryStrategy: RetryStrategy | null, streamLogs?: boolean, + refreshCache?: boolean, ) { super(accountId, timeout, verbose) this.projectBundle = projectBundle @@ -50,6 +52,7 @@ export default class TestRunner extends AbstractCheckRunner { this.baseDirectory = baseDirectory this.testRetryStrategy = testRetryStrategy this.streamLogs = streamLogs ?? false + this.refreshCache = refreshCache ?? false } async scheduleChecks ( @@ -92,6 +95,7 @@ export default class TestRunner extends AbstractCheckRunner { environment: this.environment, shouldRecord: this.shouldRecord, streamLogs: this.streamLogs, + refreshCache: this.refreshCache, }) const { testSessionId, sequenceIds } = data const checks = this.checkBundles.map(({ construct: check }) => { diff --git a/packages/cli/src/services/trigger-runner.ts b/packages/cli/src/services/trigger-runner.ts index d80c82d6f..cf9113d70 100644 --- a/packages/cli/src/services/trigger-runner.ts +++ b/packages/cli/src/services/trigger-runner.ts @@ -12,6 +12,7 @@ export default class TriggerRunner extends AbstractCheckRunner { environment: string | null testSessionName: string | undefined testRetryStrategy: RetryStrategy | null + refreshCache: boolean constructor ( accountId: string, @@ -25,6 +26,7 @@ export default class TriggerRunner extends AbstractCheckRunner { environment: string | null, testSessionName: string | undefined, testRetryStrategy: RetryStrategy | null, + refreshCache?: boolean, ) { super(accountId, timeout, verbose) this.shouldRecord = shouldRecord @@ -35,6 +37,7 @@ export default class TriggerRunner extends AbstractCheckRunner { this.environment = environment this.testSessionName = testSessionName this.testRetryStrategy = testRetryStrategy + this.refreshCache = refreshCache ?? false } async scheduleChecks ( @@ -53,6 +56,7 @@ export default class TriggerRunner extends AbstractCheckRunner { repoInfo: this.repoInfo, environment: this.environment, testRetryStrategy: this.testRetryStrategy, + refreshCache: this.refreshCache, }) const { checks,