-
Notifications
You must be signed in to change notification settings - Fork 16
Umutuzgur/sc 23256/pwt native code package simple #1042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
df79d4d
e4bbc5d
1c69242
d2750f8
94acdcf
19b61b8
ce5f6ef
7a01b04
3d02352
2f92a78
f0ef2c5
a8112f3
0134d13
4312b50
43b46a9
23e7dd4
2527c42
d4f698c
be782c6
3a1c74c
5f65915
0175d3e
6fb947b
40e36fd
7186c5d
80b33fb
414ac1d
6c68959
00d6681
602cc74
2dc4a84
895168b
6e0c662
f6e060e
91b5df2
231388b
67ed81d
7283fc7
0140338
30d1509
f57b604
6de7e35
daa9405
985f579
920849e
ed7d7e8
f828afd
b38f7f8
fe47192
c51987f
12cfc40
fa372d6
a4b8d5e
b2477fd
fb5e96c
aba26f3
c3e171d
f681793
878e7f7
4ff8089
8607983
93e068b
762ad63
f272056
88680f7
680d147
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -16,7 +16,7 @@ | |||
import { filterByFileNamePattern, filterByCheckNamePattern, filterByTags } from '../services/test-filters' | ||||
import type { Runtime } from '../rest/runtimes' | ||||
import { AuthCommand } from './authCommand' | ||||
import { BrowserCheck, Check, HeartbeatCheck, MultiStepCheck, Project, RetryStrategyBuilder, Session } from '../constructs' | ||||
import { BrowserCheck, Check, HeartbeatCheck, MultiStepCheck, PlaywrightCheck, Project, RetryStrategyBuilder, Session } from '../constructs' | ||||
import type { Region } from '..' | ||||
import { splitConfigFilePath, getGitInformation, getCiInformation, getEnvs } from '../services/util' | ||||
import { createReporters, ReporterType } from '../reporters/reporter' | ||||
|
@@ -146,6 +146,7 @@ | |||
'update-snapshots': updateSnapshots, | ||||
retries, | ||||
'verify-runtime-dependencies': verifyRuntimeDependencies, | ||||
playwrightConfig, | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused playwrightConfig parameter. The Either remove this unused parameter or implement its functionality. The static analyzer flagged this as well. - playwrightConfig, 📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Check: lint[warning] 149-149: 🤖 Prompt for AI Agents
|
||||
} = flags | ||||
const filePatterns = argv as string[] | ||||
|
||||
|
@@ -182,6 +183,9 @@ | |||
defaultRuntimeId: account.runtimeId, | ||||
verifyRuntimeDependencies, | ||||
checklyConfigConstructs, | ||||
playwrightConfigPath: checklyConfig.checks?.playwrightConfigPath, | ||||
include: checklyConfig.checks?.include, | ||||
playwrightChecks: checklyConfig.checks?.playwrightChecks, | ||||
}) | ||||
const checks = Object.entries(project.data.check) | ||||
.filter(([, check]) => { | ||||
|
@@ -230,6 +234,19 @@ | |||
check.snapshots = await uploadSnapshots(check.rawSnapshots) | ||||
} | ||||
|
||||
for (const check of checks) { | ||||
// TODO: Improve bundling and uploading | ||||
if (!(check instanceof PlaywrightCheck) || check.codeBundlePath) { | ||||
continue | ||||
} | ||||
const { | ||||
relativePlaywrightConfigPath, browsers, key, | ||||
} = await PlaywrightCheck.bundleProject(check.playwrightConfigPath, check.include) | ||||
check.codeBundlePath = key | ||||
check.browsers = browsers | ||||
check.playwrightConfigPath = relativePlaywrightConfigPath | ||||
} | ||||
|
||||
if (this.fancy) { | ||||
ux.action.stop() | ||||
} | ||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,124 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
import fs from 'fs' | ||||||||||||||||||||||||||||||||||||||||||||||||
import type { AxiosResponse } from 'axios' | ||||||||||||||||||||||||||||||||||||||||||||||||
import { Check, CheckProps } from './check' | ||||||||||||||||||||||||||||||||||||||||||||||||
import { Session } from './project' | ||||||||||||||||||||||||||||||||||||||||||||||||
import { | ||||||||||||||||||||||||||||||||||||||||||||||||
bundlePlayWrightProject, cleanup, | ||||||||||||||||||||||||||||||||||||||||||||||||
} from '../services/util' | ||||||||||||||||||||||||||||||||||||||||||||||||
import { checklyStorage } from '../rest/api' | ||||||||||||||||||||||||||||||||||||||||||||||||
import { ValidationError } from './validator-error' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
export interface PlaywrightCheckProps extends CheckProps { | ||||||||||||||||||||||||||||||||||||||||||||||||
playwrightConfigPath: string | ||||||||||||||||||||||||||||||||||||||||||||||||
codeBundlePath?: string | ||||||||||||||||||||||||||||||||||||||||||||||||
installCommand?: string | ||||||||||||||||||||||||||||||||||||||||||||||||
testCommand?: string | ||||||||||||||||||||||||||||||||||||||||||||||||
pwProjects?: string|string[] | ||||||||||||||||||||||||||||||||||||||||||||||||
pwTags?: string|string[] | ||||||||||||||||||||||||||||||||||||||||||||||||
browsers?: string[] | ||||||||||||||||||||||||||||||||||||||||||||||||
include?: string|string[] | ||||||||||||||||||||||||||||||||||||||||||||||||
groupName?: string | ||||||||||||||||||||||||||||||||||||||||||||||||
logicalId: string | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+11
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Redundant
Recommend dropping the field from the interface: export interface PlaywrightCheckProps extends CheckProps {
playwrightConfigPath: string
codeBundlePath?: string
@@
- groupName?: string
- logicalId: string
+ groupName?: string
} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||
export class PlaywrightCheck extends Check { | ||||||||||||||||||||||||||||||||||||||||||||||||
installCommand?: string | ||||||||||||||||||||||||||||||||||||||||||||||||
testCommand: string | ||||||||||||||||||||||||||||||||||||||||||||||||
playwrightConfigPath: string | ||||||||||||||||||||||||||||||||||||||||||||||||
pwProjects: string[] | ||||||||||||||||||||||||||||||||||||||||||||||||
pwTags: string[] | ||||||||||||||||||||||||||||||||||||||||||||||||
codeBundlePath?: string | ||||||||||||||||||||||||||||||||||||||||||||||||
browsers?: string[] | ||||||||||||||||||||||||||||||||||||||||||||||||
include: string[] | ||||||||||||||||||||||||||||||||||||||||||||||||
groupName?: string | ||||||||||||||||||||||||||||||||||||||||||||||||
name: string | ||||||||||||||||||||||||||||||||||||||||||||||||
constructor (logicalId: string, props: PlaywrightCheckProps) { | ||||||||||||||||||||||||||||||||||||||||||||||||
super(logicalId, props) | ||||||||||||||||||||||||||||||||||||||||||||||||
this.logicalId = logicalId | ||||||||||||||||||||||||||||||||||||||||||||||||
this.name = props.name | ||||||||||||||||||||||||||||||||||||||||||||||||
this.codeBundlePath = props.codeBundlePath | ||||||||||||||||||||||||||||||||||||||||||||||||
this.installCommand = props.installCommand | ||||||||||||||||||||||||||||||||||||||||||||||||
this.browsers = props.browsers | ||||||||||||||||||||||||||||||||||||||||||||||||
this.pwProjects = props.pwProjects | ||||||||||||||||||||||||||||||||||||||||||||||||
? (Array.isArray(props.pwProjects) ? props.pwProjects : [props.pwProjects]) | ||||||||||||||||||||||||||||||||||||||||||||||||
: [] | ||||||||||||||||||||||||||||||||||||||||||||||||
this.pwTags = props.pwTags | ||||||||||||||||||||||||||||||||||||||||||||||||
? (Array.isArray(props.pwTags) ? props.pwTags : [props.pwTags]) | ||||||||||||||||||||||||||||||||||||||||||||||||
: [] | ||||||||||||||||||||||||||||||||||||||||||||||||
this.include = props.include | ||||||||||||||||||||||||||||||||||||||||||||||||
? (Array.isArray(props.include) ? props.include : [props.include]) | ||||||||||||||||||||||||||||||||||||||||||||||||
: [] | ||||||||||||||||||||||||||||||||||||||||||||||||
this.testCommand = props.testCommand ?? 'npx playwright test' | ||||||||||||||||||||||||||||||||||||||||||||||||
if (!fs.existsSync(props.playwrightConfigPath)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
throw new ValidationError(`Playwright config doesnt exist ${props.playwrightConfigPath}`) | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
this.groupName = props.groupName | ||||||||||||||||||||||||||||||||||||||||||||||||
this.playwrightConfigPath = props.playwrightConfigPath | ||||||||||||||||||||||||||||||||||||||||||||||||
this.applyGroup(this.groupName) | ||||||||||||||||||||||||||||||||||||||||||||||||
Session.registerConstruct(this) | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
applyGroup (groupName?: string) { | ||||||||||||||||||||||||||||||||||||||||||||||||
if (!groupName) { | ||||||||||||||||||||||||||||||||||||||||||||||||
return | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
const checkGroups = Session.project?.data?.['check-group'] | ||||||||||||||||||||||||||||||||||||||||||||||||
if (!checkGroups) { | ||||||||||||||||||||||||||||||||||||||||||||||||
return | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
const group = Object.values(checkGroups).find(group => group.name === groupName) | ||||||||||||||||||||||||||||||||||||||||||||||||
if (group) { | ||||||||||||||||||||||||||||||||||||||||||||||||
this.groupId = group.ref() | ||||||||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||||||||
throw new ValidationError(`Error: No group named "${groupName}". Please verify the group exists in your code or create it.`) | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
getSourceFile () { | ||||||||||||||||||||||||||||||||||||||||||||||||
return this.__checkFilePath ?? this.logicalId | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
static buildTestCommand ( | ||||||||||||||||||||||||||||||||||||||||||||||||
testCommand: string, playwrightConfigPath: string, playwrightProject?: string[], playwrightTag?: string[], | ||||||||||||||||||||||||||||||||||||||||||||||||
) { | ||||||||||||||||||||||||||||||||||||||||||||||||
return `${testCommand} --config ${playwrightConfigPath}${playwrightProject?.length ? ' --project ' + playwrightProject.map(project => `"${project}"`).join(' ') : ''}${playwrightTag?.length ? ' --grep="' + playwrightTag.join('|') + '"' : ''}` | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
static async bundleProject (playwrightConfigPath: string, include: string[]) { | ||||||||||||||||||||||||||||||||||||||||||||||||
let dir = '' | ||||||||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||||||||
const { | ||||||||||||||||||||||||||||||||||||||||||||||||
outputFile, browsers, relativePlaywrightConfigPath, | ||||||||||||||||||||||||||||||||||||||||||||||||
} = await bundlePlayWrightProject(playwrightConfigPath, include) | ||||||||||||||||||||||||||||||||||||||||||||||||
dir = outputFile | ||||||||||||||||||||||||||||||||||||||||||||||||
const { data: { key } } = await PlaywrightCheck.uploadPlaywrightProject(dir) | ||||||||||||||||||||||||||||||||||||||||||||||||
return { key, browsers, relativePlaywrightConfigPath } | ||||||||||||||||||||||||||||||||||||||||||||||||
} finally { | ||||||||||||||||||||||||||||||||||||||||||||||||
await cleanup(dir) | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
static async uploadPlaywrightProject (dir: string): Promise<AxiosResponse> { | ||||||||||||||||||||||||||||||||||||||||||||||||
const { size } = await fs.promises.stat(dir) | ||||||||||||||||||||||||||||||||||||||||||||||||
const stream = fs.createReadStream(dir) | ||||||||||||||||||||||||||||||||||||||||||||||||
return checklyStorage.uploadCodeBundle(stream, size) | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
synthesize () { | ||||||||||||||||||||||||||||||||||||||||||||||||
const testCommand = PlaywrightCheck.buildTestCommand( | ||||||||||||||||||||||||||||||||||||||||||||||||
this.testCommand, | ||||||||||||||||||||||||||||||||||||||||||||||||
this.playwrightConfigPath, | ||||||||||||||||||||||||||||||||||||||||||||||||
this.pwProjects, | ||||||||||||||||||||||||||||||||||||||||||||||||
this.pwTags, | ||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||
return { | ||||||||||||||||||||||||||||||||||||||||||||||||
...super.synthesize(), | ||||||||||||||||||||||||||||||||||||||||||||||||
checkType: 'PLAYWRIGHT', | ||||||||||||||||||||||||||||||||||||||||||||||||
codeBundlePath: this.codeBundlePath, | ||||||||||||||||||||||||||||||||||||||||||||||||
testCommand, | ||||||||||||||||||||||||||||||||||||||||||||||||
installCommand: this.installCommand, | ||||||||||||||||||||||||||||||||||||||||||||||||
browsers: this.browsers, | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// import dotenv from 'dotenv'; | ||
// import path from 'path'; | ||
// dotenv.config({ path: path.resolve(__dirname, '.env') }); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: './tests', | ||
testMatch: 'tests.*.ts', | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: 'html', | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
// baseURL: 'http://127.0.0.1:3000', | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'Chromium', | ||
} | ||
], | ||
|
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
New code to bundle Playwright checks during deployment.
The implementation follows the same pattern as browser check snapshot handling, bundling Playwright projects and updating check metadata before deployment.
The TODO comment mentions that bundling and uploading should be improved. Consider tracking this as a separate ticket for future optimization.
🏁 Script executed:
Length of output: 1502
Approve Playwright bundling implementation; consolidate repetition and track TODO
The new bundling code in deploy.ts follows the established pattern in test.ts and project-parser.ts and correctly updates the PlaywrightCheck metadata before deployment. However, there’s repeated logic across three locations:
• packages/cli/src/commands/deploy.ts (lines 135–146)
• packages/cli/src/commands/test.ts (similar bundleProject call and metadata assignment)
• packages/cli/src/services/project-parser.ts (bundleProject + instantiation)
Suggestions:
codeBundlePath
,browsers
,playwrightConfigPath
) into a shared helper or method on PlaywrightCheck.🤖 Prompt for AI Agents