Skip to content

Commit 54823eb

Browse files
committed
test(deno): add deno-integration-tests
Move the 'mysql' devDep 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 54e995d commit 54823eb

12 files changed

Lines changed: 147 additions & 12 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') }}
@@ -953,6 +956,36 @@ jobs:
953956
working-directory: dev-packages/bun-integration-tests
954957
run: yarn test
955958

959+
job_deno_integration_tests:
960+
name: Deno Integration Tests
961+
needs: [job_get_metadata, job_build]
962+
if: needs.job_build.outputs.changed_deno_integration == 'true' || github.event_name != 'pull_request'
963+
runs-on: ubuntu-24.04
964+
timeout-minutes: 15
965+
steps:
966+
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
967+
uses: actions/checkout@v6
968+
with:
969+
ref: ${{ env.HEAD_COMMIT }}
970+
- name: Set up Node
971+
uses: actions/setup-node@v6
972+
with:
973+
node-version-file: 'package.json'
974+
- name: Set up Deno
975+
uses: denoland/setup-deno@v2.0.4
976+
with:
977+
deno-version: 'v2.8.0'
978+
- name: Restore caches
979+
uses: ./.github/actions/restore-cache
980+
with:
981+
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
982+
- name: Build @sentry/deno
983+
working-directory: packages/deno
984+
run: yarn build
985+
- name: Run integration tests
986+
working-directory: dev-packages/deno-integration-tests
987+
run: yarn test
988+
956989
job_build_tarballs:
957990
name: Build tarballs
958991
# We want to run this if:
@@ -1252,6 +1285,7 @@ jobs:
12521285
job_cloudflare_integration_tests,
12531286
job_bundler_plugin_integration_tests,
12541287
job_bun_integration_tests,
1288+
job_deno_integration_tests,
12551289
job_browser_playwright_tests,
12561290
job_browser_loader_tests,
12571291
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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "@sentry-internal/deno-integration-tests",
3+
"version": "10.62.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.62.0",
19+
"@sentry/deno": "10.62.0",
20+
"mysql": "^2.18.1"
21+
},
22+
"volta": {
23+
"extends": "../../package.json"
24+
}
25+
}
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],
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"include": ["./lib.deno.d.ts", "suites/**/*"],
4+
"compilerOptions": {
5+
"lib": ["esnext"],
6+
"target": "esnext"
7+
}
8+
}

0 commit comments

Comments
 (0)