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
12 changes: 12 additions & 0 deletions dev-packages/e2e-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,18 @@ The required E2E jobs run on 2 vCPUs (`namespace-profile-sentry-javascript-small
about 90 seconds, set `"sentryTest": { "runner": "namespace-profile-sentry-javascript" }` to run it and its variants on
4 vCPUs.

Variants that build against upstream prereleases (for example `canary`, `next` or nightly builds of a framework) go into
`canaryVariants`. They do not run on PRs, only in the nightly `CI: Canary Tests` workflow (`.github/workflows/canary.yml`),
so failures caused by an upstream prerelease do not show up on unrelated PRs. Run one locally with
`pnpm run test:run <app> --variant <label>`. Variants that build against the `latest` release belong in
`optionalVariants`.

```json
"sentryTest": {
"canaryVariants": [{ "build-command": "pnpm test:build-canary", "label": "my-app (canary)" }]
}
```

If you add Sentry dependencies to your test application, set the dependency versions to `latest || *` in order
for it to work with both regular and prerelease versions:

Expand Down
34 changes: 23 additions & 11 deletions dev-packages/e2e-tests/lib/getTestMatrix.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,42 @@ import { parseArgs } from 'node:util';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

const VARIANT_FIELDS = {
required: 'variants',
optional: 'optionalVariants',
canary: 'canaryVariants',
};

/**
* Generates a matrix for the GitHub Actions workflow to run the E2E tests.
* Checks which test applications are affected by the current changes in the PR and then generates a matrix
* including all test apps that have at least one dependency that was changed in the PR.
* If no `--base=xxx` is provided, it will output all test applications.
*
* If `--optional=true` is set, it will generate a matrix of optional test applications only.
* Otherwise, these will be skipped.
* `--variant` selects which matrix to generate:
* - not set: the required test applications and their `variants`
* - `optional`: the optional test applications and the `optionalVariants` of all test applications
* - `canary`: only the `canaryVariants` of all test applications
*/
function run() {
const { values } = parseArgs({
args: process.argv.slice(2),
options: {
base: { type: 'string' },
head: { type: 'string' },
optional: { type: 'string', default: 'false' },
variant: { type: 'string', default: 'required' },
},
});

const { base, head = 'HEAD', optional } = values;
const { base, head = 'HEAD', variant } = values;

// For GitHub Action debugging
// eslint-disable-next-line no-console
console.error(`Parsed command line arguments: base=${base}, head=${head}, optional=${optional}`);
console.error(`Parsed command line arguments: base=${base}, head=${head}, variant=${variant}`);

if (!Object.hasOwn(VARIANT_FIELDS, variant)) {
throw new Error(`Unknown --variant=${variant}, expected one of: ${Object.keys(VARIANT_FIELDS).join(', ')}`);
}

const testApplications = discoverTestApplicationDirs();

Expand All @@ -43,11 +55,10 @@ function run() {
? getAffectedTestApplications(testApplications, { base, head })
: testApplications;

const optionalMode = optional === 'true';
const includes = [];

includedTestApplications.forEach(testApp => {
addIncludesForTestApp(testApp, includes, { optionalMode });
addIncludesForTestApp(testApp, includes, { variant });
});

// We print this to the output, so the GHA can use it for the matrix
Expand All @@ -66,21 +77,22 @@ function discoverTestApplicationDirs() {
.sort();
}

function addIncludesForTestApp(testApp, includes, { optionalMode }) {
function addIncludesForTestApp(testApp, includes, { variant }) {
const packageJson = getPackageJson(testApp);

const shouldSkip = packageJson.sentryTest?.skip || false;
const isOptional = packageJson.sentryTest?.optional || false;
const variants = (optionalMode ? packageJson.sentryTest?.optionalVariants : packageJson.sentryTest?.variants) || [];
const variants = packageJson.sentryTest?.[VARIANT_FIELDS[variant]] || [];
const runner = packageJson.sentryTest?.runner;
const baseInclude = { 'test-application': testApp, ...(runner ? { runner } : {}) };

if (shouldSkip) {
return;
}

// Add the basic test-application itself, if it is in the current mode
if (optionalMode === isOptional) {
// The test application itself is either required or optional, never canary, and only runs in the matrix of its mode.
const appVariant = isOptional ? 'optional' : 'required';
if (appVariant === variant) {
includes.push(baseInclude);
}

Expand Down
3 changes: 2 additions & 1 deletion dev-packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"test:validate": "node validate-packed-tarball-setup.mjs",
"clean": "rimraf tmp node_modules packed && pnpm run clean:test-applications && pnpm run clean:pnpm",
"ci:build-matrix": "node ./lib/getTestMatrix.mjs",
"ci:build-matrix-optional": "node ./lib/getTestMatrix.mjs --optional=true",
"ci:build-matrix-optional": "node ./lib/getTestMatrix.mjs --variant=optional",
"ci:build-matrix-canary": "node ./lib/getTestMatrix.mjs --variant=canary",
"ci:copy-to-temp": "node ./ciCopyToTemp.mjs",
"ci:pnpm-overrides": "node ./ciPnpmOverrides.mjs",
"clean:test-applications": "rimraf --glob test-applications/**/{node_modules,dist,build,.next,.nuxt,.sveltekit,.react-router,.astro,.output,pnpm-lock.yaml,.last-run.json,test-results,.angular}",
Expand Down
3 changes: 2 additions & 1 deletion dev-packages/e2e-tests/run.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
* @typedef {{ 'build-command': string; 'assert-command'?: string; label?: string; skip?: boolean; runtime?: string }} SentryTestVariant
*/

/** @typedef {{ sentryTest?: { variants?: SentryTestVariant[]; optionalVariants?: SentryTestVariant[] } }} PackageJson */
/** @typedef {{ sentryTest?: { variants?: SentryTestVariant[]; optionalVariants?: SentryTestVariant[]; canaryVariants?: SentryTestVariant[] } }} PackageJson */

const DEFAULT_DSN = 'https://username@domain/123';
const DEFAULT_SENTRY_ORG_SLUG = 'sentry-javascript-sdks';
Expand Down Expand Up @@ -100,6 +100,7 @@ async function getVariantBuildCommand(packageJsonPath, variantLabel, testAppPath
const allVariants = [
...(packageJson.sentryTest?.variants || []),
...(packageJson.sentryTest?.optionalVariants || []),
...(packageJson.sentryTest?.canaryVariants || []),
];

const matchingVariant = findMatchingVariant(allVariants, variantLabel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
"typescript": "~6.0.0"
},
"sentryTest": {
"optionalVariants": [
"canaryVariants": [
{
"build-command": "pnpm test:build-canary",
"label": "angular (canary)"
"label": "angular-21 (canary)"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
"typescript": "~6.0.0"
},
"sentryTest": {
"optionalVariants": [
"canaryVariants": [
{
"build-command": "pnpm test:build-canary",
"label": "angular (canary)"
"label": "angular-22 (canary)"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,13 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"sentryTest": {
"canaryVariants": [
{
"build-command": "pnpm test:build-canary",
"label": "create-react-app (canary)"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,13 @@
"ts-loader": "^9.4.3",
"tsconfig-paths": "^4.2.0",
"typescript": "~5.9.0"
},
"sentryTest": {
"optionalVariants": [
{
"build-command": "pnpm test:build-latest",
"label": "nestjs-12 (latest)"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@
},
"sentryTest": {
"optionalVariants": [
{
"build-command": "pnpm test:build-canary",
"label": "nextjs-14 (canary)"
},
{
"build-command": "pnpm test:build-latest",
"label": "nextjs-14 (latest)"
}
],
"canaryVariants": [
{
"build-command": "pnpm test:build-canary",
"label": "nextjs-14 (canary)"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"assert-command": "pnpm test:assert"
}
],
"optionalVariants": [
"canaryVariants": [
{
"build-command": "pnpm test:build-canary",
"label": "nextjs-16-standalone (canary, turbopack)",
Expand Down
22 changes: 12 additions & 10 deletions dev-packages/e2e-tests/test-applications/nextjs-16/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,6 @@
}
],
"optionalVariants": [
{
"build-command": "pnpm test:build-canary",
"label": "nextjs-16 (canary, turbopack)",
"assert-command": "pnpm test:assert"
},
{
"build-command": "pnpm test:build-canary-webpack",
"label": "nextjs-16 (canary, webpack)",
"assert-command": "pnpm test:assert-webpack"
},
{
"runtime": "cloudflare",
"build-command": "pnpm test:build-latest:cloudflare",
Expand All @@ -126,6 +116,18 @@
"assert-command": "pnpm test:assert:vinext",
"label": "nextjs-16 (vinext, bun)"
}
],
"canaryVariants": [
{
"build-command": "pnpm test:build-canary",
"label": "nextjs-16 (canary, turbopack)",
"assert-command": "pnpm test:assert"
},
{
"build-command": "pnpm test:build-canary-webpack",
"label": "nextjs-16 (canary, webpack)",
"assert-command": "pnpm test:assert-webpack"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz"
},
"sentryTest": {
"optionalVariants": [
"canaryVariants": [
{
"build-command": "pnpm test:build-canary",
"label": "nuxt-3 (canary)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"label": "nuxt-4-static (tracer provider)"
}
],
"optionalVariants": [
"canaryVariants": [
{
"build-command": "pnpm test:build-canary",
"label": "nuxt-4-static (canary)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"label": "nuxt-4 (tunnel-basepath-dev)"
}
],
"optionalVariants": [
"canaryVariants": [
{
"build-command": "pnpm test:build-canary",
"label": "nuxt-4 (canary)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,13 @@
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
"serve": "14.0.1"
},
"sentryTest": {
"canaryVariants": [
{
"build-command": "pnpm test:build-canary",
"label": "react-create-hash-router (canary)"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
"npm-run-all2": "^6.2.0"
},
"sentryTest": {
"runner": "namespace-profile-sentry-javascript"
"runner": "namespace-profile-sentry-javascript",
"canaryVariants": [
{
"build-command": "pnpm test:build-canary",
"label": "react-router-6 (canary)"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@
"build-command": "pnpm install",
"assert-command": "pnpm test:assert:tunnel-basepath-dev"
}
],
"optionalVariants": [
{
"build-command": "pnpm test:build-latest",
"label": "tanstackstart-react (latest)"
}
]
}
}
10 changes: 6 additions & 4 deletions dev-packages/e2e-tests/test-applications/vue-3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,17 @@
}
],
"optionalVariants": [
{
"build-command": "pnpm test:build-canary",
"label": "vue-3 (canary)"
},
{
"build-command": "pnpm test:build-no-options-api",
"assert-command": "pnpm test:assert-no-options-api",
"label": "vue-3 (no Options API)"
}
],
"canaryVariants": [
{
"build-command": "pnpm test:build-canary",
"label": "vue-3 (canary)"
}
]
}
}
Loading