Skip to content

Commit 5acf6c2

Browse files
committed
test(deno): add deno-integration-tests
Move the `mysql` and `pg` devDeps out of the deno SDK (since we'll have many more to follow in short order) in favor of a deno-integration-tests package, similar to node-integration-tests and bun-integration-tests.
1 parent 3588b1a commit 5acf6c2

14 files changed

Lines changed: 167 additions & 32 deletions

File tree

.github/workflows/build.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ jobs:
172172
changed_bun_integration:
173173
${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected,
174174
'@sentry-internal/bun-integration-tests') }}
175+
changed_deno_integration:
176+
${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected,
177+
'@sentry-internal/deno-integration-tests') }}
175178
changed_browser_integration:
176179
${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected,
177180
'@sentry-internal/browser-integration-tests') }}
@@ -966,6 +969,36 @@ jobs:
966969
working-directory: dev-packages/bun-integration-tests
967970
run: yarn test
968971

972+
job_deno_integration_tests:
973+
name: Deno Integration Tests
974+
needs: [job_get_metadata, job_build]
975+
if: needs.job_build.outputs.changed_deno_integration == 'true' || github.event_name != 'pull_request'
976+
runs-on: ubuntu-24.04
977+
timeout-minutes: 15
978+
steps:
979+
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
980+
uses: actions/checkout@v6
981+
with:
982+
ref: ${{ env.HEAD_COMMIT }}
983+
- name: Set up Node
984+
uses: actions/setup-node@v6
985+
with:
986+
node-version-file: 'package.json'
987+
- name: Set up Deno
988+
uses: denoland/setup-deno@v2.0.4
989+
with:
990+
deno-version: 'v2.8.0'
991+
- name: Restore caches
992+
uses: ./.github/actions/restore-cache
993+
with:
994+
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
995+
- name: Build @sentry/deno
996+
working-directory: packages/deno
997+
run: yarn build
998+
- name: Run integration tests
999+
working-directory: dev-packages/deno-integration-tests
1000+
run: yarn test
1001+
9691002
job_build_tarballs:
9701003
name: Build tarballs
9711004
# We want to run this if:
@@ -1263,6 +1296,7 @@ jobs:
12631296
job_cloudflare_integration_tests,
12641297
job_bundler_plugin_integration_tests,
12651298
job_bun_integration_tests,
1299+
job_deno_integration_tests,
12661300
job_browser_playwright_tests,
12671301
job_browser_loader_tests,
12681302
job_e2e_tests,

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ tmp.js
5353
packages/deno/build-types
5454
packages/deno/build-test
5555
packages/deno/lib.deno.d.ts
56+
dev-packages/deno-integration-tests/lib.deno.d.ts
5657
deno.lock
5758

