Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/install-pnpm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ runs:
shell: bash
env:
PACKAGE_JSON: ${{ inputs.package-json }}
# Keep in sync with `getPnpmMajor` in `dev-packages/e2e-tests/lib/pnpmOverrides.ts`. It writes the overrides in
# Keep in sync with `getPnpmMajor` in `dev-packages/e2e-tests/lib/pnpmOverrides.mjs`. It writes the overrides in
# the format of the version it finds, so a different lookup breaks the install.
run: |
package_json="$PACKAGE_JSON"
Expand Down
21 changes: 9 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1095,11 +1095,6 @@ jobs:
uses: denoland/setup-deno@v2.0.5
with:
deno-version: ${{ matrix.deno-version || 'v2.8.3' }}
- name: Restore caches
uses: ./.github/actions/restore-cache
with:
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}

- name: Restore tarball artifacts
uses: actions/download-artifact@v8
with:
Expand All @@ -1119,6 +1114,13 @@ jobs:
name: build-layer-output
path: ${{ env.BUILD_LAYER_PATH }}

# The Lambda functions install the built workspace packages directly (see `src/stack.ts`).
- name: Restore build artifacts
uses: actions/download-artifact@v8
if: matrix.test-application == 'aws-serverless'
with:
name: build-output

# Installs Playwright while the app builds.
# Started after the artifact downloads: starting next to them made `download-artifact` fail to read the event file.
- name: Install Playwright
Expand Down Expand Up @@ -1175,7 +1177,7 @@ jobs:
- name: Pre-process E2E Test Dumps
if: failure()
run: |
node ./scripts/normalize-e2e-test-dump-transaction-events.js
node ./scripts/normalize-e2e-test-dump-transaction-events.js ${{ runner.temp }}/test-application/event-dumps

- name: Upload E2E Test Event Dumps
uses: actions/upload-artifact@v7
Expand Down Expand Up @@ -1248,11 +1250,6 @@ jobs:
uses: denoland/setup-deno@v2.0.5
with:
deno-version: ${{ matrix.deno-version || 'v2.8.3' }}
- name: Restore caches
uses: ./.github/actions/restore-cache
with:
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}

- name: Restore tarball artifacts
uses: actions/download-artifact@v8
with:
Expand Down Expand Up @@ -1308,7 +1305,7 @@ jobs:
- name: Pre-process E2E Test Dumps
if: failure()
run: |
node ./scripts/normalize-e2e-test-dump-transaction-events.js
node ./scripts/normalize-e2e-test-dump-transaction-events.js ${{ runner.temp }}/test-application/event-dumps

- name: Upload E2E Test Event Dumps
uses: actions/upload-artifact@v7
Expand Down
20 changes: 20 additions & 0 deletions dev-packages/e2e-tests/ciCopyToTemp.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// @ts-check
/* eslint-disable no-console */

import { copyToTemp } from './lib/copyToTemp.mjs';
import { applyRuntimeFiles } from './lib/runtimeFiles.mjs';

const originalPath = process.argv[2];
const tmpDirPath = process.argv[3];

if (!originalPath || !tmpDirPath) {
throw new Error('Original path and tmp dir path are required');
}

console.log(`Copying ${originalPath} to ${tmpDirPath}...`);

await copyToTemp(originalPath, tmpDirPath);

if (process.env.RUNTIME) {
applyRuntimeFiles(tmpDirPath, process.env.RUNTIME);
}
26 changes: 0 additions & 26 deletions dev-packages/e2e-tests/ciCopyToTemp.ts

This file was deleted.

