Skip to content

Commit

Permalink
Merge branch 'develop' into sig/delete-getStack
Browse files Browse the repository at this point in the history
  • Loading branch information
s1gr1d authored Jul 4, 2024
2 parents 8aad058 + 4018f80 commit 0c58f20
Show file tree
Hide file tree
Showing 18 changed files with 433 additions and 300 deletions.
38 changes: 21 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -971,22 +971,19 @@ jobs:

job_e2e_tests:
name: E2E ${{ matrix.label || matrix.test-application }} Test
# 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
# We need to add the `always()` check here because the previous step has this as well :(
# See: https://github.com/actions/runner/issues/2205
if:
always() && needs.job_e2e_prepare.result == 'success' &&
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
if: always() && needs.job_e2e_prepare.result == 'success'
needs: [job_get_metadata, job_build, job_e2e_prepare]
runs-on: ubuntu-20.04
timeout-minutes: 10
env:
E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }}
E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
# We just use a dummy DSN here, only send to the tunnel anyhow
E2E_TEST_DSN: 'https://username@domain/123'
# Needed because some apps expect a certain prefix
NEXT_PUBLIC_E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
PUBLIC_E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
REACT_APP_E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
NEXT_PUBLIC_E2E_TEST_DSN: 'https://username@domain/123'
PUBLIC_E2E_TEST_DSN: 'https://username@domain/123'
REACT_APP_E2E_TEST_DSN: 'https://username@domain/123'
E2E_TEST_SENTRY_ORG_SLUG: 'sentry-javascript-sdks'
E2E_TEST_SENTRY_PROJECT: 'sentry-javascript-e2e-tests'
strategy:
Expand Down Expand Up @@ -1072,7 +1069,7 @@ jobs:
ref: ${{ env.HEAD_COMMIT }}
- uses: pnpm/action-setup@v4
with:
version: 8.3.1
version: 9.4.0
- name: Set up Node
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -1109,12 +1106,12 @@ jobs:
- name: Build E2E app
working-directory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
timeout-minutes: 5
run: yarn ${{ matrix.build-command || 'test:build' }}
run: pnpm ${{ matrix.build-command || 'test:build' }}

- name: Run E2E test
working-directory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
timeout-minutes: 5
run: yarn test:assert
run: pnpm test:assert

- name: Deploy Astro to Cloudflare
uses: cloudflare/pages-action@v1
Expand Down Expand Up @@ -1149,8 +1146,6 @@ jobs:
strategy:
fail-fast: false
matrix:
is_dependabot:
- ${{ github.actor == 'dependabot[bot]' }}
test-application:
[
'react-send-to-sentry',
Expand All @@ -1159,8 +1154,17 @@ jobs:
]
build-command:
- false
assert-command:
- false
label:
- false
include:
- test-application: 'create-remix-app'
assert-command: 'test:assert-sourcemaps'
label: 'create-remix-app (sourcemaps)'
- test-application: 'create-remix-app-legacy'
assert-command: 'test:assert-sourcemaps'
label: 'create-remix-app-legacy (sourcemaps)'

steps:
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
Expand All @@ -1169,7 +1173,7 @@ jobs:
ref: ${{ env.HEAD_COMMIT }}
- uses: pnpm/action-setup@v4
with:
version: 8.3.1
version: 9.4.0
- name: Set up Node
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -1203,12 +1207,12 @@ jobs:
- name: Build E2E app
working-directory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
timeout-minutes: 5
run: yarn ${{ matrix.build-command || 'test:build' }}
run: pnpm ${{ matrix.build-command || 'test:build' }}

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

job_profiling_e2e_tests:
name: E2E ${{ matrix.label || matrix.test-application }} Test
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ jobs:
runs-on: ubuntu-20.04
timeout-minutes: 20
env:
E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }}
E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
# Needed because certain apps expect a certain prefix
NEXT_PUBLIC_E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
PUBLIC_E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
REACT_APP_E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
# We just use a dummy DSN here, only send to the tunnel anyhow
E2E_TEST_DSN: 'https://username@domain/123'
# Needed because some apps expect a certain prefix
NEXT_PUBLIC_E2E_TEST_DSN: 'https://username@domain/123'
PUBLIC_E2E_TEST_DSN: 'https://username@domain/123'
REACT_APP_E2E_TEST_DSN: 'https://username@domain/123'
E2E_TEST_SENTRY_ORG_SLUG: 'sentry-javascript-sdks'
E2E_TEST_SENTRY_PROJECT: 'sentry-javascript-e2e-tests'
strategy:
Expand Down
3 changes: 2 additions & 1 deletion dev-packages/e2e-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ current state.
Prerequisites: Docker

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

To finally run all of the tests:
Expand Down
33 changes: 0 additions & 33 deletions dev-packages/e2e-tests/lib/validate.ts

This file was deleted.

5 changes: 0 additions & 5 deletions dev-packages/e2e-tests/prepare.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
/* eslint-disable no-console */
import * as dotenv from 'dotenv';

import { validate } from './lib/validate';
import { registrySetup } from './registrySetup';

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

if (!validate()) {
process.exit(1);
}

