Skip to content

Commit 8c0631a

Browse files
authored
test(e2e): Do not require DSN to run E2E tests (#12743)
First, this means it is easier to run this locally. Secondly, we do not even need to send data to Sentry anymore, so we can adjust the proxy server to stop doing this. Lastly, this means that we can also safely run E2E tests for external contributors. Closes #11910
1 parent dc2659c commit 8c0631a

File tree

11 files changed

+62
-81
lines changed

11 files changed

+62
-81
lines changed

.github/workflows/build.yml

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -971,22 +971,19 @@ jobs:
971971

972972
job_e2e_tests:
973973
name: E2E ${{ matrix.label || matrix.test-application }} Test
974-
# We only run E2E tests for non-fork PRs because the E2E tests require secrets to work and they can't be accessed from forks
975974
# We need to add the `always()` check here because the previous step has this as well :(
976975
# See: https://github.com/actions/runner/issues/2205
977-
if:
978-
always() && needs.job_e2e_prepare.result == 'success' &&
979-
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
976+
if: always() && needs.job_e2e_prepare.result == 'success'
980977
needs: [job_get_metadata, job_build, job_e2e_prepare]
981978
runs-on: ubuntu-20.04
982979
timeout-minutes: 10
983980
env:
984-
E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }}
985-
E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
981+
# We just use a dummy DSN here, only send to the tunnel anyhow
982+
E2E_TEST_DSN: 'https://username@domain/123'
986983
# Needed because some apps expect a certain prefix
987-
NEXT_PUBLIC_E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
988-
PUBLIC_E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
989-
REACT_APP_E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
984+
NEXT_PUBLIC_E2E_TEST_DSN: 'https://username@domain/123'
985+
PUBLIC_E2E_TEST_DSN: 'https://username@domain/123'
986+
REACT_APP_E2E_TEST_DSN: 'https://username@domain/123'
990987
E2E_TEST_SENTRY_ORG_SLUG: 'sentry-javascript-sdks'
991988
E2E_TEST_SENTRY_PROJECT: 'sentry-javascript-e2e-tests'
992989
strategy:
@@ -1072,7 +1069,7 @@ jobs:
10721069
ref: ${{ env.HEAD_COMMIT }}
10731070
- uses: pnpm/action-setup@v4
10741071
with:
1075-
version: 8.3.1
1072+
version: 9.4.0
10761073
- name: Set up Node
10771074
uses: actions/setup-node@v4
10781075
with:
@@ -1109,12 +1106,12 @@ jobs:
11091106
- name: Build E2E app
11101107
working-directory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
11111108
timeout-minutes: 5
1112-
run: yarn ${{ matrix.build-command || 'test:build' }}
1109+
run: pnpm ${{ matrix.build-command || 'test:build' }}
11131110

11141111
- name: Run E2E test
11151112
working-directory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
11161113
timeout-minutes: 5
1117-
run: yarn test:assert
1114+
run: pnpm test:assert
11181115

11191116
- name: Deploy Astro to Cloudflare
11201117
uses: cloudflare/pages-action@v1
@@ -1149,8 +1146,6 @@ jobs:
11491146
strategy:
11501147
fail-fast: false
11511148
matrix:
1152-
is_dependabot:
1153-
- ${{ github.actor == 'dependabot[bot]' }}
11541149
test-application:
11551150
[
11561151
'react-send-to-sentry',
@@ -1159,8 +1154,17 @@ jobs:
11591154
]
11601155
build-command:
11611156
- false
1157+
assert-command:
1158+
- false
11621159
label:
11631160
- false
1161+
include:
1162+
- test-application: 'create-remix-app'
1163+
assert-command: 'test:assert-sourcemaps'
1164+
label: 'create-remix-app (sourcemaps)'
1165+
- test-application: 'create-remix-app-legacy'
1166+
assert-command: 'test:assert-sourcemaps'
1167+
label: 'create-remix-app-legacy (sourcemaps)'
11641168

11651169
steps:
11661170
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
@@ -1169,7 +1173,7 @@ jobs:
11691173
ref: ${{ env.HEAD_COMMIT }}
11701174
- uses: pnpm/action-setup@v4
11711175
with:
1172-
version: 8.3.1
1176+
version: 9.4.0
11731177
- name: Set up Node
11741178
uses: actions/setup-node@v4
11751179
with:
@@ -1203,12 +1207,12 @@ jobs:
12031207
- name: Build E2E app
12041208
working-directory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
12051209
timeout-minutes: 5
1206-
run: yarn ${{ matrix.build-command || 'test:build' }}
1210+
run: pnpm ${{ matrix.build-command || 'test:build' }}
12071211

