Skip to content

Commit 471229a

Browse files
authored
feat: allow users to ignore existing pwcs dependency cache (#1229)
Users can pass `--refresh-cache` to ignore existing dependency caches and rebuild the cache for future runs.
1 parent 63f7171 commit 471229a

6 files changed

Lines changed: 30 additions & 1 deletion

File tree

packages/cli/src/commands/pw-test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ export default class PwTestCommand extends AuthCommand {
114114
'install-command': Flags.string({
115115
description: 'Command to install dependencies before running tests.',
116116
}),
117+
'refresh-cache': Flags.boolean({
118+
description: 'Force a fresh install of dependencies and update the cached version.',
119+
default: false,
120+
}),
117121
}
118122

119123
async run (): Promise<void> {
@@ -138,6 +142,7 @@ export default class PwTestCommand extends AuthCommand {
138142
'include': includeFlag,
139143
'frequency': frequency,
140144
'install-command': installCommand,
145+
'refresh-cache': refreshCache,
141146
} = flags
142147
const { configDirectory, configFilenames } = splitConfigFilePath(configFilename)
143148
const pwPathFlag = this.getConfigPath(playwrightFlags)
@@ -309,6 +314,7 @@ export default class PwTestCommand extends AuthCommand {
309314
// TODO: ADD PROPER RETRY STRATEGY HANDLING
310315
null, // testRetryStrategy
311316
streamLogs,
317+
refreshCache,
312318
)
313319

314320
runner.on(Events.RUN_STARTED,

packages/cli/src/commands/test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ export default class Test extends AuthCommand {
114114
allowNo: true,
115115
env: 'CHECKLY_VERIFY_RUNTIME_DEPENDENCIES',
116116
}),
117+
'refresh-cache': Flags.boolean({
118+
description: 'Force a fresh install of dependencies and update the cached version.',
119+
default: false,
120+
}),
117121
}
118122

119123
static args = {
@@ -148,6 +152,7 @@ export default class Test extends AuthCommand {
148152
'update-snapshots': updateSnapshots,
149153
retries,
150154
'verify-runtime-dependencies': verifyRuntimeDependencies,
155+
'refresh-cache': refreshCache,
151156
} = flags
152157
const filePatterns = argv as string[]
153158

@@ -184,7 +189,7 @@ export default class Test extends AuthCommand {
184189
availableRuntimes: availableRuntimes.reduce((acc, runtime) => {
185190
acc[runtime.name] = runtime
186191
return acc
187-
}, <Record<string, Runtime>> {}),
192+
}, <Record<string, Runtime>>{}),
188193
defaultRuntimeId: account.runtimeId,
189194
verifyRuntimeDependencies,
190195
checklyConfigConstructs,
@@ -359,6 +364,8 @@ export default class Test extends AuthCommand {
359364
updateSnapshots,
360365
configDirectory,
361366
testRetryStrategy,
367+
undefined,
368+
refreshCache,
362369
)
363370

364371
runner.on(Events.RUN_STARTED,

packages/cli/src/commands/trigger.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ export default class Trigger extends AuthCommand {
9393
'retries': Flags.integer({
9494
description: `[default: 0, max: ${MAX_RETRIES}] How many times to retry a check run.`,
9595
}),
96+
'refresh-cache': Flags.boolean({
97+
description: 'Force a fresh install of dependencies and update the cached version.',
98+
default: false,
99+
}),
96100
}
97101

98102
async run (): Promise<void> {
@@ -111,6 +115,7 @@ export default class Trigger extends AuthCommand {
111115
'env-file': envFile,
112116
'test-session-name': testSessionName,
113117
retries,
118+
'refresh-cache': refreshCache,
114119
} = flags
115120
const envVars = await getEnvs(envFile, env)
116121
const { configDirectory, configFilenames } = splitConfigFilePath(configFilename)
@@ -146,6 +151,7 @@ export default class Trigger extends AuthCommand {
146151
ciInfo.environment,
147152
testSessionName,
148153
testRetryStrategy,
154+
refreshCache,
149155
)
150156
// TODO: This is essentially the same for `checkly test`. Maybe reuse code.
151157
runner.on(Events.RUN_STARTED,

packages/cli/src/rest/test-sessions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type RunTestSessionRequest = {
1515
environment?: string | null
1616
shouldRecord: boolean
1717
streamLogs?: boolean
18+
refreshCache?: boolean
1819
}
1920

2021
type TriggerTestSessionRequest = {
@@ -27,6 +28,7 @@ type TriggerTestSessionRequest = {
2728
repoInfo: GitInformation | null
2829
environment: string | null
2930
testRetryStrategy: RetryStrategy | null
31+
refreshCache?: boolean
3032
}
3133

3234
export type TestResultsShortLinks = {

packages/cli/src/services/test-runner.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default class TestRunner extends AbstractCheckRunner {
2121
baseDirectory: string
2222
testRetryStrategy: RetryStrategy | null
2323
streamLogs: boolean
24+
refreshCache: boolean
2425

2526
constructor (
2627
accountId: string,
@@ -37,6 +38,7 @@ export default class TestRunner extends AbstractCheckRunner {
3738
baseDirectory: string,
3839
testRetryStrategy: RetryStrategy | null,
3940
streamLogs?: boolean,
41+
refreshCache?: boolean,
4042
) {
4143
super(accountId, timeout, verbose)
4244
this.projectBundle = projectBundle
@@ -50,6 +52,7 @@ export default class TestRunner extends AbstractCheckRunner {
5052
this.baseDirectory = baseDirectory
5153
this.testRetryStrategy = testRetryStrategy
5254
this.streamLogs = streamLogs ?? false
55+
this.refreshCache = refreshCache ?? false
5356
}
5457

5558
async scheduleChecks (
@@ -92,6 +95,7 @@ export default class TestRunner extends AbstractCheckRunner {
9295
environment: this.environment,
9396
shouldRecord: this.shouldRecord,
9497
streamLogs: this.streamLogs,
98+
refreshCache: this.refreshCache,
9599
})
96100
const { testSessionId, sequenceIds } = data
97101
const checks = this.checkBundles.map(({ construct: check }) => {

packages/cli/src/services/trigger-runner.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default class TriggerRunner extends AbstractCheckRunner {
1212
environment: string | null
1313
testSessionName: string | undefined
1414
testRetryStrategy: RetryStrategy | null
15+
refreshCache: boolean
1516

1617
constructor (
1718
accountId: string,
@@ -25,6 +26,7 @@ export default class TriggerRunner extends AbstractCheckRunner {
2526
environment: string | null,
2627
testSessionName: string | undefined,
2728
testRetryStrategy: RetryStrategy | null,
29+
refreshCache?: boolean,
2830
) {
2931
super(accountId, timeout, verbose)
3032
this.shouldRecord = shouldRecord
@@ -35,6 +37,7 @@ export default class TriggerRunner extends AbstractCheckRunner {
3537
this.environment = environment
3638
this.testSessionName = testSessionName
3739
this.testRetryStrategy = testRetryStrategy
40+
this.refreshCache = refreshCache ?? false
3841
}
3942

4043
async scheduleChecks (
@@ -53,6 +56,7 @@ export default class TriggerRunner extends AbstractCheckRunner {
5356
repoInfo: this.repoInfo,
5457
environment: this.environment,
5558
testRetryStrategy: this.testRetryStrategy,
59+
refreshCache: this.refreshCache,
5660
})
5761
const {
5862
checks,

0 commit comments

Comments
 (0)