try {
registrySetup();
} catch (error) {
Expand Down
23 changes: 15 additions & 8 deletions dev-packages/e2e-tests/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import { resolve } from 'path';
import * as dotenv from 'dotenv';
import { sync as globSync } from 'glob';

import { validate } from './lib/validate';
import { registrySetup } from './registrySetup';

const DEFAULT_DSN = 'https://username@domain/123';
const DEFAULT_SENTRY_ORG_SLUG = 'sentry-javascript-sdks';
const DEFAULT_SENTRY_PROJECT = 'sentry-javascript-e2e-tests';

function asyncExec(command: string, options: { env: Record<string, string | undefined>; cwd: string }): Promise<void> {
return new Promise((resolve, reject) => {
const process = spawn(command, { ...options, shell: true });
Expand Down Expand Up @@ -39,17 +42,21 @@ async function run(): Promise<void> {
// Allow to run a single app only via `yarn test:run <app-name>`
const appName = process.argv[2];

if (!validate()) {
process.exit(1);
}
const dsn = process.env.E2E_TEST_DSN || DEFAULT_DSN;

const envVarsToInject = {
NEXT_PUBLIC_E2E_TEST_DSN: process.env.E2E_TEST_DSN,
PUBLIC_E2E_TEST_DSN: process.env.E2E_TEST_DSN,
REACT_APP_E2E_TEST_DSN: process.env.E2E_TEST_DSN,
E2E_TEST_DSN: dsn,
NEXT_PUBLIC_E2E_TEST_DSN: dsn,
PUBLIC_E2E_TEST_DSN: dsn,
REACT_APP_E2E_TEST_DSN: dsn,
E2E_TEST_SENTRY_ORG_SLUG: process.env.E2E_TEST_SENTRY_ORG_SLUG || DEFAULT_SENTRY_ORG_SLUG,
E2E_TEST_SENTRY_PROJECT: process.env.E2E_TEST_SENTRY_PROJECT || DEFAULT_SENTRY_PROJECT,
};

const env = { ...process.env, ...envVarsToInject };
const env = {
...process.env,
...envVarsToInject,
};

try {
console.log('Cleaning test-applications...');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ import { startEventProxyServer } from '@sentry-internal/test-utils';
startEventProxyServer({
port: 3031,
proxyServerName: 'aws-serverless-lambda-layer-cjs',
forwardToSentry: false,
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
"private": true,
"sideEffects": false,
"scripts": {
"build": "remix build --sourcemap && ./upload-sourcemaps.sh",
"build": "remix build --sourcemap",
"upload-sourcemaps": "./upload-sourcemaps.sh",
"dev": "remix dev",
"start": "remix-serve build",
"typecheck": "tsc",
"clean": "npx rimraf node_modules pnpm-lock.yaml",
"test:build": "pnpm install && npx playwright install && pnpm build",
"test:assert": "pnpm playwright test"
"test:assert": "pnpm playwright test",
"test:assert-sourcemaps": "pnpm upload-sourcemaps"
},
"dependencies": {
"@sentry/remix": "latest || *",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
"private": true,
"sideEffects": false,
"scripts": {
"build": "remix build --sourcemap && ./upload-sourcemaps.sh",
"build": "remix build --sourcemap",
"upload-sourcemaps": "./upload-sourcemaps.sh",
"dev": "remix dev",
"start": "NODE_OPTIONS='--require=./instrument.server.cjs' remix-serve build",
"typecheck": "tsc",
"clean": "npx rimraf node_modules pnpm-lock.yaml",
"test:build": "pnpm install && npx playwright install && pnpm build",
"test:assert": "pnpm playwright test"
"test:assert": "pnpm playwright test",
"test:assert-sourcemaps": "pnpm upload-sourcemaps"
},
"dependencies": {
"@sentry/remix": "latest || *",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"test:assert": "pnpm test"
},
"dependencies": {
"@hapi/hapi": "21.3.2",
"@hapi/boom": "10.0.1",
"@hapi/hapi": "21.3.10",
"@sentry/node": "latest || *",
"@sentry/types": "latest || *"
},
Expand Down
50 changes: 50 additions & 0 deletions dev-packages/e2e-tests/test-applications/node-hapi/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Sentry.init({
});

const Hapi = require('@hapi/hapi');
const Boom = require('@hapi/boom');

const server = Hapi.server({
port: 3030,
Expand Down Expand Up @@ -63,6 +64,55 @@ const init = async () => {
throw new Error('This is an error');
},
});

server.route({
method: 'GET',
path: '/test-failure-boom-4xx',
handler: async function (request, h) {
throw new Error('This is a JS error (boom in onPreResponse)');
},
});

server.route({
method: 'GET',
path: '/test-failure-boom-5xx',
handler: async function (request, h) {
throw new Error('This is an error (boom in onPreResponse)');
},
});

server.route({
method: 'GET',
path: '/test-failure-JS-error-onPreResponse',
handler: async function (request, h) {
throw new Error('This is an error (another JS error in onPreResponse)');
},
});

server.route({
method: 'GET',
path: '/test-failure-2xx-override-onPreResponse',
handler: async function (request, h) {
throw new Error('This is a JS error (2xx override in onPreResponse)');
},
});

// This runs after the route handler
server.ext('onPreResponse', (request, h) => {
const path = request.route.path;

if (path.includes('boom-4xx')) {
throw Boom.notFound('4xx not found (onPreResponse)');
} else if (path.includes('boom-5xx')) {
throw Boom.gatewayTimeout('5xx not implemented (onPreResponse)');
} else if (path.includes('JS-error-onPreResponse')) {
throw new Error('JS error (onPreResponse)');
} else if (path.includes('2xx-override-onPreResponse')) {
return h.response('2xx override').code(200);
} else {
return h.continue;
}
});
};

(async () => {
Expand Down
Loading

0 comments on commit 0c58f20

Please sign in to comment.