Skip to content

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

Reusable test gate logic (#82830)

Nemanja Glumacd764799f8f0b
diff --git a/.github/actions/create-test-plan/action.yml b/.github/actions/create-test-plan/action.yml
index 19eec87739c..20d5285a2f2 100644
--- a/.github/actions/create-test-plan/action.yml
+++ b/.github/actions/create-test-plan/action.yml
@@ -1,33 +1,17 @@
-name: Create test plan
+name: Create frontend test plan
description: Compute the affected-tests plan for the changed files.
inputs:
- changed-files:
- description: All changed files (CSV).
- required: true
- fe-changed-files:
- description: Changed frontend_sources files (CSV).
- required: true
- be-changed-files:
- description: Changed backend_sources files (CSV).
- required: true
- unit-infra-touched:
- description: Whether FE unit infra changed.
- required: true
- loki-infra-touched:
- description: Whether Loki infra changed.
- required: true
- e2e-infra-touched:
- description: Whether e2e harness/support code changed.
- required: true
- shared-sources-touched:
- description: Whether cljc/cljs/package.json changed.
- required: true
+ stats-url:
+ description: Endpoint that stores the affected-tests stats row.
+ required: false
+ default: ''
+ stats-api-key:
+ description: API key for stats-url.
+ required: false
+ default: ''
outputs:
- stats:
- description: FE Affected Tests stats row (JSON).
- value: ${{ steps.compute.outputs.stats }}
artifact-id:
description: Artifact containing test-plan.json for this run.
value: ${{ steps.upload.outputs.artifact-id }}
@@ -35,6 +19,14 @@ outputs:
runs:
using: composite
steps:
+ # The action reads the diff itself, so a caller hands it no file lists.
+ - name: Test which files changed
+ id: changes
+ uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
+ with:
+ token: ${{ github.token }}
+ list-files: csv
+ filters: .github/file-paths.yaml
- name: Prepare front-end environment
uses: ./.github/actions/prepare-frontend
- name: Resolve closest-ancestor e2e coverage manifest
@@ -59,13 +51,13 @@ runs:
id: compute
shell: bash
env:
- CHANGED_FILES: ${{ inputs.changed-files }}
- FE_CHANGED_FILES: ${{ inputs.fe-changed-files }}
- BE_CHANGED_FILES: ${{ inputs.be-changed-files }}
- UNIT_INFRA_TOUCHED: ${{ inputs.unit-infra-touched }}
- LOKI_INFRA_TOUCHED: ${{ inputs.loki-infra-touched }}
- E2E_INFRA_TOUCHED: ${{ inputs.e2e-infra-touched }}
- SHARED_SOURCES_TOUCHED: ${{ inputs.shared-sources-touched }}
+ CHANGED_FILES: ${{ steps.changes.outputs.all_changed_files }}
+ FE_CHANGED_FILES: ${{ steps.changes.outputs.frontend_sources_files }}
+ BE_CHANGED_FILES: ${{ steps.changes.outputs.backend_sources_files }}
+ UNIT_INFRA_TOUCHED: ${{ steps.changes.outputs.frontend_unit_infra }}
+ LOKI_INFRA_TOUCHED: ${{ steps.changes.outputs.frontend_loki_infra }}
+ E2E_INFRA_TOUCHED: ${{ steps.changes.outputs.e2e_infra }}
+ SHARED_SOURCES_TOUCHED: ${{ steps.changes.outputs.shared_sources }}
E2E_SPEC_MANIFEST: ${{ steps.manifest.outputs.path }}
run: |
# stdout is the plan JSON; the planner's own info logs go to stderr.
@@ -83,7 +75,7 @@ runs:
- name: Report test plan
shell: bash
- run: |
+ run: | # sh
plan=test-plan.json
row() { # name, selected, total
if [ "$2" -eq "$3" ]; then echo "| $1 | all ($3) | $3 |"; else echo "| $1 | $2 | $3 |"; fi
@@ -122,3 +114,20 @@ runs:
echo '```'
echo "</details>"
} | tee -a "${GITHUB_STEP_SUMMARY:-/dev/null}"
+
+ # Only land rows for PRs from the upstream repo so forks don't pollute the table. Best-effort:
+ # a failed upload must not cost us the plan.
+ - name: Upload affected tests stats
+ if: >-
+ ${{ inputs.stats-url != ''
+ && github.event.pull_request.head.repo.full_name == 'metabase/metabase' }}
+ continue-on-error: true
+ shell: bash
+ env:
+ STATS_JSON: ${{ steps.compute.outputs.stats }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+ BASE_SHA: ${{ github.event.pull_request.base.sha }}
+ ENG_STATS_URL: ${{ inputs.stats-url }}
+ API_KEY: ${{ inputs.stats-api-key }}
+ run: bun .github/scripts/upload-affected-tests-stats.ts
diff --git a/.github/actions/test-driver/action.yml b/.github/actions/test-driver/action.yml
index c03bae6b28d..91660f5459c 100644
--- a/.github/actions/test-driver/action.yml
+++ b/.github/actions/test-driver/action.yml
@@ -150,14 +150,14 @@ runs:
shell: bash
id: run-test
env:
- # Both derived from test.profile-backend.yml, the sole dispatcher; its runs always profile. Inside
- # a called workflow `github.event` is the caller's payload, so these resolve here rather than
- # in each calling workflow. On a normal CI run there are no dispatch inputs, so these render
- # `false` and empty and the job's own selection stands.
+ # PROFILE_TESTS is not set here: the suites that test.profile-backend.yml dispatches set it in
+ # their workflow `env`, which reaches this step. The stress-test workflows are dispatched too
+ # but leave it unset, so they never profile.
#
- # ONLY_TESTS replaces the job's own test selection, so every matrix leg of the chosen job
- # runs the whole list.
- PROFILE_TESTS: ${{ github.event.inputs.suite != '' }}
+ # ONLY_TESTS comes from test.profile-backend.yml. Inside a called workflow `github.event` is
+ # the caller's payload, so it resolves here rather than in each calling workflow. On any
+ # other run it renders empty and the job's own selection stands. It replaces the job's own
+ # test selection, so every matrix leg of the chosen job runs the whole list.
ONLY_TESTS: ${{ github.event.inputs.tests }}
TEST_RUNNER_INDEX: ${{ inputs.runner-index }}
TEST_RUNNER_COUNT: ${{ inputs.runner-count }}
diff --git a/.github/file-paths.yaml b/.github/file-paths.yaml
index e76cdcd49bf..da7d7ad7309 100644
--- a/.github/file-paths.yaml
+++ b/.github/file-paths.yaml
@@ -1,5 +1,5 @@
# Catch-all filter — emits the full changed-files list as `all_changed_files`
-# so create-test-plan in run-tests.yml can reuse dorny's diff.
+# for the create-test-plan action.
all_changed:
- "**"
@@ -23,6 +23,8 @@ shared_ci: &shared_ci
- ".github/actions/prepare-frontend/**"
- ".github/actions/prepare-backend/**"
- ".github/workflows/run-tests.yml"
+ # Every suite's gate calls it, so a change here can turn any suite off.
+ - ".github/workflows/test.gate.yml"
shared_e2e: &shared_e2e
- "e2e/runner/**"
@@ -246,14 +248,14 @@ embedding_sdk_ci: &embedding_sdk_ci
- ".github/actions/prepare-cypress/**"
- ".github/workflows/embedding-sdk*.yml"
-embedding_sdk_components:
+embedding_sdk_components: &embedding_sdk_components
- *default
- *embedding_sdk_ci
- *sources
- *shared_e2e
- "e2e/test-component/**/*.cy.*.{js,jsx,ts,tsx}"
-embedding_sdk_host_sample_apps:
+embedding_sdk_host_sample_apps: &embedding_sdk_host_sample_apps
- *default
- *embedding_sdk_ci
- *frontend_sources
@@ -283,7 +285,7 @@ e2e_infra: &e2e_infra
- ".github/scripts/build-e2e-matrix.js"
- ".github/file-paths.yaml"
-e2e_all:
+e2e_all: &e2e_all
- *default
- *e2e_ci
- *sources
@@ -299,10 +301,28 @@ documentation:
docs:
- "docs/**"
-embedding_documentation:
+embedding_documentation: &embedding_documentation
- ".typedoc/**"
- "docs/embedding/**"
+# Everything the SDK package build feeds, so the build itself follows the union of its consumers.
+build_embedding_sdk_package:
+ - *embedding_sdk_ci
+ - *embedding_sdk_components
+ - *embedding_sdk_host_sample_apps
+ - *embedding_documentation
+ - *frontend_sources
+
+# The uberjar only exists to feed e2e, the SDK suites that boot a Metabase instance, bundle-size and
+# containerize, so it is worth building exactly when one of them might run. The SDK's type checks run
+# against the package artifact alone, so embedding docs do not belong here.
+build_uberjar:
+ - *backend_all
+ - *frontend_all
+ - *e2e_all
+ - *embedding_sdk_components
+ - *embedding_sdk_host_sample_apps
+
yaml:
- "**/*.yml"
- "**/*.yaml"
diff --git a/.github/scripts/file-paths.unit.spec.ts b/.github/scripts/file-paths.unit.spec.ts
index f082680182d..fa528794e0f 100644
--- a/.github/scripts/file-paths.unit.spec.ts
+++ b/.github/scripts/file-paths.unit.spec.ts
@@ -117,6 +117,56 @@ describe("file-paths.yaml", () => {
expect(matches("ci_scripts", path)).toBe(true);
});
+ // Every suite's gate calls the same workflow, so a change to it has to reach every suite.
+ it.each([
+ "backend_all",
+ "frontend_all",
+ "frontend_loki_all",
+ "e2e_all",
+ "embedding_sdk_components",
+ "embedding_sdk_host_sample_apps",
+ "ci_scripts",
+ ])("runs %s when the test gate changes", (filter) => {
+ expect(matches(filter, ".github/workflows/test.gate.yml")).toBe(true);
+ });
+
+ // The build filters replace what used to be an inline condition in run-tests.yml, so what they
+ // leave out is the whole point: a diff that changes nothing an artifact ships gets no build.
+ it.each([
+ "src/metabase/core.clj",
+ "frontend/src/metabase/App.tsx",
+ "e2e/test/scenarios/question/foo.cy.spec.js",
+ // The SDK component and host-app suites boot a Metabase instance, so their CI entry points
+ // have to build one.
+ ".github/workflows/embedding-sdk.yml",
+ ])("builds the uberjar for %s", (path) => {
+ expect(matches("build_uberjar", path)).toBe(true);
+ });
+
+ it.each([
+ ".clj-kondo/ratchets.edn",
+ "README.md",
+ "docs/questions/introduction.md",
+ // The SDK type checks read the package artifact, not a running instance.
+ "docs/embedding/sdk/introduction.md",
+ ])("skips the uberjar for %s", (path) => {
+ expect(matches("build_uberjar", path)).toBe(false);
+ });
+
+ it.each([
+ "enterprise/frontend/src/embedding-sdk-package/index.ts",
+ "docs/embedding/sdk/introduction.md",
+ ".github/workflows/embedding-sdk.yml",
+ ])("builds the SDK package for %s", (path) => {
+ expect(matches("build_embedding_sdk_package", path)).toBe(true);
+ });
+
+ it("does not build the SDK package for unrelated documentation", () => {
+ expect(
+ matches("build_embedding_sdk_package", "docs/questions/introduction.md"),
+ ).toBe(false);
+ });
+
it("runs the ratchet check on the ratchets file", () => {
expect(matches("project_ratchet_checks", ".clj-kondo/ratchets.edn")).toBe(
true,
diff --git a/.github/workflows/app-db.yml b/.github/workflows/app-db.yml
index da8a6515be6..30e8240954f 100644
--- a/.github/workflows/app-db.yml
+++ b/.github/workflows/app-db.yml
@@ -2,14 +2,6 @@ name: App DB Tests
on:
workflow_call:
- inputs:
- skip:
- type: boolean
- default: false
- force-run:
- description: Run the full suite regardless of the diff (master / release branches).
- type: boolean
- default: false
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}-app-db
@@ -21,10 +13,19 @@ concurrency:
env:
CI_CONDUCTOR_BASE_URL: ${{ vars.CI_CONDUCTOR_BASE_URL }}
CI_CONDUCTOR_WEBHOOK_SECRET: ${{ secrets.CI_CONDUCTOR_WEBHOOK_SECRET }}
+ # Read by the test-driver action. This suite is only ever dispatched by test.profile-backend.yml,
+ # so a dispatch is a profiling run.
+ PROFILE_TESTS: ${{ github.event_name == 'workflow_dispatch' }}
jobs:
+ gate:
+ uses: ./.github/workflows/test.gate.yml
+ with:
+ filters: backend_all
+
app-db-matrix:
- if: ${{ !inputs.skip }}
+ needs: gate
+ if: ${{ needs.gate.outputs.run == 'true' }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 5
name: Determine app DB versions
@@ -38,7 +39,7 @@ jobs:
id: versions
uses: actions/github-script@v9
env:
- RUN_ALL: ${{ inputs.force-run }}
+ RUN_ALL: ${{ needs.gate.outputs.force-run }}
with:
script: | # js
const runAll = process.env.RUN_ALL === 'true';
@@ -130,7 +131,6 @@ jobs:
be-tests-mariadb:
needs: app-db-matrix
- if: ${{ !inputs.skip && (github.event.inputs.db == '' || github.event.inputs.db == 'mariadb') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 40
strategy:
@@ -191,7 +191,6 @@ jobs:
be-tests-mysql:
needs: app-db-matrix
- if: ${{ !inputs.skip && (github.event.inputs.db == '' || github.event.inputs.db == 'mysql') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 40
strategy:
@@ -250,7 +249,6 @@ jobs:
be-tests-postgres:
needs: app-db-matrix
- if: ${{ !inputs.skip && (github.event.inputs.db == '' || github.event.inputs.db == 'postgres') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 40
strategy:
@@ -292,6 +290,7 @@ jobs:
app-db-tests-result:
needs:
+ - gate
- app-db-matrix
- be-tests-mariadb
- be-tests-mysql
@@ -299,7 +298,7 @@ jobs:
runs-on: ${{ vars.SLIM_RUNNER_KEY }}
timeout-minutes: 5
name: app-db-tests-result
- if: always() && !cancelled()
+ if: ${{ !cancelled() }}
steps:
- name: Check job status
uses: actions/github-script@v9
diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml
index 6d449ae030e..340dc63c3e6 100644
--- a/.github/workflows/backend.yml
+++ b/.github/workflows/backend.yml
@@ -2,26 +2,6 @@ name: Backend
on:
workflow_call:
- inputs:
- skip:
- type: boolean
- default: false
- force-run:
- description: Run the full suite regardless of the diff (master / release branches).
- type: boolean
- default: false
- run-project-backend-checks:
- description: Run project-level backend checks.
- type: boolean
- default: false
- run-project-migration-checks:
- description: Run project-level migration checks.
- type: boolean
- default: false
- run-project-ratchet-checks:
- description: Run the ratchet check for a diff that touches nothing but the ratchets file.
- type: boolean
- default: false
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}-backend
@@ -35,13 +15,47 @@ env:
CI_CONDUCTOR_WEBHOOK_SECRET: ${{ secrets.CI_CONDUCTOR_WEBHOOK_SECRET }}
jobs:
+ gate:
+ uses: ./.github/workflows/test.gate.yml
+ with:
+ filters: backend_all project_backend_checks project_migration_checks project_ratchet_checks
+
+ # Generated static-viz output can shift without any backend source changing, so the suite follows
+ # it too. Only worth probing when nothing else has already decided the suite.
+ static-viz-files-changed:
+ name: Check whether static-viz files changed
+ needs: gate
+ if: >-
+ ${{ needs.gate.outputs.verdict == 'defer'
+ && !contains(fromJSON(needs.gate.outputs.matched), 'backend_all') }}
+ runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
+ timeout-minutes: 10
+ outputs:
+ static_viz: ${{ steps.static_viz.outputs.static_viz }}
+ steps:
+ - uses: actions/checkout@v7
+ - name: Prepare front-end environment
+ uses: ./.github/actions/prepare-frontend
+ - name: Prepare back-end environment
+ uses: ./.github/actions/prepare-backend
+ - name: Build static-viz frontend
+ run: bun run build-static-viz
+ env:
+ MB_EDITION: ee
+ - name: Check for static viz changes
+ uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
+ id: static_viz
+ with:
+ token: ${{ github.token }}
+ filters: .github/static-viz-sources.yaml
+
project-checks:
name: 'Project tests: Suites'
+ needs: gate
if: >-
- ${{ inputs.force-run ||
- inputs.run-project-backend-checks ||
- inputs.run-project-migration-checks ||
- inputs.run-project-ratchet-checks }}
+ ${{ contains(fromJSON(needs.gate.outputs.matched), 'project_backend_checks')
+ || contains(fromJSON(needs.gate.outputs.matched), 'project_migration_checks')
+ || contains(fromJSON(needs.gate.outputs.matched), 'project_ratchet_checks') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 15
steps:
@@ -53,21 +67,23 @@ jobs:
run: ./bin/mage
- parallel:
- name: Run backend checks
- if: ${{ inputs.force-run || inputs.run-project-backend-checks }}
+ if: ${{ contains(fromJSON(needs.gate.outputs.matched), 'project_backend_checks') }}
run: ./bin/mage project-tests backend
- name: Run migration checks
- if: ${{ inputs.force-run || inputs.run-project-migration-checks }}
+ if: ${{ contains(fromJSON(needs.gate.outputs.matched), 'project_migration_checks') }}
run: ./bin/mage project-tests migrations
# Babashka plus a scoped clj-kondo run, not a JVM test run, so it is cheap enough to run alongside the
# backend checks. It needs the JDK and Clojure CLI prepare-backend installs.
- name: Run ratchet checks
- if: ${{ inputs.force-run || inputs.run-project-backend-checks || inputs.run-project-ratchet-checks }}
+ if: >-
+ ${{ contains(fromJSON(needs.gate.outputs.matched), 'project_backend_checks')
+ || contains(fromJSON(needs.gate.outputs.matched), 'project_ratchet_checks') }}
run: ./bin/mage kondo-ratchets
project-tests:
name: Project tests
needs: project-checks
- if: ${{ always() && !cancelled() }}
+ if: ${{ !cancelled() }}
runs-on: ${{ vars.SLIM_RUNNER_KEY }}
timeout-minutes: 5
steps:
@@ -125,7 +141,14 @@ jobs:
process.exit(1);
be-linter-clj-kondo:
- if: ${{ !inputs.skip }}
+ needs: &backend-gate-needs [gate, static-viz-files-changed]
+ # `!cancelled()` so a skipped static-viz probe -- the suite was already decided -- does not skip
+ # this job; its failure still does.
+ if: &backend-gate >-
+ ${{ !cancelled() && needs.gate.result == 'success'
+ && needs.static-viz-files-changed.result != 'failure'
+ && (contains(fromJSON(needs.gate.outputs.matched), 'backend_all')
+ || needs.static-viz-files-changed.outputs.static_viz == 'true') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 10
name: Clj-Kondo
@@ -137,9 +160,10 @@ jobs:
run: ./bin/mage kondo
be-linter-eastwood:
- if: ${{ !inputs.skip }}
+ needs: *backend-gate-needs
+ if: *backend-gate
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
- timeout-minutes: 20
+ timeout-minutes: 30
name: Eastwood
steps:
- uses: actions/checkout@v7
@@ -149,10 +173,14 @@ jobs:
name: Run Eastwood linter
be-linter-eastwood-test:
- # Master / release safety net: lint every backend test namespace.
- if: ${{ !inputs.skip && inputs.force-run }}
+ # Master / release safety net: lint every backend test namespace. A force-run never probes
+ # static-viz, so the gate alone decides this one.
+ needs: gate
+ if: >-
+ ${{ needs.gate.outputs.force-run == 'true'
+ && contains(fromJSON(needs.gate.outputs.matched), 'backend_all') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
- timeout-minutes: 45
+ timeout-minutes: 50
name: Eastwood (tests only)
steps:
- uses: actions/checkout@v7
@@ -163,7 +191,13 @@ jobs:
be-linter-eastwood-test-changed:
# Lint only the test namespaces touched by the diff.
- if: ${{ !inputs.skip && !inputs.force-run && github.event_name == 'pull_request' }}
+ needs: *backend-gate-needs
+ if: >-
+ ${{ !cancelled() && needs.gate.result == 'success'
+ && needs.static-viz-files-changed.result != 'failure'
+ && needs.gate.outputs.force-run != 'true' && github.event_name == 'pull_request'
+ && (contains(fromJSON(needs.gate.outputs.matched), 'backend_all')
+ || needs.static-viz-files-changed.outputs.static_viz == 'true') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 15
name: Eastwood (changed tests only)
@@ -228,7 +262,8 @@ jobs:
run: clojure -X:dev:dev/test:ee:ee-dev:drivers:drivers-dev:test:eastwood/test :namespaces "[$NAMESPACES]"
be-tests:
- if: ${{ !inputs.skip }}
+ needs: *backend-gate-needs
+ if: *backend-gate
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 40
strategy:
@@ -352,14 +387,14 @@ jobs:
$BASE :exclude-tags '[:mb/driver-tests ${{ env.__ADDITIONAL_EXCLUDED_TAG__ }}]' ${{ matrix.job.test-args }}
fi
env:
- # Both derived from test.profile-backend.yml, the sole dispatcher; its runs always profile. On a
- # normal CI run there are no dispatch inputs, so these render `false` and empty and the
+ # Both come from test.profile-backend.yml, the only workflow that dispatches this suite, so a
+ # dispatch is a profiling run. On a normal CI run these render `false` and empty and the
# leg's own selection stands.
#
# ONLY_TESTS replaces the leg's own test selection, so every matrix leg runs the whole
# list: the partition args no longer apply, and legs that hold none of the named tests run
# nothing.
- PROFILE_TESTS: ${{ github.event.inputs.suite != '' }}
+ PROFILE_TESTS: ${{ github.event_name == 'workflow_dispatch' }}
ONLY_TESTS: ${{ github.event.inputs.tests }}
# Keep this step continue-on-error because the quarantine logic controls whether it ultimately fails.
continue-on-error: true
@@ -435,7 +470,8 @@ jobs:
# checks that all the namespaces we actually ship can be compiled, without any dependencies that we don't ship (such
# as `:dev` dependencies). See #27009 for more context.
be-check:
- if: ${{ !inputs.skip }}
+ needs: *backend-gate-needs
+ if: *backend-gate
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 10
strategy:
@@ -451,7 +487,8 @@ jobs:
run: clojure -M:ee:drivers:load-namespaces
be-cljfmt:
- if: ${{ !inputs.skip }}
+ needs: *backend-gate-needs
+ if: *backend-gate
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 10
name: Cljfmt
@@ -464,6 +501,8 @@ jobs:
be-tests-result:
needs:
+ - gate
+ - static-viz-files-changed
- project-tests
- be-linter-eastwood
- be-linter-eastwood-test
@@ -472,7 +511,7 @@ jobs:
- be-cljfmt
- be-check
- be-tests
- if: always() && !cancelled()
+ if: ${{ !cancelled() }}
runs-on: ${{ vars.SLIM_RUNNER_KEY }}
timeout-minutes: 5
env:
diff --git a/.github/workflows/build-scripts.yml b/.github/workflows/build-scripts.yml
index bffb46d9a3c..8e66a53ec26 100644
--- a/.github/workflows/build-scripts.yml
+++ b/.github/workflows/build-scripts.yml
@@ -2,18 +2,16 @@ name: Build scripts
on:
workflow_call:
- inputs:
- skip-build-scripts:
- type: boolean
- default: false
- skip-embedder-plugin:
- type: boolean
- default: false
jobs:
+ gate:
+ uses: ./.github/workflows/test.gate.yml
+ with:
+ filters: build_scripts embedder_plugin
test-embedder-plugin:
- if: ${{ !inputs.skip-embedder-plugin }}
+ needs: gate
+ if: ${{ contains(fromJSON(needs.gate.outputs.matched), 'embedder_plugin') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 20
permissions:
@@ -63,7 +61,8 @@ jobs:
'[metabase-enterprise.semantic-search.appdb-pgvector-mode-test/appdb-pgvector-in-process-embedder-round-trip-test]'
test-build-scripts:
- if: ${{ !inputs.skip-build-scripts }}
+ needs: gate
+ if: ${{ contains(fromJSON(needs.gate.outputs.matched), 'build_scripts') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 40
steps:
diff --git a/.github/workflows/bundle-size.yml b/.github/workflows/bundle-size.yml
index ba6ecfba10a..2bd12aa3029 100644
--- a/.github/workflows/bundle-size.yml
+++ b/.github/workflows/bundle-size.yml
@@ -13,8 +13,18 @@ concurrency:
cancel-in-progress: true
jobs:
+ gate:
+ uses: ./.github/workflows/test.gate.yml
+ with:
+ filters: frontend_sources
+
bundle-size-check:
name: "Bundle size check"
+ needs: gate
+ # There is no base uberjar to compare against outside a pull request.
+ if: >-
+ ${{ github.event_name == 'pull_request'
+ && contains(fromJSON(needs.gate.outputs.matched), 'frontend_sources') }}
continue-on-error: true
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 20
diff --git a/.github/workflows/drivers.yml b/.github/workflows/drivers.yml
index e02c4002dec..96981067b0a 100644
--- a/.github/workflows/drivers.yml
+++ b/.github/workflows/drivers.yml
@@ -2,14 +2,6 @@ name: Driver Tests
on:
workflow_call:
- inputs:
- skip:
- type: boolean
- default: false
- force-run:
- description: Run the full suite regardless of the diff (master / release branches, ci:run-all label).
- type: boolean
- default: false
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}-drivers
@@ -21,11 +13,21 @@ concurrency:
env:
CI_CONDUCTOR_BASE_URL: ${{ vars.CI_CONDUCTOR_BASE_URL }}
CI_CONDUCTOR_WEBHOOK_SECRET: ${{ secrets.CI_CONDUCTOR_WEBHOOK_SECRET }}
+ # Read by the test-driver action. This suite is only ever dispatched by test.profile-backend.yml,
+ # so a dispatch is a profiling run.
+ PROFILE_TESTS: ${{ github.event_name == 'workflow_dispatch' }}
jobs:
+ gate:
+ uses: ./.github/workflows/test.gate.yml
+ with:
+ filters: backend_all
+
# This job determines which driver tests should run based on PR context.
# All decision logic is consolidated in mage driver-decisions.
determine-driver-skips:
+ needs: gate
+ if: ${{ needs.gate.outputs.run == 'true' }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 10
outputs:
@@ -69,8 +71,6 @@ jobs:
--git-ref="${BASE_REF}"
--force-run="${FORCE_RUN}"
--pr-labels="${{ join(github.event.pull_request.labels.*.name, ',') }}"
- --skip="${{ inputs.skip }}"
- --only-driver="${PROFILE_DRIVER}"
)
echo "Running:"
echo "./bin/mage -driver-decisions ${MAGE_ARGS[*]}"
@@ -84,10 +84,7 @@ jobs:
./bin/mage -driver-decisions "${MAGE_ARGS[@]}" --github-output-only >> "$GITHUB_OUTPUT"
env:
BASE_REF: ${{ github.event.pull_request.base.ref || github.ref_name }}
- FORCE_RUN: ${{ inputs.force-run }}
- # Set only by test.profile-backend.yml. Absent on a normal CI run, which leaves the decision rules
- # alone; mage rejects a name that is not a driver.
- PROFILE_DRIVER: ${{ github.event.inputs.db }}
+ FORCE_RUN: ${{ needs.gate.outputs.force-run == 'true' }}
shell: bash
be-tests-athena-ee:
@@ -1247,6 +1244,7 @@ jobs:
drivers-tests-result:
needs:
+ - gate
- determine-driver-skips
# if you add a driver job, you must add it to this list for it to be a required check
- be-tests-athena-ee
@@ -1274,7 +1272,7 @@ jobs:
runs-on: ${{ vars.SLIM_RUNNER_KEY }}
timeout-minutes: 5
name: drivers-tests-result
- if: always() && !cancelled()
+ if: ${{ !cancelled() }}
steps:
- name: Check job status
uses: actions/github-script@v9
@@ -1284,8 +1282,8 @@ jobs:
script: | # js
const needs = JSON.parse(process.env.needs);
- // Drop the determine-driver-skips bookkeeping job; every remaining job is a driver
- // job whose result gates this check.
+ // Drop the determine-driver-skips bookkeeping job; the rest -- the gate and the
+ // driver jobs -- gate this check.
const jobs = Object.entries(needs)
.filter(([jobName]) => jobName !== 'determine-driver-skips')
.map(([jobName, jobValues]) => ({
diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml
index 79a50883a9b..58f327634c0 100644
--- a/.github/workflows/e2e-tests.yml
+++ b/.github/workflows/e2e-tests.yml
@@ -3,9 +3,6 @@ name: E2E Tests
on:
workflow_call:
inputs:
- skip:
- type: boolean
- default: false
test-plan-artifact-id:
description: "ID of this run's test-plan.json artifact, '' to run the full suite."
type: string
@@ -17,8 +14,14 @@ concurrency:
cancel-in-progress: true
jobs:
+ gate:
+ uses: ./.github/workflows/test.gate.yml
+ with:
+ filters: e2e_all
+
e2e-matrix-builder:
- if: ${{ !inputs.skip }}
+ needs: gate
+ if: ${{ needs.gate.outputs.run == 'true' }}
uses: ./.github/workflows/e2e-matrix-builder.yml
with:
chunks: 50
@@ -60,10 +63,9 @@ jobs:
uses: ./.github/workflows/e2e-test.yml
needs:
- e2e-matrix-builder
- if: |
- !cancelled() && !inputs.skip &&
- needs.e2e-matrix-builder.result == 'success' &&
- needs.e2e-matrix-builder.outputs.hasTests == 'true'
+ # No status function, so a skipped or failed matrix builder keeps this out: the strategy below
+ # cannot parse a matrix it never produced. The builder itself only runs when the gate says so.
+ if: ${{ needs.e2e-matrix-builder.outputs.hasTests == 'true' }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.e2e-matrix-builder.outputs.matrix) }}
@@ -83,7 +85,7 @@ jobs:
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 10
needs: e2e-tests
- if: always() && !cancelled() && github.ref == 'refs/heads/master'
+ if: ${{ !cancelled() && github.ref == 'refs/heads/master' }}
steps:
- uses: actions/checkout@v7
with:
@@ -142,21 +144,26 @@ jobs:
e2e-tests-result:
needs:
+ - gate
- e2e-matrix-builder
- e2e-tests
runs-on: ${{ vars.SLIM_RUNNER_KEY }}
timeout-minutes: 5
name: e2e-tests-result
- if: always() && !cancelled()
+ if: ${{ !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 }}
+ GATE_RESULT: ${{ needs.gate.result }}
+ RUN: ${{ needs.gate.outputs.run }}
steps:
- name: Test results
run: | # sh
- if [ "$SKIP" = "true" ]; then
+ if [ "$GATE_RESULT" != "success" ]; then
+ echo "The test gate failed, so the suite never ran"
+ exit 1
+ elif [ "$RUN" != "true" ]; then
echo "Didn't run due to conditional filtering"
elif [ "$MATRIX_RESULT" != "success" ]; then
echo "E2E matrix builder failed"
diff --git a/.github/workflows/embedding-sdk.yml b/.github/workflows/embedding-sdk.yml
index fcec19b46f3..1bdf6f1693a 100644
--- a/.github/workflows/embedding-sdk.yml
+++ b/.github/workflows/embedding-sdk.yml
@@ -2,39 +2,23 @@ name: SDK
on:
workflow_call:
- inputs:
- cli-snippets-type-check:
- description: "Whether to run cli snippets type check."
- required: true
- type: boolean
- docs-snippets-type-check:
- description: "Whether to run docs snippets type check."
- required: true
- type: boolean
- documentation-validation:
- description: "Whether to run documentation generation validation check."
- required: true
- type: boolean
- component-tests:
- description: "Whether to run component tests."
- required: true
- type: boolean
- host-sample-apps-tests:
- description: "Whether to run host and sample apps compatibility tests."
- required: true
- type: boolean
- skip:
- description: Whether to skip running tests due to one of the artifacts failing to build.
- required: true
- type: boolean
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
cancel-in-progress: true
jobs:
+ # Each job below maps to its own filter, so they read `matched` rather than `run`.
+ gate:
+ uses: ./.github/workflows/test.gate.yml
+ with:
+ filters: >-
+ frontend_sources embedding_documentation embedding_sdk_components
+ embedding_sdk_host_sample_apps
+
embedding-sdk-cli-snippets-type-check:
- if: inputs.cli-snippets-type-check && !inputs.skip
+ needs: gate
+ if: ${{ contains(fromJSON(needs.gate.outputs.matched), 'frontend_sources') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 20
steps:
@@ -50,7 +34,8 @@ jobs:
run: bun run embedding-sdk:cli-snippets:type-check
embedding-sdk-docs-snippets-type-check:
- if: inputs.docs-snippets-type-check && !inputs.skip
+ needs: gate
+ if: ${{ contains(fromJSON(needs.gate.outputs.matched), 'embedding_documentation') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 20
steps:
@@ -66,7 +51,8 @@ jobs:
run: bun run embedding-sdk:docs-snippets:type-check
embedding-sdk-api-documentation-generation-validation:
- if: inputs.documentation-validation && !inputs.skip
+ needs: gate
+ if: ${{ contains(fromJSON(needs.gate.outputs.matched), 'frontend_sources') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 20
steps:
@@ -116,23 +102,26 @@ jobs:
# See `Component e2e tests` in `enterprise/frontend/src/embedding-sdk-package/dev.md`
embedding-sdk-component-tests:
name: "SDK component tests"
- if: inputs.component-tests && !inputs.skip
+ needs: gate
+ if: ${{ contains(fromJSON(needs.gate.outputs.matched), 'embedding_sdk_components') }}
uses: ./.github/workflows/embedding-sdk-component-tests.yml
secrets: inherit
not-required-embedding-sdk-apps-compatibility-tests:
name: "SDK e2e tests for compatibility with (host/sample) apps"
- if: inputs.host-sample-apps-tests && !inputs.skip
+ needs: gate
+ if: ${{ contains(fromJSON(needs.gate.outputs.matched), 'embedding_sdk_host_sample_apps') }}
uses: ./.github/workflows/embedding-sdk-host-sample-apps-tests.yml
secrets: inherit
embedding-sdk-tests-result:
needs:
+ - gate
- embedding-sdk-cli-snippets-type-check
- embedding-sdk-docs-snippets-type-check
- embedding-sdk-api-documentation-generation-validation
- embedding-sdk-component-tests
- if: always() && !cancelled()
+ if: ${{ !cancelled() }}
runs-on: ${{ vars.SLIM_RUNNER_KEY }}
timeout-minutes: 5
env:
diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml
index 4f09a889a20..cff2f107122 100644
--- a/.github/workflows/frontend.yml
+++ b/.github/workflows/frontend.yml
@@ -3,36 +3,10 @@ name: Frontend
on:
workflow_call:
inputs:
- skip:
- type: boolean
- default: false
- skip-lint:
- type: boolean
- default: false
- skip-custom-viz:
- type: boolean
- default: false
# ID of this run's test-plan.json artifact, or '' to run the full suite.
test-plan-artifact-id:
type: string
default: ""
- skip-ci-scripts:
- type: boolean
- default: false
- workflow_dispatch:
- inputs:
- skip:
- description: "Skip main frontend jobs (type-check, unit tests, timezone tests)"
- type: boolean
- default: false
- skip-lint:
- description: "Skip linting jobs (oxfmt, oxlint, css variables check)"
- type: boolean
- default: false
- skip-custom-viz:
- description: "Skip custom-viz package tests"
- type: boolean
- default: false
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}-frontend
@@ -46,8 +20,18 @@ env:
CI_CONDUCTOR_WEBHOOK_SECRET: ${{ secrets.CI_CONDUCTOR_WEBHOOK_SECRET }}
jobs:
+ # Each job below maps to its own filter, so they read `matched` rather than `run`.
+ gate:
+ uses: ./.github/workflows/test.gate.yml
+ with:
+ filters: frontend_all e2e_all custom_viz_all ci_scripts
+
fe-lint:
- if: ${{ !inputs.skip-lint }}
+ needs: gate
+ # Linting covers the e2e specs too.
+ if: >-
+ ${{ contains(fromJSON(needs.gate.outputs.matched), 'frontend_all')
+ || contains(fromJSON(needs.gate.outputs.matched), 'e2e_all') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 20
steps:
@@ -71,7 +55,8 @@ jobs:
run: bun run lint-css
fe-type-check:
- if: ${{ !inputs.skip }}
+ needs: gate
+ if: ${{ contains(fromJSON(needs.gate.outputs.matched), 'frontend_all') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 10
steps:
@@ -86,7 +71,8 @@ jobs:
name: Check types
fe-tests-unit:
- if: ${{ !inputs.skip }}
+ needs: gate
+ if: ${{ contains(fromJSON(needs.gate.outputs.matched), 'frontend_all') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 30
strategy:
@@ -150,7 +136,8 @@ jobs:
enforce-quarantine: ${{ vars.QUARANTINE_ENGINE == 'ci-conductor' }}
fe-tests-timezones:
- if: ${{ !inputs.skip }}
+ needs: gate
+ if: ${{ contains(fromJSON(needs.gate.outputs.matched), 'frontend_all') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 20
steps:
@@ -162,7 +149,8 @@ jobs:
# No CLJS compile: the CI-script specs don't import app code.
fe-tests-ci-scripts:
- if: ${{ !inputs.skip-ci-scripts }}
+ needs: gate
+ if: ${{ contains(fromJSON(needs.gate.outputs.matched), 'ci_scripts') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 10
steps:
@@ -175,7 +163,8 @@ jobs:
# The custom-viz package is an isolated Bun workspace under
# enterprise/frontend/src/custom-viz
fe-custom-viz:
- if: ${{ !inputs.skip-custom-viz }}
+ needs: gate
+ if: ${{ contains(fromJSON(needs.gate.outputs.matched), 'custom_viz_all') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 10
defaults:
@@ -198,13 +187,14 @@ jobs:
fe-tests-result:
needs:
+ - gate
- fe-lint
- fe-type-check
- fe-tests-unit
- fe-tests-timezones
- fe-tests-ci-scripts
- fe-custom-viz
- if: always() && !cancelled()
+ if: ${{ !cancelled() }}
runs-on: ${{ vars.SLIM_RUNNER_KEY }}
timeout-minutes: 5
env:
diff --git a/.github/workflows/loki.yml b/.github/workflows/loki.yml
index e7296fc2885..a54e70d5827 100644
--- a/.github/workflows/loki.yml
+++ b/.github/workflows/loki.yml
@@ -3,10 +3,6 @@ name: Loki Visual Regression Testing
on:
workflow_call:
inputs:
- skip:
- description: "Skip the Loki visual tests."
- type: boolean
- default: false
test-plan-artifact-id:
description: "ID of this run's test-plan.json artifact, or '' to run the full suite."
type: string
@@ -17,8 +13,15 @@ concurrency:
cancel-in-progress: true
jobs:
+ gate:
+ uses: ./.github/workflows/test.gate.yml
+ with:
+ filters: frontend_loki_all
+
+ # Without a plan there is nothing to narrow, so this is skipped and every story runs.
story-selection:
- if: ${{ !inputs.skip && inputs.test-plan-artifact-id != '' }}
+ needs: gate
+ if: ${{ needs.gate.outputs.run == 'true' && inputs.test-plan-artifact-id != '' }}
runs-on: ${{ vars.SLIM_RUNNER_KEY }}
timeout-minutes: 5
outputs:
@@ -46,10 +49,14 @@ jobs:
visual-test:
name: loki-run
- needs: story-selection
- # A missing job output compares equal to '0' in GitHub expressions,
- # so an empty selection is marked with a non-numeric value.
- if: ${{ !cancelled() && !inputs.skip && needs.story-selection.outputs.selection != 'empty' }}
+ needs: [gate, story-selection]
+ # `!cancelled()` so a skipped selection (no plan) still runs every story. A missing job output
+ # compares equal to '0' in GitHub expressions, so an empty selection is marked with a
+ # non-numeric value.
+ if: >-
+ ${{ !cancelled() && needs.gate.outputs.run == 'true'
+ && needs.story-selection.result != 'failure'
+ && needs.story-selection.outputs.selection != 'empty' }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 30
services:
@@ -110,8 +117,8 @@ jobs:
loki-tests-result:
name: visual-test
- needs: [story-selection, visual-test]
- if: always() && !cancelled()
+ needs: [gate, story-selection, visual-test]
+ if: ${{ !cancelled() }}
runs-on: ${{ vars.SLIM_RUNNER_KEY }}
timeout-minutes: 5
steps:
diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml
index bfa880ca255..6ec114810a0 100644
--- a/.github/workflows/run-tests.yml
+++ b/.github/workflows/run-tests.yml
@@ -7,7 +7,6 @@ on:
- "release-**"
pull_request:
types: [opened, synchronize, reopened]
- workflow_dispatch:
permissions:
id-token: write
@@ -18,153 +17,53 @@ permissions:
security-events: write
jobs:
- # `force-run` and `force-skip` are global overrides; `defer` means this
- # job has no opinion and every downstream gate behaves as it always has.
- #
- # Only the lowest unmerged PR of a stack runs CI: it is the one whose base
- # ref is the stack base. Every PR above it is force-skipped and gets tested
- # once it reaches the bottom of the stack.
- should-run:
- name: Decide which jobs should run
- runs-on: ${{ vars.SLIM_RUNNER_KEY }}
- timeout-minutes: 5
- outputs:
- verdict: ${{ steps.decide.outputs.verdict }}
- steps:
- - name: Decide
- id: decide
- # Precedence matters for the conditions below.
- env:
- VERDICT: >-
- ${{ (github.ref_name == 'master' || startsWith(github.ref_name, 'release-x.')) && 'force-run'
- || contains(github.event.pull_request.labels.*.name, 'ci:run-all') && 'force-run'
- || contains(github.event.pull_request.labels.*.name, 'ci:skip') && 'force-skip'
- || (github.event.pull_request.stack != null && github.event.pull_request.stack.base.ref != github.event.pull_request.base.ref) && 'force-skip'
- || 'defer' }}
- run: echo "verdict=$VERDICT" | tee -a "$GITHUB_OUTPUT"
-
- files-changed:
- needs: should-run
- name: Detect changed files
- if: ${{ needs.should-run.outputs.verdict == 'defer' }}
- runs-on: ${{ vars.SLIM_RUNNER_KEY }}
- timeout-minutes: 5
- outputs:
- e2e_all: ${{ steps.changes.outputs.e2e_all }}
- e2e_specs: ${{ steps.changes.outputs.e2e_specs }}
- e2e_infra: ${{ steps.changes.outputs.e2e_infra }}
- backend_all: ${{ steps.changes.outputs.backend_all }}
- build_scripts: ${{ steps.changes.outputs.build_scripts }}
- embedder_plugin: ${{ steps.changes.outputs.embedder_plugin }}
- frontend_all: ${{ steps.changes.outputs.frontend_all }}
- frontend_sources: ${{ steps.changes.outputs.frontend_sources }}
- frontend_unit_infra: ${{ steps.changes.outputs.frontend_unit_infra }}
- frontend_loki_infra: ${{ steps.changes.outputs.frontend_loki_infra }}
- frontend_loki_all: ${{ steps.changes.outputs.frontend_loki_all }}
- shared_sources: ${{ steps.changes.outputs.shared_sources }}
- documentation: ${{ steps.changes.outputs.documentation }}
- embedding_documentation: ${{ steps.changes.outputs.embedding_documentation }}
- embedding_sdk_components: ${{ steps.changes.outputs.embedding_sdk_components }}
- embedding_sdk_host_sample_apps: ${{ steps.changes.outputs.embedding_sdk_host_sample_apps }}
- embedding_sdk_ci: ${{ steps.changes.outputs.embedding_sdk_ci }}
- custom_viz_all: ${{ steps.changes.outputs.custom_viz_all }}
- ci_scripts: ${{ steps.changes.outputs.ci_scripts }}
- project_backend_checks: ${{ steps.changes.outputs.project_backend_checks }}
- project_migration_checks: ${{ steps.changes.outputs.project_migration_checks }}
- project_ratchet_checks: ${{ steps.changes.outputs.project_ratchet_checks }}
- # A ratchets-only change (the shrink automation PR) needs the ratchet check, not an uberjar.
- no_source_code_changes: >-
- ${{ (steps.changes.outputs.documentation == 'true'
- || steps.changes.outputs.project_ratchet_checks == 'true')
- && steps.changes.outputs.backend_all == 'false'
- && steps.changes.outputs.frontend_all == 'false'
- && steps.changes.outputs.e2e_all == 'false' }}
-
- all_changed_files: ${{ steps.changes.outputs.all_changed_files }}
- e2e_all_files: ${{ steps.changes.outputs.e2e_all_files }}
- e2e_specs_files: ${{ steps.changes.outputs.e2e_specs_files }}
- frontend_sources_files: ${{ steps.changes.outputs.frontend_sources_files }}
- backend_sources_files: ${{ steps.changes.outputs.backend_sources_files }}
- steps:
- - uses: actions/checkout@v7
- - name: Test which files changed
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
- id: changes
- with:
- token: ${{ github.token }}
- # comma separated list of files
- list-files: csv
- filters: .github/file-paths.yaml
+ # Force-cancel is the only decision left here. The jobs below read `matched`;
+ # each suite that owns its gating calls the gate itself with the filters it cares about.
+ gate:
+ uses: ./.github/workflows/test.gate.yml
+ with:
+ filters: build_embedding_sdk_package build_uberjar e2e_all
+ # The plan only ever narrows a PR's suites; every other run skips this and they run in full. A
+ # planner failure does the same, so it must not fail the run either.
create-test-plan:
- needs: [should-run, files-changed]
+ needs: gate
name: Create test plan
- if: ${{ github.event_name == 'pull_request' && needs.should-run.outputs.verdict == 'defer' }}
+ if: ${{ github.event_name == 'pull_request' && needs.gate.outputs.verdict == 'defer' }}
+ continue-on-error: true
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 10
outputs:
- stats: ${{ steps.compute.outputs.stats }}
- artifact-id: ${{ steps.compute.outputs.artifact-id }}
+ # The artifact is uploaded before the planner's last steps, so a later failure would otherwise
+ # hand the suites a plan from a run that errored. Anything short of a clean run means no plan.
+ artifact-id: ${{ steps.compute.outcome == 'success' && steps.compute.outputs.artifact-id || '' }}
steps:
- uses: actions/checkout@v7
- name: Create test plan
id: compute
uses: ./.github/actions/create-test-plan
with:
- changed-files: ${{ needs.files-changed.outputs.all_changed_files }}
- fe-changed-files: ${{ needs.files-changed.outputs.frontend_sources_files }}
- be-changed-files: ${{ needs.files-changed.outputs.backend_sources_files }}
- unit-infra-touched: ${{ needs.files-changed.outputs.frontend_unit_infra }}
- loki-infra-touched: ${{ needs.files-changed.outputs.frontend_loki_infra }}
- e2e-infra-touched: ${{ needs.files-changed.outputs.e2e_infra }}
- shared-sources-touched: ${{ needs.files-changed.outputs.shared_sources }}
-
- upload-affected-tests-stats:
- needs: create-test-plan
- # Only land rows for PRs from the upstream repo so forks don't pollute the table.
- if: |
- !cancelled() &&
- needs.create-test-plan.result == 'success' &&
- github.event.pull_request.head.repo.full_name == 'metabase/metabase'
- # Stats upload is best-effort — a failure here shouldn't fail the PR run.
- continue-on-error: true
- runs-on: ${{ vars.SLIM_RUNNER_KEY }}
- timeout-minutes: 3
- steps:
- - uses: actions/checkout@v7
- - uses: ./.github/actions/prepare-node-bun
- - name: Upload affected tests stats
- env:
- STATS_JSON: ${{ needs.create-test-plan.outputs.stats }}
- PR_NUMBER: ${{ github.event.pull_request.number }}
- HEAD_SHA: ${{ github.event.pull_request.head.sha }}
- BASE_SHA: ${{ github.event.pull_request.base.sha }}
- ENG_STATS_URL: ${{ secrets.ENG_STATS_URL }}
- API_KEY: ${{ secrets.ENG_STATS_API_KEY }}
- run: bun .github/scripts/upload-affected-tests-stats.ts
+ stats-url: ${{ secrets.ENG_STATS_URL }}
+ stats-api-key: ${{ secrets.ENG_STATS_API_KEY }}
uberjar:
- needs: [should-run, files-changed]
- if: |
- !cancelled() && needs.should-run.outputs.verdict != 'force-skip' &&
- (needs.should-run.outputs.verdict == 'force-run' ||
- needs.files-changed.outputs.no_source_code_changes != 'true')
+ needs: gate
+ if: >-
+ ${{ needs.gate.outputs.verdict != 'force-skip'
+ && contains(fromJSON(needs.gate.outputs.matched), 'build_uberjar') }}
uses: ./.github/workflows/uberjar.yml
secrets: inherit
containerize:
- needs: [uberjar]
+ needs: uberjar
if: >-
- !cancelled() &&
- needs.uberjar.result == 'success' &&
- (
- (github.event_name == 'push' && github.ref_name == 'master') ||
- (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'build-docker-uberjar'))
- )
+ ${{ (github.event_name == 'push' && github.ref_name == 'master')
+ || (github.event_name == 'pull_request'
+ && contains(github.event.pull_request.labels.*.name, 'build-docker-uberjar')) }}
name: containerize (${{ matrix.edition }})
strategy:
matrix:
- edition: ['ee', 'oss']
+ edition: ["ee", "oss"]
uses: ./.github/workflows/containerize-jar.yml
secrets: inherit
with:
@@ -174,16 +73,17 @@ jobs:
edition: ${{ matrix.edition }}
release: false
+ bundle-size:
+ needs: uberjar
+ uses: ./.github/workflows/bundle-size.yml
+ secrets: inherit
+
# Compile CLJS in parallel with the uberjar and pass it to each e2e group.
# The compile is doesn't depend on MB_EDITION
e2e-cljs:
name: Compile CLJS for e2e
- needs: [should-run, files-changed]
- if: |
- !cancelled() &&
- (needs.should-run.outputs.verdict == 'force-run' ||
- (needs.files-changed.result == 'success' &&
- needs.files-changed.outputs.e2e_all == 'true'))
+ needs: gate
+ if: ${{ contains(fromJSON(needs.gate.outputs.matched), 'e2e_all') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 15
steps:
@@ -204,223 +104,100 @@ jobs:
# replace it rather than fail on a re-run.
overwrite: true
- static-viz-files-changed:
- name: Check whether static-viz files changed
- needs: should-run
- # Its only consumer is the backend skip gate, which a force-run overrides.
- if: ${{ needs.should-run.outputs.verdict == 'defer' }}
- runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
- timeout-minutes: 10
- outputs:
- static_viz: ${{ steps.static_viz.outputs.static_viz }}
- steps:
- - uses: actions/checkout@v7
- - name: Prepare front-end environment
- uses: ./.github/actions/prepare-frontend
- - name: Prepare back-end environment
- uses: ./.github/actions/prepare-backend
- - name: Build static-viz frontend
- run: bun run build-static-viz
- env:
- MB_EDITION: ee
- - name: Check for static viz changes
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
- id: static_viz
- with:
- token: ${{ github.token }}
- filters: .github/static-viz-sources.yaml
-
backend-tests:
- if: |
- !cancelled() &&
- (needs.should-run.outputs.verdict == 'force-run' ||
- needs.files-changed.result == 'success')
- needs: [should-run, files-changed, static-viz-files-changed]
+ needs: gate
+ if: ${{ needs.gate.outputs.verdict != 'force-skip' }}
uses: ./.github/workflows/backend.yml
secrets: inherit
- with:
- skip: >-
- ${{ needs.should-run.outputs.verdict != 'force-run' &&
- needs.files-changed.outputs.backend_all != 'true' &&
- needs.static-viz-files-changed.outputs.static_viz != 'true' }}
- force-run: ${{ needs.should-run.outputs.verdict == 'force-run' }}
- run-project-backend-checks: ${{ needs.files-changed.outputs.project_backend_checks == 'true' }}
- run-project-migration-checks: ${{ needs.files-changed.outputs.project_migration_checks == 'true' }}
- run-project-ratchet-checks: ${{ needs.files-changed.outputs.project_ratchet_checks == 'true' }}
+ # These suites gate themselves; the only thing decided here is whether to call them at all.
semantic-search-tests:
- if: |
- !cancelled() &&
- (needs.should-run.outputs.verdict == 'force-run' ||
- needs.files-changed.result == 'success')
- needs: [should-run, files-changed]
+ needs: gate
+ if: ${{ needs.gate.outputs.verdict != 'force-skip' }}
uses: ./.github/workflows/semantic-search.yml
secrets: inherit
- with:
- skip: >-
- ${{ needs.should-run.outputs.verdict != 'force-run' &&
- needs.files-changed.outputs.backend_all != 'true' }}
- smoke-only: >-
- ${{ needs.should-run.outputs.verdict != 'force-run' &&
- !contains(github.event.pull_request.labels.*.name, 'ci:run-semantic-search-tests')
- }}
app-db-tests:
- if: |
- !cancelled() &&
- (needs.should-run.outputs.verdict == 'force-run' ||
- needs.files-changed.result == 'success')
- needs: [should-run, files-changed]
+ needs: gate
+ if: ${{ needs.gate.outputs.verdict != 'force-skip' }}
uses: ./.github/workflows/app-db.yml
secrets: inherit
- with:
- skip: >-
- ${{ needs.should-run.outputs.verdict != 'force-run' &&
- needs.files-changed.outputs.backend_all != 'true' }}
- force-run: ${{ needs.should-run.outputs.verdict == 'force-run' }}
driver-tests:
- if: |
- !cancelled() &&
- (needs.should-run.outputs.verdict == 'force-run' ||
- needs.files-changed.result == 'success')
- needs: [should-run, files-changed]
+ needs: gate
+ if: ${{ needs.gate.outputs.verdict != 'force-skip' }}
uses: ./.github/workflows/drivers.yml
secrets: inherit
- with:
- skip: >-
- ${{ needs.should-run.outputs.verdict != 'force-run' &&
- needs.files-changed.outputs.backend_all != 'true' }}
- force-run: ${{ needs.should-run.outputs.verdict == 'force-run' }}
frontend-tests:
- needs: [should-run, files-changed, create-test-plan]
- if: |
- !cancelled() &&
- (needs.should-run.outputs.verdict == 'force-run' ||
- needs.files-changed.result == 'success')
+ needs: [gate, create-test-plan]
+ # `!cancelled()` so a skipped planner (no plan) still runs the suite.
+ if: >-
+ ${{ !cancelled() && needs.gate.result == 'success'
+ && needs.gate.outputs.verdict != 'force-skip' }}
uses: ./.github/workflows/frontend.yml
secrets: inherit
with:
- skip: >-
- ${{ needs.should-run.outputs.verdict != 'force-run' &&
- needs.files-changed.outputs.frontend_all != 'true' }}
- # A skipped/failed planner supplies no artifact, so the suite runs in full.
- test-plan-artifact-id: ${{ needs.create-test-plan.result == 'success' && needs.create-test-plan.outputs.artifact-id || '' }}
- skip-lint: >-
- ${{ needs.should-run.outputs.verdict != 'force-run' &&
- needs.files-changed.outputs.frontend_all != 'true' &&
- needs.files-changed.outputs.e2e_all != 'true' }}
- skip-custom-viz: >-
- ${{ needs.should-run.outputs.verdict != 'force-run' &&
- needs.files-changed.outputs.custom_viz_all != 'true' }}
- skip-ci-scripts: >-
- ${{ needs.should-run.outputs.verdict != 'force-run' &&
- needs.files-changed.outputs.ci_scripts != 'true' }}
+ # No artifact means the suite runs in full.
+ test-plan-artifact-id: ${{ needs.create-test-plan.outputs.artifact-id }}
loki-tests:
- needs: [should-run, files-changed, create-test-plan]
- if: |
- !cancelled() &&
- (needs.should-run.outputs.verdict == 'force-run' ||
- needs.files-changed.result == 'success')
+ needs: [gate, create-test-plan]
+ # `!cancelled()` so a skipped planner (no plan) still runs the suite.
+ if: >-
+ ${{ !cancelled() && needs.gate.result == 'success'
+ && needs.gate.outputs.verdict != 'force-skip' }}
uses: ./.github/workflows/loki.yml
with:
- skip: >-
- ${{ needs.should-run.outputs.verdict != 'force-run' &&
- needs.files-changed.outputs.frontend_loki_all != 'true' }}
- # A skipped/failed planner supplies no artifact, so the suite runs in full.
- test-plan-artifact-id: ${{ needs.create-test-plan.result == 'success' && needs.create-test-plan.outputs.artifact-id || '' }}
+ # No artifact means the suite runs in full.
+ test-plan-artifact-id: ${{ needs.create-test-plan.outputs.artifact-id }}
e2e-tests:
- needs: [should-run, files-changed, uberjar, create-test-plan]
+ needs: [gate, 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
# enter the workflow when uberjar is `skipped` (docs-only PRs), because
- # the inner `skip` input handles that path and reports the required
+ # the suite's own gate handles that path and reports the required
# `e2e-tests-result` check as success. When the uberjar genuinely failed,
# this whole job is skipped, the inner required checks never report, and
# branch protection blocks the merge as pending.
if: |
- always() && !cancelled() &&
- (needs.should-run.outputs.verdict == 'force-run' || needs.files-changed.result == 'success') &&
+ !cancelled() &&
+ needs.gate.result == 'success' &&
+ needs.gate.outputs.verdict != 'force-skip' &&
needs.uberjar.result != 'failure' &&
needs.uberjar.result != 'cancelled'
uses: ./.github/workflows/e2e-tests.yml
secrets: inherit
with:
- skip: >-
- ${{ needs.should-run.outputs.verdict != 'force-run' &&
- needs.files-changed.outputs.e2e_all != 'true' }}
- # 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.create-test-plan.result == 'success' &&
- needs.create-test-plan.outputs.artifact-id || '' }}
+ # No artifact means the suite runs in full.
+ test-plan-artifact-id: ${{ needs.create-test-plan.outputs.artifact-id }}
embedding-sdk-package:
- needs: [should-run, files-changed]
- if: |
- !cancelled() &&
- (needs.should-run.outputs.verdict == 'force-run' ||
- needs.files-changed.outputs.embedding_sdk_components == 'true' ||
- needs.files-changed.outputs.frontend_sources == 'true' ||
- needs.files-changed.outputs.embedding_documentation == 'true' ||
- needs.files-changed.outputs.embedding_sdk_ci == 'true' ||
- needs.files-changed.outputs.embedding_sdk_host_sample_apps == 'true')
+ needs: gate
+ if: ${{ contains(fromJSON(needs.gate.outputs.matched), 'build_embedding_sdk_package') }}
uses: ./.github/workflows/embedding-sdk-package-build.yml
secrets: inherit
sdk-tests:
- needs: [should-run, uberjar, embedding-sdk-package, files-changed]
- if: always() && !cancelled()
+ needs: [gate, uberjar, embedding-sdk-package]
+ # Same rule as e2e-tests: a `skipped` artifact build still enters the suite, whose own gate then
+ # skips every job and reports the required result check. A genuine failure keeps this job out, so
+ # the check stays pending instead of being buried under missing-artifact errors. A failed gate
+ # skips both builds for a reason the suite's own gate cannot see, so it has to keep this out too.
+ if: |
+ !cancelled() &&
+ needs.gate.result == 'success' &&
+ needs.uberjar.result != 'failure' &&
+ needs.uberjar.result != 'cancelled' &&
+ needs.embedding-sdk-package.result != 'failure' &&
+ needs.embedding-sdk-package.result != 'cancelled'
uses: ./.github/workflows/embedding-sdk.yml
secrets: inherit
- with:
- cli-snippets-type-check: >-
- ${{ needs.should-run.outputs.verdict == 'force-run' ||
- needs.files-changed.outputs.frontend_sources == 'true' }}
- docs-snippets-type-check: >-
- ${{ needs.should-run.outputs.verdict == 'force-run' ||
- needs.files-changed.outputs.embedding_documentation == 'true' }}
- documentation-validation: >-
- ${{ needs.should-run.outputs.verdict == 'force-run' ||
- needs.files-changed.outputs.frontend_sources == 'true' }}
- component-tests: >-
- ${{ needs.should-run.outputs.verdict == 'force-run' ||
- needs.files-changed.outputs.embedding_sdk_components == 'true' }}
- host-sample-apps-tests: >-
- ${{ needs.should-run.outputs.verdict == 'force-run' ||
- needs.files-changed.outputs.embedding_sdk_host_sample_apps == 'true' }}
- skip: >-
- ${{ needs.embedding-sdk-package.result != 'success' ||
- needs.uberjar.result != 'success' }}
build-scripts-tests:
- needs: [should-run, files-changed]
- if: |
- !cancelled() &&
- (needs.should-run.outputs.verdict == 'force-run' ||
- needs.files-changed.result == 'success')
+ needs: gate
+ if: ${{ needs.gate.outputs.verdict != 'force-skip' }}
uses: ./.github/workflows/build-scripts.yml
secrets: inherit
- with:
- skip-build-scripts: >-
- ${{ needs.should-run.outputs.verdict != 'force-run' &&
- needs.files-changed.outputs.build_scripts != 'true' }}
- skip-embedder-plugin: >-
- ${{ needs.should-run.outputs.verdict != 'force-run' &&
- needs.files-changed.outputs.embedder_plugin != 'true' }}
-
- bundle-size:
- needs: [uberjar, files-changed]
- if: |
- !cancelled() &&
- github.event_name == 'pull_request' &&
- needs.uberjar.result == 'success' &&
- needs.files-changed.outputs.frontend_sources == 'true'
- uses: ./.github/workflows/bundle-size.yml
- secrets: inherit
diff --git a/.github/workflows/semantic-search.yml b/.github/workflows/semantic-search.yml
index 7afb9419bcc..b6555ffc966 100644
--- a/.github/workflows/semantic-search.yml
+++ b/.github/workflows/semantic-search.yml
@@ -2,14 +2,6 @@ name: Semantic Search Tests
on:
workflow_call:
- inputs:
- skip:
- type: boolean
- default: false
- smoke-only:
- type: boolean
- default: false
- description: Only run Postgres Latest to do a quick resource-efficient sanity check, intended to be set for PRs.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}-semantic-search
@@ -21,10 +13,21 @@ concurrency:
env:
CI_CONDUCTOR_BASE_URL: ${{ vars.CI_CONDUCTOR_BASE_URL }}
CI_CONDUCTOR_WEBHOOK_SECRET: ${{ secrets.CI_CONDUCTOR_WEBHOOK_SECRET }}
+ # Read by the test-driver action. This suite is only ever dispatched by test.profile-backend.yml,
+ # so a dispatch is a profiling run.
+ PROFILE_TESTS: ${{ github.event_name == 'workflow_dispatch' }}
jobs:
+ # A CI run is a smoke run -- Postgres Latest alone, to keep PRs cheap -- unless the whole suite is
+ # forced to run (master, release branches, `ci:run-all`).
+ gate:
+ uses: ./.github/workflows/test.gate.yml
+ with:
+ filters: backend_all
+
semantic-search-tests-h2:
- if: ${{ !inputs.skip && !inputs.smoke-only && (github.event.inputs.db == '' || github.event.inputs.db == 'h2') }}
+ needs: gate
+ if: ${{ needs.gate.outputs.force-run == 'true' }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 40
strategy:
@@ -68,7 +71,8 @@ jobs:
:exclude-tags '[${{ matrix.job.exclude-tag }}]'
semantic-search-tests-mariadb:
- if: ${{ !inputs.skip && !inputs.smoke-only && (github.event.inputs.db == '' || github.event.inputs.db == 'mariadb') }}
+ needs: gate
+ if: ${{ needs.gate.outputs.force-run == 'true' }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 40
strategy:
@@ -133,7 +137,8 @@ jobs:
:exclude-tags '[${{ matrix.job.exclude-tag }}]'
semantic-search-tests-mysql:
- if: ${{ !inputs.skip && !inputs.smoke-only && (github.event.inputs.db == '' || github.event.inputs.db == 'mysql') }}
+ needs: gate
+ if: ${{ needs.gate.outputs.force-run == 'true' }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 40
strategy:
@@ -205,7 +210,8 @@ jobs:
:exclude-tags '[${{ matrix.job.exclude-tag }}]'
semantic-search-tests-postgres:
- if: ${{ !inputs.skip && (github.event.inputs.db == '' || github.event.inputs.db == 'postgres') }}
+ needs: gate
+ if: ${{ needs.gate.outputs.run == 'true' }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 40
strategy:
@@ -221,7 +227,7 @@ jobs:
postgres-image: postgres:latest
pgvector-image: pgvector/pgvector:pg17
exclude: >-
- ${{ inputs.smoke-only
+ ${{ needs.gate.outputs.force-run != 'true'
&& fromJSON('[{"version":{"name":"Postgres 14.x with pgvector pg17"}}]')
|| fromJSON('[]') }}
job:
@@ -276,7 +282,8 @@ jobs:
# MB_PGVECTOR_DB_URL is deliberately unset. The dedicated-harness tests gate themselves off; the
# appdb-pgvector-mode round trip (and the URL-independent unit tests) run for real.
semantic-search-tests-appdb-mode:
- if: ${{ !inputs.skip && !inputs.smoke-only && (github.event.inputs.db == '' || github.event.inputs.db == 'appdb-mode') }}
+ needs: gate
+ if: ${{ needs.gate.outputs.force-run == 'true' }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 40
strategy:
@@ -328,6 +335,7 @@ jobs:
semantic-search-tests-result:
needs:
+ - gate
- semantic-search-tests-h2
- semantic-search-tests-mariadb
- semantic-search-tests-mysql
@@ -336,7 +344,7 @@ jobs:
runs-on: ${{ vars.SLIM_RUNNER_KEY }}
timeout-minutes: 5
name: semantic-search-tests-result
- if: always() && !cancelled()
+ if: ${{ !cancelled() }}
steps:
- name: Check job status
uses: actions/github-script@v9
diff --git a/.github/workflows/test.gate.yml b/.github/workflows/test.gate.yml
new file mode 100644
index 00000000000..f8f6805fb5e
--- /dev/null
+++ b/.github/workflows/test.gate.yml
@@ -0,0 +1,119 @@
+name: Test gate
+
+# Decides whether a test suite should run, so each suite owns its own gating
+# instead of the caller computing a `skip` input for it.
+#
+# `force-run` and `force-skip` are global overrides; `defer` hands the decision
+# to the paths filter, which is the only path that pays for a checkout.
+#
+# Only the lowest unmerged PR of a stack runs CI: it is the one whose base ref
+# is the stack base. Every PR above it is force-skipped and gets tested once it
+# reaches the bottom of the stack.
+on:
+ workflow_call:
+ inputs:
+ filters:
+ description: >-
+ Filter names from .github/file-paths.yaml, comma- or
+ whitespace-separated. The suite runs when the diff matches any of them.
+ Leave empty to decide on the overrides alone and skip the paths filter.
+ type: string
+ default: ''
+ outputs:
+ run:
+ description: Whether the calling suite should run.
+ value: >-
+ ${{ jobs.should-run.outputs.verdict != 'force-skip'
+ && (inputs.filters == ''
+ || jobs.should-run.outputs.verdict == 'force-run'
+ || jobs.files-changed.outputs.any == 'true') }}
+ matched:
+ description: >-
+ Which of the requested filters the diff touched, as a JSON array, for suites whose jobs
+ map to different filters. A force-run reports every requested filter.
+ value: >-
+ ${{ (jobs.should-run.outputs.verdict == 'force-run' && jobs.should-run.outputs.filters)
+ || jobs.files-changed.outputs.matched || '[]' }}
+ force-run:
+ description: Whether the suite should run in full, ignoring the diff.
+ value: ${{ jobs.should-run.outputs.verdict == 'force-run' }}
+ verdict:
+ description: force-run, force-skip, or defer.
+ value: ${{ jobs.should-run.outputs.verdict }}
+
+jobs:
+ should-run:
+ name: Decide whether to run
+ runs-on: ${{ vars.SLIM_RUNNER_KEY }}
+ timeout-minutes: 5
+ outputs:
+ verdict: ${{ steps.decide.outputs.verdict }}
+ filters: ${{ steps.decide.outputs.filters }}
+ steps:
+ - name: Decide
+ id: decide
+ # Precedence matters for the conditions below.
+ env:
+ FILTERS: ${{ inputs.filters }}
+ VERDICT: >-
+ ${{ (github.ref_name == 'master' || startsWith(github.ref_name, 'release-x.')) && 'force-run'
+ || contains(github.event.pull_request.labels.*.name, 'ci:run-all') && 'force-run'
+ || contains(github.event.pull_request.labels.*.name, 'ci:skip') && 'force-skip'
+ || (github.event.pull_request.stack != null && github.event.pull_request.stack.base.ref != github.event.pull_request.base.ref) && 'force-skip'
+ || 'defer' }}
+ run: |
+ echo "verdict=$VERDICT" | tee -a "$GITHUB_OUTPUT"
+ # Echoed back as JSON so a force-run can report every requested filter as matched.
+ echo "filters=$(jq -Rc 'split("[,\\s]+";"") | map(select(length > 0))' <<< "$FILTERS")" | tee -a "$GITHUB_OUTPUT"
+
+ files-changed:
+ name: Detect changed files
+ needs: should-run
+ if: ${{ needs.should-run.outputs.verdict == 'defer' && inputs.filters != '' }}
+ runs-on: ${{ vars.SLIM_RUNNER_KEY }}
+ timeout-minutes: 5
+ outputs:
+ matched: ${{ steps.match.outputs.matched }}
+ any: ${{ steps.match.outputs.any }}
+ steps:
+ # The filter definitions are the only thing on disk that paths-filter reads.
+ - uses: actions/checkout@v7
+ with:
+ sparse-checkout: .github
+ # No file lists: one filter's list can outgrow the 128 KiB a single environment variable may
+ # hold on Linux, and every caller after the gate pays for it. A job that needs the paths runs
+ # its own paths filter.
+ - name: Test which files changed
+ uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
+ id: changes
+ with:
+ token: ${{ github.token }}
+ filters: .github/file-paths.yaml
+ - name: Match the diff against the requested filters
+ id: match
+ uses: actions/github-script@v9
+ env:
+ REQUESTED: ${{ inputs.filters }}
+ # The names of every filter the diff matched, as a JSON array.
+ CHANGED: ${{ steps.changes.outputs.changes }}
+ with:
+ script: | # js
+ const fs = require('fs');
+
+ const requested = process.env.REQUESTED.split(/[\s,]+/).filter(Boolean);
+ const changed = JSON.parse(process.env.CHANGED);
+
+ // A filter name that no longer exists would silently gate the suite off forever.
+ const defined = [...fs.readFileSync('.github/file-paths.yaml', 'utf8')
+ .matchAll(/^(\w+):/gm)].map(([, name]) => name);
+ const unknown = requested.filter((filter) => !defined.includes(filter));
+ if (unknown.length) {
+ core.setFailed(`Unknown filter(s) in .github/file-paths.yaml: ${unknown.join(', ')}`);
+ return;
+ }
+
+ const matched = requested.filter((filter) => changed.includes(filter));
+ core.info(`requested: ${requested.join(', ')}`);
+ core.info(`matched: ${matched.join(', ') || 'none'}`);
+ core.setOutput('matched', JSON.stringify(matched));
+ core.setOutput('any', matched.length > 0);
diff --git a/.github/workflows/test.profile-backend.yml b/.github/workflows/test.profile-backend.yml
index 0a7bf18b2f4..10223aecd49 100644
--- a/.github/workflows/test.profile-backend.yml
+++ b/.github/workflows/test.profile-backend.yml
@@ -1,23 +1,22 @@
name: Profile Backend
# The only on-demand entry point for the backend test suites. Dispatching this workflow runs one
-# job of one suite against the ref you dispatch on, under clj-async-profiler, and attaches a
-# flamegraph to the job.
+# suite against the ref you dispatch on, under clj-async-profiler, and attaches a flamegraph to
+# each job.
#
# The suite workflows below are called unchanged: services, matrix legs, test args and quarantine
# gating are whatever the normal CI run uses, because they are the same jobs. They declare nothing
-# for this feature -- they read `suite`, `db` and `tests` off `github.event.inputs`, which inside a
-# called workflow is this dispatch's payload.
+# for this feature beyond treating a `workflow_dispatch` as a profiling run, and reading `tests` off
+# `github.event.inputs`, which inside a called workflow is this dispatch's payload.
#
-# `suite` picks the workflow, `db` picks the leg within it. `db` is free text so that adding a
-# driver or an app-DB leg needs no edit here; an unknown driver fails the drivers run through
-# mage's `--only-driver`, and an unknown app-DB or semantic-search leg matches nothing and runs no
-# jobs.
+# The suite is gated like any other run: dispatched on master or a release branch it runs in full;
+# anywhere else it runs only if the ref's diff from master touches the backend, and semantic-search
+# runs its Postgres-latest smoke leg alone.
#
-# Renaming an input here means updating every reader -- `grep -rn github.event.inputs .github/`.
-# Nothing enforces that, deliberately: a stale name reads as empty, which runs every leg of the
-# suite unprofiled, on the run you are watching. It cannot affect a normal CI run, where those
-# references are empty either way.
+# Renaming `tests` means updating its readers -- `grep -rn github.event.inputs.tests .github/`.
+# Nothing enforces that, deliberately: a stale name reads as empty, which profiles each leg's usual
+# set instead of the tests you named, on the run you are watching. It cannot affect a normal CI
+# run, where the reference is empty either way.
on:
workflow_dispatch:
inputs:
@@ -30,13 +29,8 @@ on:
- app-db
- drivers
- semantic-search
- db:
- description: 'Which leg of the suite: app-db takes mariadb, mysql or postgres; drivers takes a driver name, e.g. bigquery or mongo-ssl; semantic-search takes h2, mariadb, mysql, postgres or appdb-mode. Ignored by backend. Blank runs the whole suite -- every leg for app-db and semantic-search, mage''s usual decisions for drivers.'
- type: string
- required: false
- default: ''
tests:
- description: 'Optional: profile only these tests, comma- or space-separated, e.g. metabase.query-processor-test/some-test. Bare namespaces work too. Blank profiles the leg''s usual set.'
+ description: 'Optional: profile only these tests, comma- or space-separated, e.g. metabase.query-processor-test/some-test. Bare namespaces work too. Blank profiles each leg''s usual set.'
type: string
required: false
default: ''