12081212
- name: Run E2E test
12091213
working-directory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
12101214
timeout-minutes: 5
1211-
run: yarn test:assert
1215+
run: pnpm ${{ matrix.assert-command || 'test:assert' }}
12121216

12131217
job_profiling_e2e_tests:
12141218
name: E2E ${{ matrix.label || matrix.test-application }} Test

.github/workflows/canary.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ jobs:
5656
runs-on: ubuntu-20.04
5757
timeout-minutes: 20
5858
env:
59-
E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }}
60-
E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
61-
# Needed because certain apps expect a certain prefix
62-
NEXT_PUBLIC_E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
63-
PUBLIC_E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
64-
REACT_APP_E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
59+
# We just use a dummy DSN here, only send to the tunnel anyhow
60+
E2E_TEST_DSN: 'https://username@domain/123'
61+
# Needed because some apps expect a certain prefix
62+
NEXT_PUBLIC_E2E_TEST_DSN: 'https://username@domain/123'
63+
PUBLIC_E2E_TEST_DSN: 'https://username@domain/123'
64+
REACT_APP_E2E_TEST_DSN: 'https://username@domain/123'
6565
E2E_TEST_SENTRY_ORG_SLUG: 'sentry-javascript-sdks'
6666
E2E_TEST_SENTRY_PROJECT: 'sentry-javascript-e2e-tests'
6767
strategy:

dev-packages/e2e-tests/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ current state.
88
Prerequisites: Docker
99

1010
- Copy `.env.example` to `.env`
11-
- Fill in auth information in `.env` for an example Sentry project
11+
- OPTIONAL: Fill in auth information in `.env` for an example Sentry project - you only need this to run E2E tests that
12+
send data to Sentry.
1213
- Run `yarn build:tarball` in the root of the repository
1314

1415
To finally run all of the tests:

dev-packages/e2e-tests/lib/validate.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

dev-packages/e2e-tests/prepare.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
/* eslint-disable no-console */
22
import * as dotenv from 'dotenv';
33

4-
import { validate } from './lib/validate';
54
import { registrySetup } from './registrySetup';
65

