-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
chore(e2e-tests): Use tarball symlinks for E2E tests instead of verdaccio #20386
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0887664
chore(e2e-tests): Use tarball symlinks for E2E tests instead of verda…
mydea 1f93f1f
lint fix
mydea 9287dd5
fix order
mydea 0800fa7
add to optional too
mydea 5cb9c0b
fix overrides
mydea a34d06d
fix link handling
mydea a78242b
small fixes
mydea b2caccb
remove console log
mydea 4cccd63
fix e2e tests
mydea 26432cb
cleanup layer files
mydea a8a9f05
ensure we use absolute paths and fix overrides
mydea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,4 @@ tmp | |
| .tmp_build_stderr | ||
| pnpm-lock.yaml | ||
| .last-run.json | ||
| packed | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /* eslint-disable no-console */ | ||
|
|
||
| import { addPnpmOverrides } from './lib/pnpmOverrides'; | ||
| import * as path from 'path'; | ||
|
|
||
| async function run(): Promise<void> { | ||
| const tmpDirPath = process.argv[2]; | ||
| const packedDirPath = process.argv[3]; | ||
|
|
||
| if (!tmpDirPath || !packedDirPath) { | ||
| throw new Error('Tmp dir path and packed dir path are required'); | ||
| } | ||
|
|
||
| await addPnpmOverrides(path.resolve(tmpDirPath), path.resolve(packedDirPath)); | ||
| } | ||
|
|
||
| run().catch(error => { | ||
| console.error(error); | ||
| process.exit(1); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import * as path from 'path'; | ||
| import * as fs from 'fs'; | ||
| import { sync as globSync } from 'glob'; | ||
|
|
||
| const E2E_TESTS_ROOT = path.resolve(__dirname, '..'); | ||
| const REPOSITORY_ROOT = path.resolve(E2E_TESTS_ROOT, '../..'); | ||
|
|
||
| /** | ||
| * Workspace @sentry and @sentry-internal packages that have a built tarball for the E2E version. | ||
| * @returns The names of the published Sentry tarball packages. | ||
| */ | ||
| export function getPublishedSentryTarballPackageNames(): string[] { | ||
| const version = getE2eTestsPackageVersion(); | ||
| const names: string[] = []; | ||
|
|
||
| for (const packageJsonPath of globSync('packages/*/package.json', { | ||
| cwd: REPOSITORY_ROOT, | ||
| absolute: true, | ||
| })) { | ||
| const pkg = readJson<{ name?: string }>(packageJsonPath); | ||
| const name = pkg.name; | ||
| if (!name || (!name.startsWith('@sentry/') && !name.startsWith('@sentry-internal/'))) { | ||
| continue; | ||
| } | ||
| const packageDir = path.dirname(packageJsonPath); | ||
| const tarball = path.join(packageDir, versionedTarballFilename(name, version)); | ||
| if (fs.existsSync(tarball)) { | ||
| names.push(name); | ||
| } | ||
| } | ||
|
|
||
| return names.sort(); | ||
| } | ||
|
|
||
| /** Stable symlink name in `packed/` (no version segment). */ | ||
| export function packedSymlinkFilename(packageName: string): string { | ||
| return `${npmPackBasename(packageName)}-packed.tgz`; | ||
| } | ||
|
|
||
| /** | ||
| * Versioned tarball filename produced by `npm pack` in a package directory. | ||
| */ | ||
| export function versionedTarballFilename(packageName: string, version: string): string { | ||
| return `${npmPackBasename(packageName)}-${version}.tgz`; | ||
| } | ||
|
|
||
| /** | ||
| * npm pack tarball basename (without version and .tgz), e.g. `@sentry/core` -> `sentry-core`. | ||
| */ | ||
| function npmPackBasename(packageName: string): string { | ||
| return packageName.replace(/^@/, '').replace(/\//g, '-'); | ||
| } | ||
|
|
||
| function readJson<T>(filePath: string): T { | ||
| return JSON.parse(fs.readFileSync(filePath, 'utf8')) as T; | ||
| } | ||
|
|
||
| function getE2eTestsPackageVersion(): string { | ||
| return readJson<{ version: string }>(path.join(E2E_TESTS_ROOT, 'package.json')).version; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { readFile, writeFile } from 'fs/promises'; | ||
| import * as path from 'path'; | ||
| import { getPublishedSentryTarballPackageNames, packedSymlinkFilename } from './packedTarballUtils'; | ||
| import { fixFileLinkDependencies } from './copyToTemp'; | ||
|
|
||
| /** | ||
| * For a given temp test application directory, add pnpm.overrides to pin the internal Sentry packages to the packed tarballs. | ||
| * This is used to ensure that the test application uses the correct version of the internal Sentry packages. | ||
| * @param tmpDirPath - The temporary directory path of the test application. | ||
| * @param packedDirPath - The path to the packed tarballs. | ||
| * @param packageNames - The names of the internal Sentry packages to pin to the packed tarballs. | ||
| * @returns | ||
| */ | ||
| export async function addPnpmOverrides(tmpDirPath: string, packedDirPath: string): Promise<void> { | ||
| const packageJsonPath = path.join(tmpDirPath, 'package.json'); | ||
| const packageJson = JSON.parse(await readFile(packageJsonPath, 'utf8')) as { | ||
| pnpm?: { overrides?: Record<string, string> }; | ||
| }; | ||
|
|
||
| const overrides: Record<string, string> = {}; | ||
|
|
||
| const packageNames = getPublishedSentryTarballPackageNames(); | ||
|
|
||
| for (const packageName of packageNames) { | ||
| overrides[packageName] = `file:${packedDirPath}/${packedSymlinkFilename(packageName)}`; | ||
| } | ||
|
|
||
| const fixedOverrides = packageJson.pnpm?.overrides ?? {}; | ||
| fixFileLinkDependencies(fixedOverrides); | ||
|
|
||
| packageJson.pnpm = { | ||
| ...packageJson.pnpm, | ||
| overrides: { | ||
| ...overrides, | ||
| ...fixedOverrides, | ||
| }, | ||
| }; | ||
|
cursor[bot] marked this conversation as resolved.
|
||
|
|
||
| // oxlint-disable-next-line no-console | ||
| console.log(`Added ${packageNames.length} internal Sentry packages to pnpm.overrides`); | ||
|
|
||
| await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2)); | ||
| } | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Bug: The merge order for
pnpm.overridesis incorrect. Existing overrides frompackage.jsonare applied after the new tarball overrides, causing the new ones to be ignored on key conflicts.Severity: MEDIUM
Suggested Fix
Reverse the spread operator order in the
overridesobject to be{ ...fixedOverrides, ...overrides }. This ensures that the newly generated tarball overrides will correctly take precedence over any pre-existing overrides in the test application'spackage.json.Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.
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.
this is expected, we need to be able to override this.