Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Use affected-test plans to narrow E2E tests (#82052)

Fraserdf5e090463d5
diff --git a/.github/file-paths.yaml b/.github/file-paths.yaml
index db7b2d97d20..29081345280 100644
--- a/.github/file-paths.yaml
+++ b/.github/file-paths.yaml
@@ -121,8 +121,11 @@ ci_scripts:
- ".github/file-paths.yaml"
- ".github/scripts/**"
- ".github/actions/**"
+ - ".github/workflows/e2e-{test,tests,matrix-builder}.yml"
- ".github/workflows/loki.yml"
- ".storybook/story-files.cjs"
+ - "e2e/runner/read-spec-paths.js"
+ - "e2e/support/cypress.config.js"
- "frontend/lint/module-boundaries.mjs"
- "frontend/lint/shared-tiers.mjs"
- "frontend/test/jest-test-paths-filter.ts"
@@ -133,12 +136,6 @@ ci_scripts:
- "package.json"
- "bun.lock"
-# e2e harness/support code (commands, support file, runner). Not in the
-# instrumented bundle, so it maps to no covered module — a change here forces a
-# full e2e run (see create-test-plan / e2eInfraTouched).
-e2e_infra: &e2e_infra
- - *shared_e2e
-
backend_ci: &backend_ci
- *shared_ci
- ".github/actions/test-driver/**"
@@ -266,6 +263,21 @@ snowplow: &snowplow
- "bin/lint-snowplow-schemas.bb"
- "bin/lint-snowplow-schemas-test.bb"
+# e2e harness/support code (commands, support file, runner). Not in the
+# instrumented bundle, so it maps to no covered module — a change here forces a
+# full e2e run (see create-test-plan / e2eInfraTouched).
+e2e_infra: &e2e_infra
+ - *default
+ - *e2e_ci
+ - *frontend_configs
+ - *shared_e2e
+ - *snowplow
+ - "e2e/**/!(*.cy.spec.@(js|jsx|ts|tsx))"
+ - "frontend/build/**"
+ - "patches/**"
+ - ".github/scripts/build-e2e-matrix.js"
+ - ".github/file-paths.yaml"
+
e2e_all:
- *default
- *e2e_ci
@@ -273,6 +285,7 @@ e2e_all:
- *e2e_specs
- "e2e/**"
- *snowplow
+ - *e2e_infra
documentation:
- "docs/**"
diff --git a/.github/scripts/build-e2e-matrix.js b/.github/scripts/build-e2e-matrix.js
index 5939265e64d..ac8535eb58b 100755
--- a/.github/scripts/build-e2e-matrix.js
+++ b/.github/scripts/build-e2e-matrix.js
@@ -2,9 +2,10 @@
// its aim is to split the e2e test matrix into multiple jobs
// grouping some specific tests together, other tests are split into chunks
+const SPECS_PER_JOB = 5;
const DEFAULT_SPEC_PATTERN = "./e2e/test/scenarios/**/*.cy.spec.*";
-const specialTestConfigs = [
+const taggedJobs = [
{
name: "oss-subset",
edition: "oss",
@@ -15,69 +16,38 @@ const specialTestConfigs = [
{ name: "python", tags: "@python", specs: DEFAULT_SPEC_PATTERN },
];
-/**
- *
- * @param {*} inputSpecs - specs, which were changed in the PR, separated by comma
- * .e.g e2e/test/scenarios/onboarding/command-palette.cy.spec.js,e2e/test/scenarios/question/document-title.cy.spec.js
- * or a pattern like DEFAULT_SPEC_PATTERN
- */
-function buildMatrix(options, inputSpecs, inputChunks) {
+function buildMatrix(options, specFiles, maxJobs) {
const { java, defaultRunner } = options;
-
- // number of specs per chunk when running specific specs
- const SPECS_PER_CHUNK = 5;
-
- const defaultOptions = {
- "java-version": java,
- runner: defaultRunner,
- edition: "ee",
- };
-
- const isDefaultSpecPattern =
- inputSpecs === "" || inputSpecs === DEFAULT_SPEC_PATTERN;
-
- console.log("Processed specs value:", inputSpecs);
- console.log("Is default pattern:", isDefaultSpecPattern);
-
- let regularChunks;
- if (isDefaultSpecPattern) {
- regularChunks = inputChunks - specialTestConfigs.length;
- } else {
- // when pattern is not default, it means we passed some custom list of the changed specs
- // so we need to calculate how many chunks we need to run
- const matchingSpecsCount = inputSpecs.split(",").length;
- regularChunks = Math.max(
- 1,
- Math.ceil(matchingSpecsCount / SPECS_PER_CHUNK),
+ if (!Number.isInteger(maxJobs) || maxJobs <= taggedJobs.length) {
+ throw new Error(
+ `E2E job limit must be an integer greater than ${taggedJobs.length} to allow at least one regular job alongside the tagged jobs`,
);
}
- const regularTests = Array.from({ length: regularChunks }, (_, index) => {
- const paddedIndex = String(index + 1).padStart(2, "0");
+ if (specFiles?.length === 0) {
+ return { config: [], regularChunks: 0 };
+ }
- return {
- name: `e2e-group-${paddedIndex}`,
- // works when specs less than 5, otherwise seems all chunks will contain
- // same specs
- ...(!isDefaultSpecPattern && {
- specs: inputSpecs
- .split(",")
- .slice(SPECS_PER_CHUNK * index, SPECS_PER_CHUNK * (index + 1))
- .join(","),
- }),
- };
- });
+ const maxRegularJobs = maxJobs - taggedJobs.length;
+ let regularChunks = maxRegularJobs;
+ if (specFiles !== null) {
+ const jobsForSelectedSpecs = Math.ceil(specFiles.length / SPECS_PER_JOB);
+ regularChunks = Math.min(maxRegularJobs, jobsForSelectedSpecs);
+ }
- const testSets = isDefaultSpecPattern
- ? regularTests.concat(specialTestConfigs)
- : regularTests;
+ const regularJobs = Array.from({ length: regularChunks }, (_, index) => ({
+ name: `e2e-group-${String(index + 1).padStart(2, "0")}`,
+ }));
- const config = testSets.map((options) => ({
- ...defaultOptions,
- ...options,
+ // Regular jobs exclude the OSS, Mongo, and Python tags, so these jobs must also run for selected specs.
+ const config = [...regularJobs, ...taggedJobs].map((test) => ({
+ "java-version": java,
+ runner: defaultRunner,
+ edition: "ee",
+ ...test,
}));
- return { config, regularChunks, isDefaultSpecPattern };
+ return { config, regularChunks };
}
module.exports = { buildMatrix };
diff --git a/.github/scripts/build-e2e-matrix.unit.spec.js b/.github/scripts/build-e2e-matrix.unit.spec.js
index 6a8c7dff3a7..aa7fcb989f2 100644
--- a/.github/scripts/build-e2e-matrix.unit.spec.js
+++ b/.github/scripts/build-e2e-matrix.unit.spec.js
@@ -1,99 +1,74 @@
const { buildMatrix } = require("./build-e2e-matrix");
-describe("buildMatrix", () => {
- const options = {
- java: "11",
- defaultRunner: "${{ vars.DEFAULT_RUNNER_KEY }}",
- };
- const testBuildMatrix = (entry, chunks) =>
- buildMatrix(options, entry, chunks);
-
- it("should calculate correct regular chunks with default parameters", () => {
- const result = testBuildMatrix("./e2e/test/scenarios/**/*.cy.spec.*", 30);
-
- expect(result.regularChunks).toBe(27);
- });
-
- it("should create correct number of configuration objects", () => {
- const result = testBuildMatrix("./e2e/test/scenarios/**/*.cy.spec.*", 10);
-
- expect(result.config.length).toBe(10);
- });
+const options = { java: 25, defaultRunner: "runner" };
+const specs = (count) =>
+ Array.from({ length: count }, (_, i) => `e2e/test/scenarios/${i}.cy.spec.ts`);
- it("should apply default specs path when empty entry is provided", () => {
- const result = testBuildMatrix("", 6);
-
- expect(result.regularChunks).toBe(3);
- expect(result.config.length).toBe(6);
+describe("buildMatrix", () => {
+ it.each([0, 3, 3.5])("should reject an invalid job budget: %s", (chunks) => {
+ expect(() => buildMatrix(options, specs(1), chunks)).toThrow();
});
- it("should name regular test groups sequentially", () => {
- const result = testBuildMatrix("./e2e/test/scenarios/**/*.cy.spec.*", 10);
- const regularTests = result.config.filter((cfg) =>
- cfg.name.startsWith("e2e-group-"),
- );
+ it("should use the full job budget when there is no plan", () => {
+ const result = buildMatrix(options, null, 50);
- regularTests.forEach((test, index) => {
- expect(test.name).toBe(
- `e2e-group-${String(index + 1).padStart(2, "0")}`,
- );
+ expect(result.regularChunks).toBe(47);
+ expect(result.config).toHaveLength(50);
+ expect(result.config[0]).toMatchObject({
+ name: "e2e-group-01",
+ edition: "ee",
+ runner: "runner",
});
+ expect(result.config[46].name).toBe("e2e-group-47");
});
- it("should handle case when input chunks equals special tests count", () => {
- const result = testBuildMatrix("./e2e/test/scenarios/**/*.cy.spec.*", 3);
-
- expect(result.regularChunks).toBe(0);
- expect(result.config.length).toBe(3);
- expect(result.config[0].name).toBe("oss-subset");
- expect(result.config[1].name).toBe("mongo");
- expect(result.config[2].name).toBe("python");
- });
-
- it("should correctly calculate regularChunks for non-default spec pattern", () => {
- const entry = "file.cy.spec.js,".repeat(12).slice(0, -1);
- const result = testBuildMatrix(entry, 10);
-
- // For 12 matching specs with SPECS_PER_CHUNK=5, we expect ceil(12/5) = 3 chunks
- expect(result.regularChunks).toBe(3);
-
- const firstGroupSpecs = result.config[0].specs.split(",").length;
- const secondGroupSpecs = result.config[1].specs.split(",").length;
- const thirdGroupSpecs = result.config[2].specs.split(",").length;
-
- expect(firstGroupSpecs).toBe(5);
- expect(secondGroupSpecs).toBe(5);
- expect(thirdGroupSpecs).toBe(2);
- });
-
- it("should return isDefaultSpecPattern as true when empty or default value is provided", () => {
- let result = testBuildMatrix("", 5);
-
- expect(result.isDefaultSpecPattern).toBe(true);
-
- result = testBuildMatrix("./e2e/test/scenarios/**/*.cy.spec.*", 5);
-
- expect(result.isDefaultSpecPattern).toBe(true);
- });
-
- it("should return isDefaultSpecPattern as false when non-default spec pattern is provided", () => {
- const result = testBuildMatrix("test1.cy.spec.js,test2.cy.spec.js", 1);
-
- expect(result.isDefaultSpecPattern).toBe(false);
- });
-
- it("should return special test configs when default spec pattern is provided", () => {
- const result = testBuildMatrix("./e2e/test/scenarios/**/*.cy.spec.*", 50);
-
- expect(result.config[47].name).toBe("oss-subset");
- expect(result.config[48].name).toBe("mongo");
- expect(result.config[49].name).toBe("python");
+ it("should create no jobs for an empty plan", () => {
+ expect(buildMatrix(options, [], 50)).toEqual({
+ config: [],
+ regularChunks: 0,
+ });
});
- it("should not return special test configs when non-default spec pattern is provided", () => {
- const result = testBuildMatrix("test1.cy.spec.js,test2.cy.spec.js", 50);
-
- expect(result.config.length).toBe(1);
- expect(result.config[0].name).toBe("e2e-group-01");
+ it.each([
+ [1, 1],
+ [5, 1],
+ [6, 2],
+ [12, 3],
+ [424, 47],
+ ])(
+ "should allocate %i selected specs to %i regular jobs",
+ (count, regularChunks) => {
+ const result = buildMatrix(options, specs(count), 50);
+
+ expect(result.regularChunks).toBe(regularChunks);
+ expect(result.config).toHaveLength(regularChunks + 3);
+ },
+ );
+
+ it.each([null, specs(1), specs(424)])(
+ "should retain every tagged variant",
+ (plan) => {
+ const result = buildMatrix(options, plan, 50);
+
+ expect(result.config.slice(-3)).toMatchObject([
+ { name: "oss-subset", edition: "oss", tags: "@OSS @prerelease+-@EE" },
+ { name: "mongo", edition: "ee", tags: "@mongo" },
+ { name: "python", edition: "ee", tags: "@python" },
+ ]);
+ },
+ );
+
+ it("should leave regular jobs to cypress-split", () => {
+ const result = buildMatrix(options, specs(12), 50);
+
+ const regularJobs = result.config.slice(0, result.regularChunks);
+ expect(regularJobs.map((job) => job.name)).toEqual([
+ "e2e-group-01",
+ "e2e-group-02",
+ "e2e-group-03",
+ ]);
+ for (const job of regularJobs) {
+ expect(job.specs).toBeUndefined();
+ }
});
});
diff --git a/.github/scripts/file-paths.unit.spec.ts b/.github/scripts/file-paths.unit.spec.ts
index a941df30e02..8285454153b 100644
--- a/.github/scripts/file-paths.unit.spec.ts
+++ b/.github/scripts/file-paths.unit.spec.ts
@@ -139,4 +139,43 @@ describe("file-paths.yaml", () => {
])("does not run Loki stories when %s changes", (file) => {
expect(matches("frontend_loki_all", file)).toBe(false);
});
+
+ it.each([
+ "e2e/support/cypress.config.js",
+ "e2e/test/scenarios/shared-helper.js",
+ "e2e/runner/read-spec-paths.js",
+ ".github/workflows/e2e-test.yml",
+ ".github/workflows/run-tests.yml",
+ ".github/actions/prepare-cypress/action.yml",
+ ".github/scripts/build-e2e-matrix.js",
+ ".github/file-paths.yaml",
+ "frontend/build/shared/esbuild/side-effect-free-modules-plugin.js",
+ "rspack.main.config.js",
+ "bun.lock",
+ "locales/fr.po",
+ "snowplow/events/event.yaml",
+ "patches/@cypress+grep+6.0.0.patch",
+ ])("runs all E2E specs when %s changes", (file) => {
+ expect(matches("e2e_all", file)).toBe(true);
+ expect(matches("e2e_infra", file)).toBe(true);
+ });
+
+ it.each(["js", "jsx", "ts", "tsx"])(
+ "allows changes to .cy.spec.%s files to narrow E2E",
+ (extension) => {
+ expect(
+ matches("e2e_infra", `e2e/test/scenarios/a.cy.spec.${extension}`),
+ ).toBe(false);
+ },
+ );
+
+ it.each([
+ ".github/workflows/e2e-test.yml",
+ ".github/workflows/e2e-tests.yml",
+ ".github/workflows/e2e-matrix-builder.yml",
+ "e2e/runner/read-spec-paths.js",
+ "e2e/support/cypress.config.js",
+ ])("runs CI-script tests when %s changes", (file) => {
+ expect(matches("ci_scripts", file)).toBe(true);
+ });
});
diff --git a/.github/scripts/prepare-test-selection.unit.spec.ts b/.github/scripts/prepare-test-selection.unit.spec.ts
index e705d9af3bd..5e103aa072b 100644
--- a/.github/scripts/prepare-test-selection.unit.spec.ts
+++ b/.github/scripts/prepare-test-selection.unit.spec.ts
@@ -206,9 +206,15 @@ describe("prepareTestSelection", () => {
describe("test selection workflow steps", () => {
const ACTION = "./.github/actions/prepare-test-selection";
- const CONSUMERS: Record<string, { suite: keyof typeof SUITES }> = {
+ const CONSUMERS: Record<
+ string,
+ { suite: keyof typeof SUITES; "require-download"?: boolean }
+ > = {
"frontend.yml": { suite: "unit" },
"loki.yml": { suite: "loki" },
+ "e2e-matrix-builder.yml": { suite: "e2e" },
+ // The matrix was sized for the planned specs, so a shard fails when the plan download fails.
+ "e2e-test.yml": { suite: "e2e", "require-download": true },
};
it("skips Loki visual tests only for an empty story selection", () => {
diff --git a/.github/scripts/read-spec-paths.unit.spec.js b/.github/scripts/read-spec-paths.unit.spec.js
new file mode 100644
index 00000000000..ad733aa1f14
--- /dev/null
+++ b/.github/scripts/read-spec-paths.unit.spec.js
@@ -0,0 +1,34 @@
+const { readFileSync } = require("node:fs");
+
+const { readSpecPaths } = require("../../e2e/runner/read-spec-paths");
+
+jest.mock("node:fs", () => ({ readFileSync: jest.fn() }));
+
+describe("readSpecPaths", () => {
+ it("should use the full suite when no paths file is provided", () => {
+ expect(readSpecPaths("")).toBeNull();
+ expect(readSpecPaths(undefined)).toBeNull();
+ });
+
+ it("should preserve an empty selection", () => {
+ readFileSync.mockReturnValue("[]");
+
+ expect(readSpecPaths("specs.json")).toEqual([]);
+ });
+
+ it("should preserve selected paths, including spaces and commas", () => {
+ const files = ["e2e/test/a.cy.spec.js", "e2e/test/a folder/b,c.cy.spec.ts"];
+ readFileSync.mockReturnValue(JSON.stringify(files));
+
+ expect(readSpecPaths("specs.json")).toEqual(files);
+ });
+
+ it.each(["{", "null", '""', "{}", "[null]", '[""]'])(
+ "should reject invalid spec paths: %s",
+ (contents) => {
+ readFileSync.mockReturnValue(contents);
+
+ expect(() => readSpecPaths("specs.json")).toThrow();
+ },
+ );
+});
diff --git a/.github/workflows/e2e-matrix-builder.yml b/.github/workflows/e2e-matrix-builder.yml
index 75a7ec54779..926ea9c8018 100644
--- a/.github/workflows/e2e-matrix-builder.yml
+++ b/.github/workflows/e2e-matrix-builder.yml
@@ -7,17 +7,21 @@ on:
required: false
type: number
default: 30
- specs:
+ test-plan-artifact-id:
+ description: "ID of this run's test-plan.json artifact, '' to run the full suite."
required: false
type: string
- default: "./e2e/test/scenarios/**/*.cy.spec.*"
+ default: ""
outputs:
matrix:
value: ${{ jobs.build-matrix.outputs.matrix }}
regularChunks:
value: ${{ jobs.build-matrix.outputs.regularChunks }}
- isDefaultSpecPattern:
- value: ${{ jobs.build-matrix.outputs.isDefaultSpecPattern }}
+ hasTests:
+ value: ${{ jobs.build-matrix.outputs.hasTests }}
+ test-plan-artifact-id:
+ description: "The test plan artifact ID when the matrix was built from a narrowed selection, otherwise ''."
+ value: ${{ jobs.build-matrix.outputs.test-plan-artifact-id }}
jobs:
build-matrix:
@@ -26,25 +30,38 @@ jobs:
outputs:
matrix: ${{ steps.matrix.outputs.config }}
regularChunks: ${{ steps.matrix.outputs.regularChunks }}
- isDefaultSpecPattern: ${{ steps.matrix.outputs.isDefaultSpecPattern }}
+ hasTests: ${{ steps.matrix.outputs.hasTests }}
+ test-plan-artifact-id: ${{ steps.selection.outputs.paths-file && inputs.test-plan-artifact-id || '' }}
steps:
- uses: actions/checkout@v7
with:
sparse-checkout: |
.github
+ /.nvmrc
+ /package.json
+ e2e/runner/read-spec-paths.js
sparse-checkout-cone-mode: false
- - uses: actions/[email protected]
+ - name: Prepare Node + Bun environment
+ if: ${{ inputs.test-plan-artifact-id != '' }}
+ uses: ./.github/actions/prepare-node-bun
+ - name: Prepare E2E spec selection
+ id: selection
+ if: ${{ inputs.test-plan-artifact-id != '' }}
+ uses: ./.github/actions/prepare-test-selection
with:
- node-version: lts/Jod # 22.x.x
+ suite: e2e
+ test-plan-artifact-id: ${{ inputs.test-plan-artifact-id }}
- name: Build e2e matrix
uses: actions/github-script@v9
id: matrix
env:
chunks: ${{ inputs.chunks }}
+ E2E_SPEC_PATHS_FILE: ${{ steps.selection.outputs.paths-file }}
with:
script: | # js
const { buildMatrix } = require('${{ github.workspace }}/.github/scripts/build-e2e-matrix.js');
- const inputSpecs = "${{ inputs.specs }}";
+ const { readSpecPaths } = require('${{ github.workspace }}/e2e/runner/read-spec-paths.js');
+ const specFiles = readSpecPaths(process.env.E2E_SPEC_PATHS_FILE);
const inputChunks = Number(process.env.chunks);
const java = 25;
const defaultRunner = "${{ vars.DEFAULT_RUNNER_KEY }}";
@@ -52,12 +69,11 @@ jobs:
java,
defaultRunner,
};
- const { config, regularChunks, isDefaultSpecPattern } = buildMatrix(options, inputSpecs, inputChunks);
+ const { config, regularChunks } = buildMatrix(options, specFiles, inputChunks);
core.setOutput("regularChunks", JSON.stringify(regularChunks));
core.setOutput("config", JSON.stringify({ include: config }));
- core.setOutput("isDefaultSpecPattern", JSON.stringify(isDefaultSpecPattern));
+ core.setOutput("hasTests", config.length > 0);
console.log({ regularChunks });
console.log("matrix config", config);
- console.log("isDefaultSpecPattern", isDefaultSpecPattern);
diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml
index da06af602ad..b0702eefaff 100644
--- a/.github/workflows/e2e-test.yml
+++ b/.github/workflows/e2e-test.yml
@@ -15,6 +15,10 @@ on:
required: false
default: ./e2e/test/scenarios/**/*.cy.spec.*
type: string
+ test-plan-artifact-id:
+ description: "ID of this run's test-plan.json artifact, '' to use the default spec pattern."
+ type: string
+ default: ""
tags:
required: false
type: string
@@ -114,6 +118,17 @@ jobs:
- name: Prepare front-end environment
uses: ./.github/actions/prepare-frontend
+
+ # The matrix builder sized these jobs for the planned specs, so the test plan download has to succeed.
+ - name: Prepare E2E spec selection
+ id: selection
+ if: ${{ inputs.test-plan-artifact-id != '' }}
+ uses: ./.github/actions/prepare-test-selection
+ with:
+ suite: e2e
+ test-plan-artifact-id: ${{ inputs.test-plan-artifact-id }}
+ require-download: true
+
- name: Prepare back-end environment
uses: ./.github/actions/prepare-backend
@@ -187,6 +202,7 @@ jobs:
# do not write cypress-split summary to github
SPLIT_SUMMARY: false
SPEC_PATH: ${{ env.specs || inputs.specs }}
+ E2E_SPEC_PATHS_FILE: ${{ steps.selection.outputs.paths-file }}
# Re-run attempts run only the previously-failed specs (env.specs), so record them.
CYPRESS_VIDEO: ${{ env.specs && 'true' || 'false' }}
CYPRESS_BROWSER: ${{ steps.cypress-prep.outputs.chrome-path }}
@@ -205,6 +221,7 @@ jobs:
shell: bash
env:
SPEC_PATH: ${{ env.specs || inputs.specs }}
+ E2E_SPEC_PATHS_FILE: ${{ steps.selection.outputs.paths-file }}
# Re-run attempts run only the previously-failed specs (env.specs), so record them.
CYPRESS_VIDEO: ${{ env.specs && 'true' || 'false' }}
CYPRESS_BROWSER: ${{ steps.cypress-prep.outputs.chrome-path }}
diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml
index ac512a8b4b8..79a50883a9b 100644
--- a/.github/workflows/e2e-tests.yml
+++ b/.github/workflows/e2e-tests.yml
@@ -6,7 +6,8 @@ on:
skip:
type: boolean
default: false
- specs:
+ test-plan-artifact-id:
+ description: "ID of this run's test-plan.json artifact, '' to run the full suite."
type: string
required: false
default: ""
@@ -17,10 +18,11 @@ concurrency:
jobs:
e2e-matrix-builder:
+ if: ${{ !inputs.skip }}
uses: ./.github/workflows/e2e-matrix-builder.yml
with:
chunks: 50
- specs: ${{ inputs.specs }}
+ test-plan-artifact-id: ${{ inputs.test-plan-artifact-id }}
reset-e2e-test-comment:
if: ${{ github.event_name == 'pull_request' }}
@@ -59,7 +61,9 @@ jobs:
needs:
- e2e-matrix-builder
if: |
- !cancelled() && !inputs.skip
+ !cancelled() && !inputs.skip &&
+ needs.e2e-matrix-builder.result == 'success' &&
+ needs.e2e-matrix-builder.outputs.hasTests == 'true'
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.e2e-matrix-builder.outputs.matrix) }}
@@ -68,6 +72,7 @@ jobs:
name: ${{ matrix.name }}
edition: ${{ matrix.edition }}
specs: ${{ matrix.specs }}
+ test-plan-artifact-id: ${{ needs.e2e-matrix-builder.outputs.test-plan-artifact-id }}
total_chunks: ${{ fromJson(needs.e2e-matrix-builder.outputs.regularChunks) }}
split_index: ${{ strategy.job-index }}
tags: ${{ matrix.tags }}
@@ -137,6 +142,7 @@ jobs:
e2e-tests-result:
needs:
+ - e2e-matrix-builder
- e2e-tests
runs-on: ${{ vars.SLIM_RUNNER_KEY }}
timeout-minutes: 5
@@ -144,17 +150,22 @@ jobs:
if: always() && !cancelled()
env:
E2E_TESTS_RESULT: ${{ needs.e2e-tests.result }}
+ MATRIX_RESULT: ${{ needs.e2e-matrix-builder.result }}
+ HAS_TESTS: ${{ needs.e2e-matrix-builder.outputs.hasTests }}
+ SKIP: ${{ inputs.skip }}
steps:
- - name: Stub
- if: ${{ needs.e2e-tests.result == 'skipped' }}
- run: |
- echo "Didn't run due to conditional filtering"
- name: Test results
- if: ${{ needs.e2e-tests.result != 'skipped' }}
run: | # sh
- echo "E2E Tests: ${{ needs.e2e-tests.result }}"
-
- if [ "${{ needs.e2e-tests.result }}" != "success" ]; then
+ if [ "$SKIP" = "true" ]; then
+ echo "Didn't run due to conditional filtering"
+ elif [ "$MATRIX_RESULT" != "success" ]; then
+ echo "E2E matrix builder failed"
+ exit 1
+ elif [ "$HAS_TESTS" = "false" ]; then
+ echo "The plan selected no E2E specs"
+ elif [ "$E2E_TESTS_RESULT" != "success" ]; then
echo "E2E Tests failed"
exit 1
+ else
+ echo "E2E Tests passed"
fi
diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml
index 3ae673438db..bfa880ca255 100644
--- a/.github/workflows/run-tests.yml
+++ b/.github/workflows/run-tests.yml
@@ -333,7 +333,7 @@ jobs:
test-plan-artifact-id: ${{ needs.create-test-plan.result == 'success' && needs.create-test-plan.outputs.artifact-id || '' }}
e2e-tests:
- needs: [should-run, files-changed, uberjar]
+ needs: [should-run, files-changed, uberjar, create-test-plan]
# Skip e2e tests when the uberjar build failed or was cancelled — the
# downstream tests can't fetch a missing artifact, and we don't want to
# mask the uberjar failure with a wave of misleading e2e errors. We still
@@ -353,19 +353,13 @@ jobs:
skip: >-
${{ needs.should-run.outputs.verdict != 'force-run' &&
needs.files-changed.outputs.e2e_all != 'true' }}
- # here we pass the list of changed files
- # e.g. e2e/test/scenarios/onboarding/command-palette.cy.spec.js,e2e/test/scenarios/question/document-title.cy.spec.js
- # e2e_all_files includes all changes which trigger all e2e tests, if the list of changes files is included in the
- # list of changed specs files, then only specs are changed and we can run only those specs.
- # Only narrow to changed specs on pull requests that haven't been forced to run everything.
- # On push to master/release branches (and the merge queue) the paths-filter still computes
- # these file lists, so without this guard a run that touched only specs would silently run a
- # narrowed suite — we always want the full suite there.
- specs: >-
+ # Only narrow specs on pull requests that haven't been forced to run everything.
+ # Push and merge-queue runs always use the full suite.
+ test-plan-artifact-id: >-
${{ needs.should-run.outputs.verdict != 'force-run' &&
github.event_name == 'pull_request' &&
- needs.files-changed.outputs.e2e_all_files == needs.files-changed.outputs.e2e_specs_files &&
- needs.files-changed.outputs.e2e_specs_files || '' }}
+ needs.create-test-plan.result == 'success' &&
+ needs.create-test-plan.outputs.artifact-id || '' }}
embedding-sdk-package:
needs: [should-run, files-changed]
diff --git a/e2e/runner/read-spec-paths.js b/e2e/runner/read-spec-paths.js
new file mode 100644
index 00000000000..d355c743181
--- /dev/null
+++ b/e2e/runner/read-spec-paths.js
@@ -0,0 +1,18 @@
+const { readFileSync } = require("node:fs");
+
+function readSpecPaths(pathsFile) {
+ if (!pathsFile) {
+ return null;
+ }
+
+ const files = JSON.parse(readFileSync(pathsFile, "utf8"));
+ if (
+ !Array.isArray(files) ||
+ !files.every((file) => typeof file === "string" && file.length > 0)
+ ) {
+ throw new Error("Spec paths must be a JSON array of non-empty strings");
+ }
+ return files;
+}
+
+module.exports = { readSpecPaths };
diff --git a/e2e/support/cypress.config.js b/e2e/support/cypress.config.js
index c6abcf3edfe..c797b7af0ea 100644
--- a/e2e/support/cypress.config.js
+++ b/e2e/support/cypress.config.js
@@ -1,5 +1,14 @@
const { defineConfig } = require("cypress");
+const { readSpecPaths } = require("../runner/read-spec-paths");
+
const { mainConfig } = require("./config");
-module.exports = defineConfig({ e2e: mainConfig });
+const specFiles = readSpecPaths(process.env.E2E_SPEC_PATHS_FILE);
+
+module.exports = defineConfig({
+ e2e: {
+ ...mainConfig,
+ ...(specFiles !== null && { specPattern: specFiles }),
+ },
+});