76
async function run(): Promise<void> {
87
// Load environment variables from .env file locally
98
dotenv.config();
109

11-
if (!validate()) {
12-
process.exit(1);
13-
}
14-
1510
try {
1611
registrySetup();
1712
} catch (error) {

dev-packages/e2e-tests/run.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ import { resolve } from 'path';
44
import * as dotenv from 'dotenv';
55
import { sync as globSync } from 'glob';
66

7-
import { validate } from './lib/validate';
87
import { registrySetup } from './registrySetup';
98

9+
const DEFAULT_DSN = 'https://username@domain/123';
10+
const DEFAULT_SENTRY_ORG_SLUG = 'sentry-javascript-sdks';
11+
const DEFAULT_SENTRY_PROJECT = 'sentry-javascript-e2e-tests';
12+
1013
function asyncExec(command: string, options: { env: Record<string, string | undefined>; cwd: string }): Promise<void> {
1114
return new Promise((resolve, reject) => {
1215
const process = spawn(command, { ...options, shell: true });
@@ -39,17 +42,21 @@ async function run(): Promise<void> {
3942
// Allow to run a single app only via `yarn test:run <app-name>`
4043
const appName = process.argv[2];
4144

42-
if (!validate()) {
43-
process.exit(1);
44-
}
45+
const dsn = process.env.E2E_TEST_DSN || DEFAULT_DSN;
4546

4647
const envVarsToInject = {
47-
NEXT_PUBLIC_E2E_TEST_DSN: process.env.E2E_TEST_DSN,
48-
PUBLIC_E2E_TEST_DSN: process.env.E2E_TEST_DSN,
49-
REACT_APP_E2E_TEST_DSN: process.env.E2E_TEST_DSN,
48+
E2E_TEST_DSN: dsn,
49+
NEXT_PUBLIC_E2E_TEST_DSN: dsn,
50+
PUBLIC_E2E_TEST_DSN: dsn,
51+
REACT_APP_E2E_TEST_DSN: dsn,
52+
E2E_TEST_SENTRY_ORG_SLUG: process.env.E2E_TEST_SENTRY_ORG_SLUG || DEFAULT_SENTRY_ORG_SLUG,
53+
E2E_TEST_SENTRY_PROJECT: process.env.E2E_TEST_SENTRY_PROJECT || DEFAULT_SENTRY_PROJECT,
5054
};
5155

52-
const env = { ...process.env, ...envVarsToInject };
56+
const env = {
57+
...process.env,
58+
...envVarsToInject,
59+
};
5360

5461
try {
5562
console.log('Cleaning test-applications...');

dev-packages/e2e-tests/test-applications/aws-lambda-layer-cjs/start-event-proxy.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ import { startEventProxyServer } from '@sentry-internal/test-utils';
33
startEventProxyServer({
44
port: 3031,
55
proxyServerName: 'aws-serverless-lambda-layer-cjs',
6-
forwardToSentry: false,
76
});

dev-packages/e2e-tests/test-applications/create-remix-app-legacy/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
"private": true,
33
"sideEffects": false,
44
"scripts": {
5-
"build": "remix build --sourcemap && ./upload-sourcemaps.sh",
5+
"build": "remix build --sourcemap",
6+
"upload-sourcemaps": "./upload-sourcemaps.sh",
67
"dev": "remix dev",
78
"start": "remix-serve build",
89
"typecheck": "tsc",
910
"clean": "npx rimraf node_modules pnpm-lock.yaml",
1011
"test:build": "pnpm install && npx playwright install && pnpm build",
11-
"test:assert": "pnpm playwright test"
12+
"test:assert": "pnpm playwright test",
13+
"test:assert-sourcemaps": "pnpm upload-sourcemaps"
1214
},
1315
"dependencies": {
1416
"@sentry/remix": "latest || *",

dev-packages/e2e-tests/test-applications/create-remix-app/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
"private": true,
33
"sideEffects": false,
44
"scripts": {
5-
"build": "remix build --sourcemap && ./upload-sourcemaps.sh",
5+
"build": "remix build --sourcemap",
6+
"upload-sourcemaps": "./upload-sourcemaps.sh",
67
"dev": "remix dev",
78
"start": "NODE_OPTIONS='--require=./instrument.server.cjs' remix-serve build",
89
"typecheck": "tsc",
910
"clean": "npx rimraf node_modules pnpm-lock.yaml",
1011
"test:build": "pnpm install && npx playwright install && pnpm build",
11-
"test:assert": "pnpm playwright test"
12+
"test:assert": "pnpm playwright test",
13+
"test:assert-sourcemaps": "pnpm upload-sourcemaps"
1214
},
1315
"dependencies": {
1416
"@sentry/remix": "latest || *",

dev-packages/e2e-tests/test-applications/react-19/src/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import Index from './pages/Index';
66

77
Sentry.init({
88
environment: 'qa', // dynamic sampling bias to keep transactions
9-
dsn:
10-
process.env.REACT_APP_E2E_TEST_DSN ||
11-
'https://3b6c388182fb435097f41d181be2b2ba@o4504321058471936.ingest.sentry.io/4504321066008576',
9+
dsn: process.env.REACT_APP_E2E_TEST_DSN,
1210
release: 'e2e-test',
1311
tunnel: 'http://localhost:3031/', // proxy server
1412
});

dev-packages/test-utils/src/event-proxy-server.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface EventProxyServerOptions {
1919
/** The name for the proxy server used for referencing it with listener functions */
2020
proxyServerName: string;
2121
/**
22-
* Whether or not to forward the event to sentry. @default `true`
22+
* Whether or not to forward the event to sentry. @default `false`
2323
* This is helpful when you can't register a tunnel in the SDK setup (e.g. lambda layer without Sentry.init call)
2424
*/
2525
forwardToSentry?: boolean;
@@ -172,7 +172,7 @@ export async function startEventProxyServer(options: EventProxyServerOptions): P
172172
await startProxyServer(options, async (eventCallbackListeners, proxyRequest, proxyRequestBody, eventBuffer) => {
173173
const envelopeHeader: EnvelopeItem[0] = JSON.parse(proxyRequestBody.split('\n')[0] as string);
174174

175-
const shouldForwardEventToSentry = options.forwardToSentry != null ? options.forwardToSentry : true;
175+
const shouldForwardEventToSentry = options.forwardToSentry || false;
176176

177177
if (!envelopeHeader.dsn && shouldForwardEventToSentry) {
178178
// eslint-disable-next-line no-console
@@ -195,7 +195,13 @@ export async function startEventProxyServer(options: EventProxyServerOptions): P
195195
listener(Buffer.from(JSON.stringify(data)).toString('base64'));
196196
});
197197

198-
return [200, '{}', {}];
198+
return [
199+
200,
200+
'{}',
201+
{
202+
'Access-Control-Allow-Origin': '*',
203+
},
204+
];
199205
}
200206

201207
const { origin, pathname, host } = new URL(envelopeHeader.dsn as string);

0 commit comments

Comments
 (0)