Skip to content

Commit 5304fe2

Browse files
author
Luca Forstner
authored
ci(integration-tests): Add OS and Node.js version matrix (#131)
1 parent 3e8bf59 commit 5304fe2

File tree

24 files changed

+208
-146
lines changed

24 files changed

+208
-146
lines changed

.github/workflows/checks.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,28 @@ jobs:
4848

4949
test-integration:
5050
needs: build
51-
name: Integration Tests
52-
runs-on: ubuntu-latest
51+
name: "Integration Tests (Node ${{ matrix.node-version }}, OS ${{ matrix.os }})"
52+
strategy:
53+
fail-fast: false
54+
matrix:
55+
node-version: [
56+
# nx uses a `yargs-parser` versision which isn't compatible with node 10
57+
# "10.24.1",
58+
# vite uses optional chaining which isn't compatible with node 12
59+
# "12.22.12",
60+
"14.21.1",
61+
"16.18.1",
62+
"18.12.1",
63+
]
64+
os: [ubuntu-latest, windows-latest]
65+
runs-on: ${{ matrix.os }}
5366
steps:
5467
- uses: actions/checkout@v3
5568
- uses: volta-cli/action@v3
56-
- run: yarn --frozen-lockfile
69+
with:
70+
node-version: ${{ matrix.node-version }}
71+
# husky uses fs-extra which needs node >= 14 - we can ignore because its a dev dependency
72+
- run: yarn --frozen-lockfile --ignore-engines
5773
- run: yarn test:integration
5874

5975
test-e2e:

packages/e2e-tests/scenarios/basic-upload/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as path from "path";
66
*/
77
export const pluginConfig: Options = {
88
release: "basic-upload",
9-
include: path.resolve(__dirname, "./out"),
9+
include: path.resolve(__dirname, "out"),
1010
authToken: process.env["SENTRY_AUTH_TOKEN"] || "",
1111
org: "sentry-sdks",
1212
project: "js-bundler-plugin-e2e-tests",

packages/e2e-tests/scenarios/basic-upload/setup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { createCjsBundles } from "../../utils/create-cjs-bundles";
66

77
deleteAllReleases(pluginConfig.release || "")
88
.then(() => {
9-
const entryPointPath = path.resolve(__dirname, "./input/index.js");
10-
const outputDir = path.resolve(__dirname, "./out");
9+
const entryPointPath = path.resolve(__dirname, "input", "index.js");
10+
const outputDir = path.resolve(__dirname, "out");
1111

1212
createCjsBundles({ index: entryPointPath }, outputDir, pluginConfig);
1313
})

packages/e2e-tests/scripts/run-scenario-setups.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import fs from "fs";
22
import path from "path";
33

44
const scenarioPaths = fs
5-
.readdirSync(path.join(__dirname, "../scenarios"))
6-
.map((fixtureDir) => path.join(__dirname, "../scenarios", fixtureDir));
5+
.readdirSync(path.join(__dirname, "..", "scenarios"))
6+
.map((fixtureDir) => path.join(__dirname, "..", "scenarios", fixtureDir));
77

88
scenarioPaths.forEach((fixturePath) => {
99
require(path.join(fixturePath, "setup.ts"));
Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import childProcess from "child_process";
22
import path from "path";
33
import fs from "fs";
4+
import { testIfNodeMajorVersionIsLessThan18 } from "../../utils/testIf";
45

56
function getBundleOutput(bundlePath: string): string {
67
return childProcess.execSync(`node ${bundlePath}`, { encoding: "utf-8" });
@@ -12,67 +13,71 @@ function getFileContents(bundlePath: string): string {
1213

1314
describe("`releaseInjectionTargets` option should work as expected when given an array of RegEx and strings", () => {
1415
test("esbuild bundle", () => {
15-
expect(getBundleOutput(path.join(__dirname, "./out/esbuild/entrypoint1.js"))).toBe(
16+
expect(getBundleOutput(path.join(__dirname, "out", "esbuild", "entrypoint1.js"))).toBe(
1617
"I AM A RELEASE!"
1718
);
18-
expect(getBundleOutput(path.join(__dirname, "./out/esbuild/entrypoint2.js"))).toBe("");
19-
expect(getBundleOutput(path.join(__dirname, "./out/esbuild/entrypoint3.js"))).toBe(
19+
expect(getBundleOutput(path.join(__dirname, "out", "esbuild", "entrypoint2.js"))).toBe("");
20+
expect(getBundleOutput(path.join(__dirname, "out", "esbuild", "entrypoint3.js"))).toBe(
2021
"I AM A RELEASE!"
2122
);
22-
expect(getFileContents(path.join(__dirname, "./out/esbuild/entrypoint2.js"))).not.toContain(
23+
expect(getFileContents(path.join(__dirname, "out", "esbuild", "entrypoint2.js"))).not.toContain(
2324
"I AM A RELEASE!"
2425
);
2526
});
2627

2728
test("rollup bundle", () => {
28-
expect(getBundleOutput(path.join(__dirname, "./out/rollup/entrypoint1.js"))).toBe(
29+
expect(getBundleOutput(path.join(__dirname, "out", "rollup", "entrypoint1.js"))).toBe(
2930
"I AM A RELEASE!"
3031
);
31-
expect(getBundleOutput(path.join(__dirname, "./out/rollup/entrypoint2.js"))).toBe("");
32-
expect(getBundleOutput(path.join(__dirname, "./out/rollup/entrypoint3.js"))).toBe(
32+
expect(getBundleOutput(path.join(__dirname, "out", "rollup", "entrypoint2.js"))).toBe("");
33+
expect(getBundleOutput(path.join(__dirname, "out", "rollup", "entrypoint3.js"))).toBe(
3334
"I AM A RELEASE!"
3435
);
35-
expect(getFileContents(path.join(__dirname, "./out/rollup/entrypoint2.js"))).not.toContain(
36+
expect(getFileContents(path.join(__dirname, "out", "rollup", "entrypoint2.js"))).not.toContain(
3637
"I AM A RELEASE!"
3738
);
3839
});
3940

4041
test("vite bundle", () => {
41-
expect(getBundleOutput(path.join(__dirname, "./out/vite/entrypoint1.js"))).toBe(
42+
expect(getBundleOutput(path.join(__dirname, "out", "vite", "entrypoint1.js"))).toBe(
4243
"I AM A RELEASE!"
4344
);
44-
expect(getBundleOutput(path.join(__dirname, "./out/vite/entrypoint2.js"))).toBe("");
45-
expect(getBundleOutput(path.join(__dirname, "./out/vite/entrypoint3.js"))).toBe(
45+
expect(getBundleOutput(path.join(__dirname, "out", "vite", "entrypoint2.js"))).toBe("");
46+
expect(getBundleOutput(path.join(__dirname, "out", "vite", "entrypoint3.js"))).toBe(
4647
"I AM A RELEASE!"
4748
);
48-
expect(getFileContents(path.join(__dirname, "./out/vite/entrypoint2.js"))).not.toContain(
49+
expect(getFileContents(path.join(__dirname, "out", "vite", "entrypoint2.js"))).not.toContain(
4950
"I AM A RELEASE!"
5051
);
5152
});
5253

53-
test("webpack 4 bundle", () => {
54-
expect(getBundleOutput(path.join(__dirname, "./out/webpack4/entrypoint1.js"))).toBe(
54+
testIfNodeMajorVersionIsLessThan18("webpack 4 bundle", () => {
55+
// eslint-disable-next-line jest/no-standalone-expect
56+
expect(getBundleOutput(path.join(__dirname, "out", "webpack4", "entrypoint1.js"))).toBe(
5557
"I AM A RELEASE!"
5658
);
57-
expect(getBundleOutput(path.join(__dirname, "./out/webpack4/entrypoint2.js"))).toBe("");
58-
expect(getBundleOutput(path.join(__dirname, "./out/webpack4/entrypoint3.js"))).toBe(
59-
"I AM A RELEASE!"
60-
);
61-
expect(getFileContents(path.join(__dirname, "./out/webpack4/entrypoint2.js"))).not.toContain(
59+
// eslint-disable-next-line jest/no-standalone-expect
60+
expect(getBundleOutput(path.join(__dirname, "out", "webpack4", "entrypoint2.js"))).toBe("");
61+
// eslint-disable-next-line jest/no-standalone-expect
62+
expect(getBundleOutput(path.join(__dirname, "out", "webpack4", "entrypoint3.js"))).toBe(
6263
"I AM A RELEASE!"
6364
);
65+
// eslint-disable-next-line jest/no-standalone-expect
66+
expect(
67+
getFileContents(path.join(__dirname, "out", "webpack4", "entrypoint2.js"))
68+
).not.toContain("I AM A RELEASE!");
6469
});
6570

6671
test("webpack 5 bundle", () => {
67-
expect(getBundleOutput(path.join(__dirname, "./out/webpack5/entrypoint1.js"))).toBe(
68-
"I AM A RELEASE!"
69-
);
70-
expect(getBundleOutput(path.join(__dirname, "./out/webpack5/entrypoint2.js"))).toBe("");
71-
expect(getBundleOutput(path.join(__dirname, "./out/webpack5/entrypoint3.js"))).toBe(
72+
expect(getBundleOutput(path.join(__dirname, "out", "webpack5", "entrypoint1.js"))).toBe(
7273
"I AM A RELEASE!"
7374
);
74-
expect(getFileContents(path.join(__dirname, "./out/webpack5/entrypoint2.js"))).not.toContain(
75+
expect(getBundleOutput(path.join(__dirname, "out", "webpack5", "entrypoint2.js"))).toBe("");
76+
expect(getBundleOutput(path.join(__dirname, "out", "webpack5", "entrypoint3.js"))).toBe(
7577
"I AM A RELEASE!"
7678
);
79+
expect(
80+
getFileContents(path.join(__dirname, "out", "webpack5", "entrypoint2.js"))
81+
).not.toContain("I AM A RELEASE!");
7782
});
7883
});

packages/integration-tests/fixtures/array-entries-option/setup.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { Options } from "@sentry/bundler-plugin-core";
22
import * as path from "path";
33
import { createCjsBundles } from "../../utils/create-cjs-bundles";
44

5-
const entryPoint1Path = path.resolve(__dirname, "./input/entrypoint1.js");
6-
const entryPoint2Path = path.resolve(__dirname, "./input/entrypoint2.js");
7-
const entryPoint3Path = path.resolve(__dirname, "./input/entrypoint3.js");
8-
const outputDir = path.resolve(__dirname, "./out");
5+
const entryPoint1Path = path.resolve(__dirname, "input", "entrypoint1.js");
6+
const entryPoint2Path = path.resolve(__dirname, "input", "entrypoint2.js");
7+
const entryPoint3Path = path.resolve(__dirname, "input", "entrypoint3.js");
8+
const outputDir = path.resolve(__dirname, "out");
99

1010
createCjsBundles(
1111
{ entrypoint1: entryPoint1Path, entrypoint2: entryPoint2Path, entrypoint3: entryPoint3Path },

packages/integration-tests/fixtures/basic-release-injection/basic-release-injection.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import childProcess from "child_process";
22
import path from "path";
3+
import { testIfNodeMajorVersionIsLessThan18 } from "../../utils/testIf";
34

45
/**
56
* Runs a node file in a seprate process.
@@ -27,7 +28,7 @@ test("vite bundle", () => {
2728
checkBundle(path.join(__dirname, "./out/vite/index.js"));
2829
});
2930

30-
test("webpack 4 bundle", () => {
31+
testIfNodeMajorVersionIsLessThan18("webpack 4 bundle", () => {
3132
expect.assertions(1);
3233
checkBundle(path.join(__dirname, "./out/webpack4/index.js"));
3334
});

packages/integration-tests/fixtures/basic-release-injection/setup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { Options } from "@sentry/bundler-plugin-core";
22
import * as path from "path";
33
import { createCjsBundles } from "../../utils/create-cjs-bundles";
44

5-
const entryPointPath = path.resolve(__dirname, "./input/entrypoint.js");
6-
const outputDir = path.resolve(__dirname, "./out");
5+
const entryPointPath = path.resolve(__dirname, "input", "entrypoint.js");
6+
const outputDir = path.resolve(__dirname, "out");
77

88
createCjsBundles({ index: entryPointPath }, outputDir, {
99
release: "I AM A RELEASE!",
Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import childProcess from "child_process";
22
import path from "path";
33
import fs from "fs";
4+
import { testIfNodeMajorVersionIsLessThan18 } from "../../utils/testIf";
45

56
function getBundleOutput(bundlePath: string): string {
67
return childProcess.execSync(`node ${bundlePath}`, { encoding: "utf-8" });
@@ -12,67 +13,71 @@ function getFileContents(bundlePath: string): string {
1213

1314
describe("`releaseInjectionTargets` option should work as expected when given a function", () => {
1415
test("esbuild bundle", () => {
15-
expect(getBundleOutput(path.join(__dirname, "./out/esbuild/entrypoint1.js"))).toBe(
16+
expect(getBundleOutput(path.join(__dirname, "out", "esbuild", "entrypoint1.js"))).toBe(
1617
"I AM A RELEASE!"
1718
);
18-
expect(getBundleOutput(path.join(__dirname, "./out/esbuild/entrypoint2.js"))).toBe("");
19-
expect(getBundleOutput(path.join(__dirname, "./out/esbuild/entrypoint3.js"))).toBe(
19+
expect(getBundleOutput(path.join(__dirname, "out", "esbuild", "entrypoint2.js"))).toBe("");
20+
expect(getBundleOutput(path.join(__dirname, "out", "esbuild", "entrypoint3.js"))).toBe(
2021
"I AM A RELEASE!"
2122
);
22-
expect(getFileContents(path.join(__dirname, "./out/esbuild/entrypoint2.js"))).not.toContain(
23+
expect(getFileContents(path.join(__dirname, "out", "esbuild", "entrypoint2.js"))).not.toContain(
2324
"I AM A RELEASE!"
2425
);
2526
});
2627

2728
test("rollup bundle", () => {
28-
expect(getBundleOutput(path.join(__dirname, "./out/rollup/entrypoint1.js"))).toBe(
29+
expect(getBundleOutput(path.join(__dirname, "out", "rollup", "entrypoint1.js"))).toBe(
2930
"I AM A RELEASE!"
3031
);
31-
expect(getBundleOutput(path.join(__dirname, "./out/rollup/entrypoint2.js"))).toBe("");
32-
expect(getBundleOutput(path.join(__dirname, "./out/rollup/entrypoint3.js"))).toBe(
32+
expect(getBundleOutput(path.join(__dirname, "out", "rollup", "entrypoint2.js"))).toBe("");
33+
expect(getBundleOutput(path.join(__dirname, "out", "rollup", "entrypoint3.js"))).toBe(
3334
"I AM A RELEASE!"
3435
);
35-
expect(getFileContents(path.join(__dirname, "./out/rollup/entrypoint2.js"))).not.toContain(
36+
expect(getFileContents(path.join(__dirname, "out", "rollup", "entrypoint2.js"))).not.toContain(
3637
"I AM A RELEASE!"
3738
);
3839
});
3940

4041
test("vite bundle", () => {
41-
expect(getBundleOutput(path.join(__dirname, "./out/vite/entrypoint1.js"))).toBe(
42+
expect(getBundleOutput(path.join(__dirname, "out", "vite", "entrypoint1.js"))).toBe(
4243
"I AM A RELEASE!"
4344
);
44-
expect(getBundleOutput(path.join(__dirname, "./out/vite/entrypoint2.js"))).toBe("");
45-
expect(getBundleOutput(path.join(__dirname, "./out/vite/entrypoint3.js"))).toBe(
45+
expect(getBundleOutput(path.join(__dirname, "out", "vite", "entrypoint2.js"))).toBe("");
46+
expect(getBundleOutput(path.join(__dirname, "out", "vite", "entrypoint3.js"))).toBe(
4647
"I AM A RELEASE!"
4748
);
48-
expect(getFileContents(path.join(__dirname, "./out/vite/entrypoint2.js"))).not.toContain(
49+
expect(getFileContents(path.join(__dirname, "out", "vite", "entrypoint2.js"))).not.toContain(
4950
"I AM A RELEASE!"
5051
);
5152
});
5253

53-
test("webpack 4 bundle", () => {
54-
expect(getBundleOutput(path.join(__dirname, "./out/webpack4/entrypoint1.js"))).toBe(
54+
testIfNodeMajorVersionIsLessThan18("webpack 4 bundle", () => {
55+
// eslint-disable-next-line jest/no-standalone-expect
56+
expect(getBundleOutput(path.join(__dirname, "out", "webpack4", "entrypoint1.js"))).toBe(
5557
"I AM A RELEASE!"
5658
);
57-
expect(getBundleOutput(path.join(__dirname, "./out/webpack4/entrypoint2.js"))).toBe("");
58-
expect(getBundleOutput(path.join(__dirname, "./out/webpack4/entrypoint3.js"))).toBe(
59-
"I AM A RELEASE!"
60-
);
61-
expect(getFileContents(path.join(__dirname, "./out/webpack4/entrypoint2.js"))).not.toContain(
59+
// eslint-disable-next-line jest/no-standalone-expect
60+
expect(getBundleOutput(path.join(__dirname, "out", "webpack4", "entrypoint2.js"))).toBe("");
61+
// eslint-disable-next-line jest/no-standalone-expect
62+
expect(getBundleOutput(path.join(__dirname, "out", "webpack4", "entrypoint3.js"))).toBe(
6263
"I AM A RELEASE!"
6364
);
65+
// eslint-disable-next-line jest/no-standalone-expect
66+
expect(
67+
getFileContents(path.join(__dirname, "out", "webpack4", "entrypoint2.js"))
68+
).not.toContain("I AM A RELEASE!");
6469
});
6570

6671
test("webpack 5 bundle", () => {
67-
expect(getBundleOutput(path.join(__dirname, "./out/webpack5/entrypoint1.js"))).toBe(
68-
"I AM A RELEASE!"
69-
);
70-
expect(getBundleOutput(path.join(__dirname, "./out/webpack5/entrypoint2.js"))).toBe("");
71-
expect(getBundleOutput(path.join(__dirname, "./out/webpack5/entrypoint3.js"))).toBe(
72+
expect(getBundleOutput(path.join(__dirname, "out", "webpack5", "entrypoint1.js"))).toBe(
7273
"I AM A RELEASE!"
7374
);
74-
expect(getFileContents(path.join(__dirname, "./out/webpack5/entrypoint2.js"))).not.toContain(
75+
expect(getBundleOutput(path.join(__dirname, "out", "webpack5", "entrypoint2.js"))).toBe("");
76+
expect(getBundleOutput(path.join(__dirname, "out", "webpack5", "entrypoint3.js"))).toBe(
7577
"I AM A RELEASE!"
7678
);
79+
expect(
80+
getFileContents(path.join(__dirname, "out", "webpack5", "entrypoint2.js"))
81+
).not.toContain("I AM A RELEASE!");
7782
});
7883
});

packages/integration-tests/fixtures/function-entries-option/setup.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { Options } from "@sentry/bundler-plugin-core";
22
import * as path from "path";
33
import { createCjsBundles } from "../../utils/create-cjs-bundles";
44

5-
const entryPoint1Path = path.resolve(__dirname, "./input/entrypoint1.js");
6-
const entryPoint2Path = path.resolve(__dirname, "./input/entrypoint2.js");
7-
const entryPoint3Path = path.resolve(__dirname, "./input/entrypoint3.js");
8-
const outputDir = path.resolve(__dirname, "./out");
5+
const entryPoint1Path = path.resolve(__dirname, "input", "entrypoint1.js");
6+
const entryPoint2Path = path.resolve(__dirname, "input", "entrypoint2.js");
7+
const entryPoint3Path = path.resolve(__dirname, "input", "entrypoint3.js");
8+
const outputDir = path.resolve(__dirname, "out");
99

1010
createCjsBundles(
1111
{ entrypoint1: entryPoint1Path, entrypoint2: entryPoint2Path, entrypoint3: entryPoint3Path },

0 commit comments

Comments
 (0)