Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ jobs:
changed_bun:
${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected,
'@sentry/bun') }}
changed_bun_integration:
${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected,
'@sentry-internal/bun-integration-tests') }}
changed_browser_integration:
${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected,
'@sentry-internal/browser-integration-tests') }}
Expand Down Expand Up @@ -769,6 +772,32 @@ jobs:
working-directory: dev-packages/cloudflare-integration-tests
run: yarn test

job_bun_integration_tests:
name: Bun Integration Tests
needs: [job_get_metadata, job_build]
if: needs.job_build.outputs.changed_bun_integration == 'true' || github.event_name != 'pull_request'
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
uses: actions/checkout@v6
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version-file: 'package.json'
- name: Set up Bun
uses: oven-sh/setup-bun@v2
- name: Restore caches
uses: ./.github/actions/restore-cache
with:
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}

- name: Run integration tests
working-directory: dev-packages/bun-integration-tests
run: yarn test

job_remix_integration_tests:
name: Remix (Node ${{ matrix.node }}) Tests
needs: [job_get_metadata, job_build]
Expand Down Expand Up @@ -1109,6 +1138,7 @@ jobs:
job_node_integration_tests,
job_node_core_integration_tests,
job_cloudflare_integration_tests,
job_bun_integration_tests,
job_browser_playwright_tests,
job_browser_loader_tests,
job_remix_integration_tests,
Expand Down
26 changes: 26 additions & 0 deletions dev-packages/bun-integration-tests/.oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "../../node_modules/oxlint/configuration_schema.json",
"extends": ["../.oxlintrc.json"],
"env": {
"node": true
},
"overrides": [
{
"files": ["suites/**/*.ts"],
"globals": {
"Bun": "readonly",
"fetch": "readonly"
},
"rules": {
"typescript/ban-ts-comment": [
"error",
{
"ts-ignore": "allow-with-description",
"ts-expect-error": true
}
],
"import/first": "off"
}
}
]
}
87 changes: 87 additions & 0 deletions dev-packages/bun-integration-tests/expect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import type { Contexts, Envelope, Event, SdkInfo } from '@sentry/core';
import { SDK_VERSION } from '@sentry/core';
import { expect } from 'vitest';

export const UUID_MATCHER = expect.stringMatching(/^[\da-f]{32}$/);
export const UUID_V4_MATCHER = expect.stringMatching(
/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/,
);
export const SHORT_UUID_MATCHER = expect.stringMatching(/^[\da-f]{16}$/);
export const ISO_DATE_MATCHER = expect.stringMatching(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/);

function dropUndefinedKeys<T extends Record<string, unknown>>(obj: T): T {
for (const [key, value] of Object.entries(obj)) {
if (value === undefined) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete obj[key];
}
}
return obj;
}

function getSdk(sdk: 'bun' | 'hono'): SdkInfo {
return {
integrations: expect.any(Array),
name: `sentry.javascript.${sdk}`,
packages: [
{
name: `npm:@sentry/${sdk}`,
version: SDK_VERSION,
},
...(sdk === 'hono' ? [{ name: 'npm:@sentry/bun', version: SDK_VERSION }] : []),
],
version: SDK_VERSION,
};
}

function defaultContexts(eventContexts: Contexts = {}): Contexts {
return dropUndefinedKeys({
app: { app_memory: expect.any(Number), app_start_time: expect.any(String), free_memory: expect.any(Number) },
cloud_resource: expect.any(Object),
trace: {
trace_id: UUID_MATCHER,
span_id: SHORT_UUID_MATCHER,
},
culture: { locale: expect.any(String), timezone: expect.any(String) },
device: expect.any(Object),
os: expect.any(Object),
runtime: { name: 'bun', version: expect.any(String) },
...eventContexts,
});
}

export function expectedEvent(event: Event, { sdk }: { sdk: 'bun' | 'hono' }): Event {
return dropUndefinedKeys({
event_id: UUID_MATCHER,
timestamp: expect.any(Number),
environment: 'production',
platform: 'node',
modules: expect.any(Object),
sdk: getSdk(sdk),
server_name: expect.any(String),
...event,
contexts: defaultContexts(event.contexts),
});
}

export function eventEnvelope(
event: Event,
{ includeSampleRand = false, sdk = 'bun' }: { includeSampleRand?: boolean; sdk?: 'bun' | 'hono' } = {},
): Envelope {
return [
{
event_id: UUID_MATCHER,
sent_at: ISO_DATE_MATCHER,
sdk: { name: `sentry.javascript.${sdk}`, version: SDK_VERSION },
trace: {
environment: event.environment || 'production',
public_key: 'public',
trace_id: UUID_MATCHER,
sample_rate: expect.any(String),
...(includeSampleRand && { sample_rand: expect.stringMatching(/^[01](\.\d+)?$/) }),
sampled: expect.any(String),
},
},
[[{ type: 'event' }, expectedEvent(event, { sdk })]],
];
}
28 changes: 28 additions & 0 deletions dev-packages/bun-integration-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@sentry-internal/bun-integration-tests",
"version": "10.48.0",
"license": "MIT",
"engines": {
"node": ">=18"
},
"private": true,
"scripts": {
"lint": "OXLINT_TSGOLINT_DANGEROUSLY_SUPPRESS_PROGRAM_DIAGNOSTICS=true oxlint . --type-aware",
"lint:fix": "OXLINT_TSGOLINT_DANGEROUSLY_SUPPRESS_PROGRAM_DIAGNOSTICS=true oxlint . --fix --type-aware",
"test": "vitest run",
"test:watch": "yarn test --watch"
},
"dependencies": {
"@sentry/bun": "10.48.0",
"@sentry/hono": "10.48.0",
"hono": "^4.12.12"
},
"devDependencies": {
"@sentry-internal/test-utils": "10.48.0",
"bun-types": "^1.2.9",
"vitest": "^3.2.4"
},
"volta": {
"extends": "../../package.json"
}
}
Loading
Loading