12 changes: 12 additions & 0 deletions dev-packages/e2e-tests/ciPnpmOverrides.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @ts-check
import * as path from 'node:path';
import { addPnpmOverrides } from './lib/pnpmOverrides.mjs';

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));
20 changes: 0 additions & 20 deletions dev-packages/e2e-tests/ciPnpmOverrides.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
// @ts-check
/* eslint-disable no-console */
import { readFileSync, writeFileSync } from 'fs';
import { cp } from 'fs/promises';
import { isAbsolute, join, resolve } from 'path';
import { readFileSync, writeFileSync } from 'node:fs';
import { cp } from 'node:fs/promises';
import { dirname, isAbsolute, join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

export async function copyToTemp(originalPath: string, tmpDirPath: string): Promise<void> {
const __dirname = dirname(fileURLToPath(import.meta.url));

/**
* @param {string} originalPath
* @param {string} tmpDirPath
* @returns {Promise<void>}
*/
export async function copyToTemp(originalPath, tmpDirPath) {
// copy files to tmp dir
await cp(originalPath, tmpDirPath, { recursive: true });

fixPackageJson(tmpDirPath);
}

function fixPackageJson(cwd: string): void {
/**
* @param {string} cwd
*/
function fixPackageJson(cwd) {
const packageJsonPath = join(cwd, 'package.json');
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as {
dependencies?: Record<string, string>;
devDependencies?: Record<string, string>;
volta?: Record<string, unknown>;
};
/** @type {{ dependencies?: Record<string, string>; devDependencies?: Record<string, string>; volta?: Record<string, unknown> }} */
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));

// 1. Fix file dependencies
if (packageJson.dependencies) {
Expand Down Expand Up @@ -45,8 +54,11 @@ function fixPackageJson(cwd: string): void {
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
}

// Exported for pnpmOverrides as well
export function fixFileLinkDependencies(dependencyObj: Record<string, string>): void {
/**
* Exported for pnpmOverrides as well
* @param {Record<string, string>} dependencyObj
*/
export function fixFileLinkDependencies(dependencyObj) {
for (const [key, value] of Object.entries(dependencyObj)) {
const prefix = value.startsWith('link:') ? 'link:' : value.startsWith('file:') ? 'file:' : null;
if (!prefix) {
Expand Down
83 changes: 83 additions & 0 deletions dev-packages/e2e-tests/lib/packedTarballUtils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// @ts-check
import * as fs from 'node:fs';
import * as path from 'node:path';
import { fileURLToPath } from 'node:url';

const E2E_TESTS_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const REPOSITORY_ROOT = path.resolve(E2E_TESTS_ROOT, '../..');

// test-utils is not published, but test apps install it from its tarball too: with a `link:`, its dependencies would
// resolve from the monorepo's root `node_modules` instead of the app's.
const TARBALL_PACKAGE_DIRS = [
...fs.readdirSync(path.join(REPOSITORY_ROOT, 'packages')).map(dir => path.join(REPOSITORY_ROOT, 'packages', dir)),
path.join(REPOSITORY_ROOT, 'dev-packages', 'test-utils'),
];

/**
* Workspace @sentry and @sentry-internal packages that have a built tarball for the E2E version.
* @returns {{ name: string; tarballPath: string }[]} The package names and their tarball paths, sorted by name.
*/
export function getPackedTarballs() {
const version = getE2eTestsPackageVersion();
const tarballs = [];

for (const packageDir of TARBALL_PACKAGE_DIRS) {
const packageJsonPath = path.join(packageDir, 'package.json');
if (!fs.existsSync(packageJsonPath)) {
continue;
}

const name = readJson(packageJsonPath).name;
if (!name || (!name.startsWith('@sentry/') && !name.startsWith('@sentry-internal/'))) {
continue;
}

const tarballPath = path.join(packageDir, versionedTarballFilename(name, version));
if (fs.existsSync(tarballPath)) {
tarballs.push({ name, tarballPath });
}
}

return tarballs.sort((a, b) => a.name.localeCompare(b.name));
}

/**
* Stable symlink name in `packed/` (no version segment).
* @param {string} packageName
* @returns {string}
*/
export function packedSymlinkFilename(packageName) {
return `${npmPackBasename(packageName)}-packed.tgz`;
}

/**
* Versioned tarball filename produced by `npm pack` in a package directory.
* @param {string} packageName
* @param {string} version
* @returns {string}
*/
function versionedTarballFilename(packageName, version) {
return `${npmPackBasename(packageName)}-${version}.tgz`;
}

/**
* npm pack tarball basename (without version and .tgz), e.g. `@sentry/core` -> `sentry-core`.
* @param {string} packageName
* @returns {string}
*/
function npmPackBasename(packageName) {
return packageName.replace(/^@/, '').replace(/\//g, '-');
}

/**
* @param {string} filePath
* @returns {any}
*/
function readJson(filePath) {
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
}

/** @returns {string} */
export function getE2eTestsPackageVersion() {
return readJson(path.join(E2E_TESTS_ROOT, 'package.json')).version;
}
64 changes: 0 additions & 64 deletions dev-packages/e2e-tests/lib/packedTarballUtils.ts

This file was deleted.

Loading
Loading