Skip to content
Merged
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
9 changes: 7 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:

env:
DEFAULT_NODE_VERSION: "16.15.1"
SENTRY_RELEASE: "default_release_name"

jobs:
build:
Expand All @@ -22,6 +21,7 @@ jobs:
- run: yarn build

type-check:
needs: build
name: Typing check
runs-on: ubuntu-latest
steps:
Expand All @@ -30,6 +30,7 @@ jobs:
with:
node-version: ${{ env.DEFAULT_NODE_VERSION }}
- run: yarn --frozen-lockfile
- run: yarn build
- run: yarn check:types

formatting-check:
Expand All @@ -44,6 +45,7 @@ jobs:
- run: yarn check:formatting

test:
needs: build
name: Tests
runs-on: ubuntu-latest
steps:
Expand All @@ -52,9 +54,11 @@ jobs:
with:
node-version: ${{ env.DEFAULT_NODE_VERSION }}
- run: yarn --frozen-lockfile
- run: yarn check:formatting
- run: yarn build
- run: yarn test

lint:
needs: build
name: Linter check
runs-on: ubuntu-latest
steps:
Expand All @@ -63,4 +67,5 @@ jobs:
with:
node-version: ${{ env.DEFAULT_NODE_VERSION }}
- run: yarn --frozen-lockfile
- run: yarn build
- run: yarn lint
20 changes: 20 additions & 0 deletions packages/integration-tests/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const jestPackageJson = require("jest/package.json");

/** @type {import('eslint').ESLint.Options} */
module.exports = {
root: true,
extends: ["local/jest", "local/base"],
ignorePatterns: [".eslintrc.js", "fixtures/*/out", "jest.config.js"],
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.json"],
},
env: {
node: true,
},
settings: {
jest: {
version: jestPackageJson.version,
},
},
};
1 change: 1 addition & 0 deletions packages/integration-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fixtures/*/out/**
5 changes: 5 additions & 0 deletions packages/integration-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Integration Tests

Each folder in the `fixtures` folder represents one testing scenario.
When `yarn test` is run, first `setup.ts` in all fixtures is executed, afterwards we run `jest`, which will pick up all `*.test.ts` files.
The `*.test.ts` files can then use anything that is generated via `setup.ts`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import childProcess from "child_process";
import path from "path";

/**
* Runs a node file in a seprate process.
*
* @param bundlePath Path of node file to run
* @returns Stdout of the process
*/
function checkBundle(bundlePath: string): void {
const processOutput = childProcess.execSync(`node ${bundlePath}`, { encoding: "utf-8" });
expect(processOutput).toBe("I AM A RELEASE!");
}

test("esbuild bundle", () => {
expect.assertions(1);
checkBundle(path.join(__dirname, "./out/esbuild/index.js"));
});

test("rollup bundle", () => {
expect.assertions(1);
checkBundle(path.join(__dirname, "./out/rollup/index.js"));
});

test("vite bundle", () => {
expect.assertions(1);
checkBundle(path.join(__dirname, "./out/vite/index.js"));
});

test("webpack 4 bundle", () => {
expect.assertions(1);
checkBundle(path.join(__dirname, "./out/webpack4/index.js"));
});

test("webpack 5 bundle", () => {
expect.assertions(1);
checkBundle(path.join(__dirname, "./out/webpack5/index.js"));
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
process.stdout.write(global.SENTRY_RELEASE.id);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as path from "path";
import { createCjsBundles } from "../../utils/create-cjs-bundles";

const entryPointPath = path.resolve(__dirname, "./input/entrypoint.js");
const outputDir = path.resolve(__dirname, "./out");

createCjsBundles(entryPointPath, outputDir, { release: "I AM A RELEASE!", include: "" });
6 changes: 6 additions & 0 deletions packages/integration-tests/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
testEnvironment: "node",
transform: {
"^.+\\.(t|j)sx?$": ["@swc/jest"],
},
};
29 changes: 29 additions & 0 deletions packages/integration-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "integration-tests",
"version": "1.0.0",
"private": true,
"scripts": {
"test": "run-s test:setup test:jest",
"test:setup": "ts-node scripts/run-fixture-setups.ts",
"test:jest": "jest",
"lint": "eslint .",
"check:types": "tsc --project ./tsconfig.json --noEmit"
},
"dependencies": {
"@swc/jest": "^0.2.21",
"@types/jest": "^28.1.3",
"@sentry/unplugin": "*",
"@types/webpack4": "npm:@types/webpack@4.41.32",
"esbuild": "0.14.49",
"eslint-config-local": "*",
"jest": "^28.1.3",
"npm-run-all": "4.1.5",
"rollup": "2.77.0",
"sentry-unplugin-tsconfigs": "*",
"eslint": "^8.18.0",
"ts-node": "^10.9.1",
"vite": "3.0.0",
"webpack": "5.74.0",
"webpack4": "npm:webpack@4.46.0"
}
}
10 changes: 10 additions & 0 deletions packages/integration-tests/scripts/run-fixture-setups.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import fs from "fs";
import path from "path";

