GeezerVison is showing github.com — test(e2e): Run nestjs-12 on Bun, Deno and Cloudflare (#26283) · getsentry/sentry-javascript@8832e97
File treeExpand file treeCollapse file tree Open diff view settings test-applications/nestjs-12
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/actions/prepare-e2e-test/action.yml +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 9 | 9 | runtime: | 10 | 10 | description: 'The `runtime` of a runtime variant, see dev-packages/e2e-tests/README.md.' | 11 | 11 | default: '' | | 12 | + bun-version: | | 13 | + description: 'The Bun version to install, if the application needs Bun.' | | 14 | + default: '1.3.14' | 12 | 15 | deno-version: | 13 | 16 | description: 'The Deno version to install, if the application needs Deno.' | 14 | 17 | default: 'v2.8.3' | | 32 | 35 | == 'bun' | 33 | 36 | uses: oven-sh/setup-bun@v2 | 34 | 37 | with: | 35 | | - bun-version: '1.3.14' | | 38 | + bun-version: ${{ inputs.bun-version || '1.3.14' }} | 36 | 39 | - name: Set up AWS SAM | 37 | 40 | if: contains(inputs.test-application, 'aws-serverless') | 38 | 41 | uses: aws-actions/setup-sam@v3 | |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/build.yml +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1084,6 +1084,7 @@ jobs: | 1084 | 1084 | with: | 1085 | 1085 | test-application: ${{ matrix.test-application }} | 1086 | 1086 | runtime: ${{ matrix.runtime }} | | 1087 | + bun-version: ${{ matrix.bun-version }} | 1087 | 1088 | deno-version: ${{ matrix.deno-version }} | 1088 | 1089 |
| 1089 | 1090 | # Installs Playwright while the app builds. Keep it right before the build: the runner sets up a background | |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/canary.yml +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -101,6 +101,7 @@ jobs: | 101 | 101 | with: | 102 | 102 | test-application: ${{ matrix.test-application }} | 103 | 103 | runtime: ${{ matrix.runtime }} | | 104 | + bun-version: ${{ matrix.bun-version }} | 104 | 105 | deno-version: ${{ matrix.deno-version }} | 105 | 106 |
| 106 | 107 | - name: Build E2E app | |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/optional-e2e.yml +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 79 | 79 | with: | 80 | 80 | test-application: ${{ matrix.test-application }} | 81 | 81 | runtime: ${{ matrix.runtime }} | | 82 | + bun-version: ${{ matrix.bun-version }} | 82 | 83 | deno-version: ${{ matrix.deno-version }} | 83 | 84 | artifacts-run-id: ${{ inputs.build_run_id }} | 84 | 85 | github-token: ${{ github.token }} | |
Collapse file Copy file name to clipboardExpand all lines: dev-packages/e2e-tests/README.md +5-2Lines changed: 5 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -207,10 +207,13 @@ is the reference setup. | 207 | 207 | replaces `vite.config.ts`. For a variant with `runtime`, the runner copies these files over the others in the | 208 | 208 | temporary copy of the app, before the build. This needs no framework or bundler config. A build in the app folder | 209 | 209 | itself does not get these files, so run a variant with `pnpm run test:run <app> --variant <runtime>`. | 210 | | -- **Deno version**: a variant can pin the Deno version, for example `"deno-version": "v2.9.0"`. | | 210 | +- **Bun and Deno versions**: a variant can pin the Bun or Deno version, for example `"bun-version": "1.4.4"` or | | 211 | + `"deno-version": "v2.9.0"`. | 211 | 212 | - **Bun**: under `bun run` the SDK cannot inject diagnostics channels into packages that stay outside the build (for | 212 | 213 | example Express behind `react-router-serve`), so those produce no spans on Bun. Where a test depends on them, branch | 213 | | - on `RUNTIME` and say why in a comment. | | 214 | + on `RUNTIME` and say why in a comment. An app that starts its own server can instead bundle it with | | 215 | + `@sentry/bun/plugin`, as `nestjs-12/bun-build.mjs` does. Bun 1.3 renames classes in bundles (`class Foo2`), which | | 216 | + changes span names taken from class names, so `nestjs-12` pins Bun 1.4 (see #26289). | 214 | 217 |
| 215 | 218 | ```json | 216 | 219 | "sentryTest": { | |
Collapse file Copy file name to clipboardExpand all lines: dev-packages/e2e-tests/test-applications/nestjs-12/.gitignore +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | # compiled output | 2 | 2 | /dist | | 3 | +/dist-bun | | 4 | +/dist-cloudflare | | 5 | +/.wrangler | 3 | 6 | /node_modules | 4 | 7 | /build | 5 | 8 |
| |
Collapse file Copy file name to clipboard +23Lines changed: 23 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// Bundles the `nest build` output with `@sentry/bun/plugin`. Under `bun run` the SDK cannot inject | | 2 | +// diagnostics channels into packages, so only a bundled app gets the Nest and Express spans. | | 3 | +import { sentryBunPlugin } from '@sentry/bun/plugin'; | | 4 | +import { join } from 'node:path'; | | 5 | + | | 6 | +await Bun.build({ | | 7 | + entrypoints: [join(import.meta.dir, 'dist/main.js')], | | 8 | + target: 'bun', | | 9 | + outdir: join(import.meta.dir, 'dist-bun'), | | 10 | + // The bundler resolves Nest's optional `require` calls at build time. `@nestjs/websockets`, | | 11 | + // `class-transformer`, `class-validator` and `cache-manager` are not installed. `@nestjs/microservices` | | 12 | + // is installed for `RpcException`, but it loads transports (`kafkajs`, `@grpc/grpc-js`, ...) that are not. | | 13 | + external: [ | | 14 | + '@nestjs/microservices', | | 15 | + '@nestjs/microservices/*', | | 16 | + '@nestjs/websockets', | | 17 | + '@nestjs/websockets/*', | | 18 | + 'class-transformer', | | 19 | + 'class-validator', | | 20 | + 'cache-manager', | | 21 | + ], | | 22 | + plugins: [sentryBunPlugin({ telemetry: false })], | | 23 | +}); |
Collapse file Copy file name to clipboard +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +{ | | 2 | + "imports": { | | 3 | + "@sentry/deno/import": "./node_modules/@sentry/deno/build/import.mjs" | | 4 | + }, | | 5 | + "nodeModulesDir": "manual" | | 6 | +} |
Collapse file Copy file name to clipboardExpand all lines: dev-packages/e2e-tests/test-applications/nestjs-12/package.json +28-1Lines changed: 28 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 6 | 6 | "scripts": { | 7 | 7 | "build": "nest build", | 8 | 8 | "start": "node --import ./dist/instrument.js dist/main.js", | | 9 | + "start:bun": "bun dist-bun/main.js", | | 10 | + "start:deno": "deno run -A --preload=@sentry/deno/import --preload=./dist/instrument.js dist/main.js", | | 11 | + "start:cloudflare": "wrangler dev --config ./dist-cloudflare/nestjs_12/wrangler.json --port 3030", | 9 | 12 | "start:dev": "nest start --watch", | 10 | 13 | "start:debug": "nest start --debug --watch", | 11 | 14 | "start:prod": "node dist/main", | 12 | 15 | "clean": "npx rimraf node_modules pnpm-lock.yaml", | 13 | 16 | "test": "playwright test", | 14 | 17 | "test:build": "pnpm install && pnpm build", | | 18 | + "test:build:bun": "pnpm install && pnpm build && bun ./bun-build.mjs", | | 19 | + "test:build:cloudflare": "pnpm install && pnpm build && vite build", | 15 | 20 | "test:build-latest": "pnpm install && pnpm add @nestjs/common@latest @nestjs/core@latest @nestjs/platform-express@latest @nestjs/microservices@latest && pnpm add -D @nestjs/cli@latest && pnpm build", | 16 | 21 | "test:assert": "pnpm test" | 17 | 22 | }, | | 21 | 26 | "@nestjs/microservices": "^12.0.0", | 22 | 27 | "@nestjs/schedule": "^12.0.0", | 23 | 28 | "@nestjs/platform-express": "^12.0.0", | | 29 | + "@sentry/bun": "file:../../packed/sentry-bun-packed.tgz", | | 30 | + "@sentry/cloudflare": "file:../../packed/sentry-cloudflare-packed.tgz", | | 31 | + "@sentry/deno": "file:../../packed/sentry-deno-packed.tgz", | 24 | 32 | "@sentry/nestjs": "file:../../packed/sentry-nestjs-packed.tgz", | 25 | 33 | "reflect-metadata": "^0.2.0", | 26 | 34 | "rxjs": "^7.8.1" | | 32 | 40 | "@nestjs/schematics": "^12.0.0", | 33 | 41 | "@types/express": "^5.0.0", | 34 | 42 | "@types/node": "^22.0.0", | 35 | | - "typescript": "~5.9.0" | | 43 | + "typescript": "~5.9.0", | | 44 | + "@cloudflare/vite-plugin": "^1.47.0", | | 45 | + "vite": "^8.1.5", | | 46 | + "wrangler": "^4.120.0" | 36 | 47 | }, | 37 | 48 | "sentryTest": { | 38 | 49 | "optionalVariants": [ | 39 | 50 | { | 40 | 51 | "build-command": "pnpm test:build-latest", | 41 | 52 | "label": "nestjs-12 (latest)" | | 53 | + }, | | 54 | + { | | 55 | + "runtime": "bun", | | 56 | + "bun-version": "1.4.4", | | 57 | + "build-command": "pnpm test:build:bun", | | 58 | + "label": "nestjs-12 (bun)" | | 59 | + }, | | 60 | + { | | 61 | + "runtime": "deno", | | 62 | + "deno-version": "v2.9.0", | | 63 | + "label": "nestjs-12 (deno)" | | 64 | + }, | | 65 | + { | | 66 | + "runtime": "cloudflare", | | 67 | + "build-command": "pnpm test:build:cloudflare", | | 68 | + "label": "nestjs-12 (cloudflare)" | 42 | 69 | } | 43 | 70 | ] | 44 | 71 | } | |
Collapse file Copy file name to clipboard +9-2Lines changed: 9 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import { getPlaywrightConfig } from '@sentry-internal/test-utils'; | | 1 | +import { getPlaywrightConfig, getRuntime } from '@sentry-internal/test-utils'; | | 2 | + | | 3 | +const startCommands = { | | 4 | + node: 'pnpm start', | | 5 | + bun: 'pnpm start:bun', | | 6 | + deno: 'pnpm start:deno', | | 7 | + cloudflare: 'pnpm start:cloudflare', | | 8 | +}; | 2 | 9 |
| 3 | 10 | const config = getPlaywrightConfig({ | 4 | | - startCommand: `pnpm start`, | | 11 | + startCommand: startCommands[getRuntime()], | 5 | 12 | }); | 6 | 13 |
| 7 | 14 | export default config; |
|