5859
# gatsby
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$schema": "../../node_modules/oxlint/configuration_schema.json",
3+
"extends": ["../.oxlintrc.json"],
4+
"env": {
5+
"node": true
6+
},
7+
"overrides": [
8+
{
9+
"files": ["suites/**/*.ts", "suites/**/*.mjs"],
10+
"globals": {
11+
"Deno": "readonly"
12+
},
13+
"rules": {
14+
"typescript/ban-ts-comment": [
15+
"error",
16+
{
17+
"ts-ignore": "allow-with-description",
18+
"ts-expect-error": true
19+
}
20+
],
21+
"import/first": "off"
22+
}
23+
}
24+
]
25+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "@sentry-internal/deno-integration-tests",
3+
"version": "10.63.0",
4+
"license": "MIT",
5+
"engines": {
6+
"node": ">=18"
7+
},
8+
"private": true,
9+
"scripts": {
10+
"deno-types": "node ./scripts/download-deno-types.mjs",
11+
"install:deno": "node ./scripts/install-deno.mjs",
12+
"lint": "OXLINT_TSGOLINT_DANGEROUSLY_SUPPRESS_PROGRAM_DIAGNOSTICS=true oxlint . --type-aware",
13+
"lint:fix": "OXLINT_TSGOLINT_DANGEROUSLY_SUPPRESS_PROGRAM_DIAGNOSTICS=true oxlint . --fix --type-aware",
14+
"test": "run-s install:deno deno-types test:unit",
15+
"test:unit": "deno test --allow-net --allow-read --allow-run --allow-env --no-check"
16+
},
17+
"dependencies": {
18+
"@sentry/core": "10.63.0",
19+
"@sentry/deno": "10.63.0",
20+
"mysql": "^2.18.1",
21+
"pg": "^8.22.0"
22+
},
23+
"volta": {
24+
"extends": "../../package.json"
25+
}
26+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { existsSync, writeFileSync } from 'fs';
2+
import { download } from './download.mjs';
3+
4+
if (!existsSync('lib.deno.d.ts')) {
5+
const code = await download('https://github.com/denoland/deno/releases/download/v2.8.0/lib.deno.d.ts');
6+
writeFileSync('lib.deno.d.ts', code);
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/** Download a url to a string */
2+
export async function download(url) {
3+
try {
4+
return await fetch(url).then(res => res.text());
5+
} catch (e) {
6+
// eslint-disable-next-line no-console
7+
console.error('Failed to download', url, e);
8+
process.exit(1);
9+
}
10+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { execSync } from 'child_process';
2+
3+
import { download } from './download.mjs';
4+
5+
try {
6+
execSync('deno --version', { stdio: 'inherit' });
7+
} catch {
8+
// eslint-disable-next-line no-console
9+
console.error('Deno is not installed. Installing...');
10+
if (process.platform === 'win32') {
11+
// TODO
12+
// eslint-disable-next-line no-console
13+
console.error('Please install Deno manually: https://docs.deno.com/runtime/manual/getting_started/installation');
14+
process.exit(1);
15+
} else {
16+
const script = await download('https://deno.land/x/install/install.sh');
17+
18+
try {
19+
execSync(script, { stdio: 'inherit' });
20+
} catch (e) {
21+
// eslint-disable-next-line no-console
22+
console.error('Failed to install Deno', e);
23+
process.exit(1);
24+
}
25+
}
26+
}

packages/deno/test/orchestrion-mysql/scenario.mjs renamed to dev-packages/deno-integration-tests/suites/orchestrion-mysql/scenario.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Spawned by orchestrion-mysql.test.ts via `deno run`.
1+
// Spawned by test.ts via `deno run`.
22
//
33
// Importing `@sentry/deno/import` FIRST registers the orchestrion module hook,
44
// so the subsequent `mysql` import is transformed to publish to the

packages/deno/test/orchestrion-mysql.test.ts renamed to dev-packages/deno-integration-tests/suites/orchestrion-mysql/test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
import { tracingChannel } from 'node:diagnostics_channel';
44
import type { TransactionEvent } from '@sentry/core';
5+
import type { DenoClient } from '@sentry/deno';
6+
import { getCurrentScope, getGlobalScope, getIsolationScope, init, startSpan } from '@sentry/deno';
57
import { assert } from 'https://deno.land/std@0.212.0/assert/assert.ts';
68
import { assertEquals } from 'https://deno.land/std@0.212.0/assert/assert_equals.ts';
79
import { assertExists } from 'https://deno.land/std@0.212.0/assert/assert_exists.ts';
8-
import type { DenoClient } from '../build/esm/index.js';
9-
import { getCurrentScope, getGlobalScope, getIsolationScope, init, startSpan } from '../build/esm/index.js';
1010

1111
function resetGlobals(): void {
1212
getCurrentScope().clear();
@@ -65,10 +65,11 @@ Deno.test('denoMysqlIntegration: included in default integrations (Deno 2.8.0+)'
6565
// import inside the entry graph in Deno 2.8.0 through 2.8.2.
6666
// TODO: revisit a `--import` or `--preload` approach once Deno 2.8.3 ships.
6767
Deno.test('@sentry/deno/import: transforms mysql so it publishes the orchestrion channel', async () => {
68-
const scenario = new URL('./orchestrion-mysql/scenario.mjs', import.meta.url);
68+
const scenario = new URL('./scenario.mjs', import.meta.url);
6969

70-
// packages/deno — where node_modules resolves
71-
const cwd = new URL('../', import.meta.url);
70+
// The package root — where `node_modules` (and thus `@sentry/deno` / `mysql`)
71+
// resolves for the spawned `deno run`.
72+
const cwd = new URL('../../', import.meta.url);
7273

7374
const command = new Deno.Command('deno', {
7475
args: ['run', '--allow-all', scenario.pathname],

packages/deno/test/orchestrion-postgres/scenario.mjs renamed to dev-packages/deno-integration-tests/suites/orchestrion-postgres/scenario.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Spawned by orchestrion-postgres.test.ts via `deno run`.
1+
// Spawned by test.ts via `deno run`.
22
//
33
// Importing `@sentry/deno/import` FIRST registers the orchestrion module hook,
44
// so the subsequent `pg` import is transformed to publish to the

0 commit comments

Comments
 (0)