const fixturePaths = fs
.readdirSync(path.join(__dirname, "../fixtures"))
.map((fixtureDir) => path.join(__dirname, "../fixtures", fixtureDir));

fixturePaths.forEach((fixturePath) => {
require(path.join(fixturePath, "setup.ts"));
});
9 changes: 9 additions & 0 deletions packages/integration-tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "sentry-unplugin-tsconfigs/base-config.json",
"include": ["./**/*"],
"compilerOptions": {
"esModuleInterop": true,
"types": ["node", "jest"]
}
}
95 changes: 95 additions & 0 deletions packages/integration-tests/utils/create-cjs-bundles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import * as vite from "vite";
import * as path from "path";
import * as rollup from "rollup";
import { default as webpack4 } from "webpack4";
import { webpack as webpack5 } from "webpack";
import * as esbuild from "esbuild";
import {
sentryEsbuildPlugin,
sentryRollupPlugin,
sentryVitePlugin,
sentryWebpackPlugin,
Options,
} from "@sentry/unplugin";

export function createCjsBundles(
entryPointPath: string,
outFolder: string,
sentryUnpluginOptions: Options
): void {
void vite.build({
clearScreen: false,
build: {
outDir: path.join(outFolder, "vite"),
lib: {
entry: entryPointPath,
fileName: "index",
formats: ["cjs"],
},
},
plugins: [sentryVitePlugin(sentryUnpluginOptions)],
});

void rollup
.rollup({
input: entryPointPath,
plugins: [sentryRollupPlugin(sentryUnpluginOptions)],
})
.then((bundle) =>
bundle.write({
file: path.join(outFolder, "rollup/index.js"),
format: "cjs",
exports: "named",
})
);

void esbuild.build({
entryPoints: [entryPointPath],
outfile: path.join(outFolder, "esbuild/index.js"),
plugins: [sentryEsbuildPlugin(sentryUnpluginOptions)],
minify: true,
bundle: true,
format: "cjs",
});

webpack4(
{
mode: "production",
entry: entryPointPath,
cache: false,
output: {
path: path.join(outFolder, "webpack4"),
filename: "index.js",
libraryTarget: "commonjs",
},
target: "node", // needed for webpack 4 so we can access node api
plugins: [sentryWebpackPlugin(sentryUnpluginOptions)],
},
(err) => {
if (err) {
throw err;
}
}
);

webpack5(
{
cache: false,
entry: entryPointPath,
output: {
filename: "index.js",
path: path.join(outFolder, "webpack5"),
library: {
type: "commonjs",
},
},
mode: "production",
plugins: [sentryWebpackPlugin(sentryUnpluginOptions)],
},
(err) => {
if (err) {
throw err;
}
}
);
}
2 changes: 1 addition & 1 deletion packages/playground/build-esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ build({
minify: true,
bundle: true,
format: "cjs",
sourcemap: true, // currently we break source maps :(, we need to fix this upstream in unplugin
sourcemap: true,
});
6 changes: 1 addition & 5 deletions packages/playground/build-webpack4.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ webpack4(
library: "ExampleBundle",
libraryTarget: "commonjs",
},
plugins: [
sentryWebpackPlugin({
...placeHolderOptions,
}),
],
plugins: [sentryWebpackPlugin({ ...placeHolderOptions })],
devtool: "source-map",
},
(err) => {
Expand Down
5 changes: 0 additions & 5 deletions packages/unplugin/test/example.test.ts

This file was deleted.

Loading