-
Notifications
You must be signed in to change notification settings - Fork 56
test: Isolate integration test package installs #902
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 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* eslint-disable no-console */ | ||
| import { promises as fs } from "fs"; | ||
| import { join } from "path"; | ||
| import { fileURLToPath } from "url"; | ||
| import { execSync } from "child_process"; | ||
|
|
||
| console.log("Installing all dependencies for fixtures..."); | ||
|
|
||
| const __dirname = fileURLToPath(new URL(".", import.meta.url)); | ||
| const fixturesDir = join(__dirname, "fixtures"); | ||
| const entries = await fs.readdir(fixturesDir, { withFileTypes: true }); | ||
|
|
||
| // Get all directories | ||
| const directories = entries | ||
| .filter((entry) => entry.isDirectory()) | ||
| .map((entry) => join(fixturesDir, entry.name)); | ||
|
|
||
| for (const dir of directories) { | ||
| try { | ||
| const packageJson = await fs.readFile(join(dir, "package.json"), { encoding: "utf-8" }); | ||
| if (packageJson.length < 50) { | ||
| continue; | ||
| } | ||
| } catch { | ||
| continue; | ||
| } | ||
|
|
||
| execSync("pnpm install", { | ||
| cwd: dir, | ||
| stdio: "inherit", | ||
| }); | ||
| } | ||
|
|
||
| console.log("All fixture dependencies installed successfully!"); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,48 @@ function bumpVersions(rootDir, newVersion) { | |
| return workspacePackages.length; | ||
| } | ||
|
|
||
| /** | ||
| * The test fixtures have their own pnpm installs with overrides that point to the local tarballs. | ||
| * We need to update those overrides to point to the correct version's tarball. | ||
| */ | ||
| function bumpTestFixtureVersions(rootDir, newVersion) { | ||
| const fixturesDir = path.join(rootDir, "packages", "integration-tests-next", "fixtures"); | ||
| const entries = fs.readdirSync(fixturesDir, { withFileTypes: true }); | ||
|
|
||
| for (const entry of entries) { | ||
| if (!entry.isDirectory()) { | ||
| continue; | ||
| } | ||
|
|
||
| const pkgPath = path.join(fixturesDir, entry.name, "package.json"); | ||
| if (!fs.existsSync(pkgPath)) { | ||
| continue; | ||
| } | ||
|
|
||
| const pkg = readJson(pkgPath); | ||
| if (!pkg.dependencies) { | ||
| continue; | ||
| } | ||
|
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. Early return skips pnpm overrides path updateLow Severity The Additional Locations (1)
Collaborator
Author
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. if it doesn't have any dependencies, it wont have any overrides 🙈 |
||
|
|
||
| for (const dep of Object.keys(pkg.dependencies)) { | ||
| if (dep.startsWith("@sentry/")) { | ||
| pkg.dependencies[dep] = newVersion; | ||
| } | ||
| } | ||
|
|
||
| if (pkg?.pnpm?.overrides) { | ||
| for (const dep of Object.keys(pkg.pnpm.overrides)) { | ||
| if (dep.startsWith("@sentry/")) { | ||
| const orig = pkg.pnpm.overrides[dep]; | ||
| pkg.pnpm.overrides[dep] = orig.replace(/-\d*\.\d*\..+?\.tgz/, `-${newVersion}.tgz`); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n"); | ||
| } | ||
| } | ||
|
|
||
| // CLI entry point | ||
| if (require.main === module) { | ||
| const newVersion = process.argv[2]; | ||
|
|
@@ -75,6 +117,7 @@ if (require.main === module) { | |
|
|
||
| const rootDir = path.join(__dirname, ".."); | ||
| const updatedCount = bumpVersions(rootDir, newVersion); | ||
| bumpTestFixtureVersions(rootDir, newVersion); | ||
|
|
||
| // Write a .version file used by the gitflow sync workflow to detect version bumps | ||
| const versionFile = { | ||
|
|
||


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.
Can you add a comment on this magic number? :D
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.
I'll do this a more sensible way without magic!