Skip to content

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

Move PR env creation out of run-tests and remove unnecessary workflows (#81814)

Chris Vandoodewaard9344c2bd56cf
diff --git a/.github/actions/get-docker-info/action.yml b/.github/actions/get-docker-info/action.yml
index 9e0317402d1..a37a54decb3 100644
--- a/.github/actions/get-docker-info/action.yml
+++ b/.github/actions/get-docker-info/action.yml
@@ -2,12 +2,16 @@ name: Get Docker Info
description: Determines the registry, repository, and tag a container image is pushed to.
inputs:
+ registry:
+ description: Registry the image is pushed to, either "docker" or "ecr".
+ required: false
+ default: docker
repo:
- description: Registry and repo, e.g. "metabase/metabase". Overrides branch derived repo.
+ description: Repository name, e.g. "metabase-enterprise". Overrides a branch derived repo.
required: false
default: ''
tag:
- description: Docker tag, e.g. v1.87.2. Overrides a branch derived tag.
+ description: Image tag, e.g. v1.87.2. Overrides a branch derived tag.
required: false
default: ''
branch:
@@ -18,14 +22,22 @@ inputs:
description: Edition (ee or oss)
required: false
default: ee
- owner:
- description: Repository owner (defaults to current repo owner)
+ aws-account-id:
+ description: AWS account id hosting the ECR registry. Required for the ecr registry.
+ required: false
+ default: ''
+ aws-region:
+ description: Region of the ECR registry.
+ required: false
+ default: us-east-1
+ dockerhub-owner:
+ description: DockerHub owner.
required: false
- default: ${{ github.repository_owner }}
+ default: metabase
outputs:
repo:
- description: Docker repository name
+ description: Docker repository, including the registry host (ecr) or the owner (docker)
value: ${{ steps.docker-info.outputs.repo }}
tag:
description: Docker tag
@@ -40,28 +52,49 @@ runs:
- name: Determine Docker info
id: docker-info
uses: actions/github-script@v9
+ env:
+ REGISTRY: ${{ inputs.registry }}
+ REPO: ${{ inputs.repo }}
+ TAG: ${{ inputs.tag }}
+ BRANCH: ${{ inputs.branch }}
+ EDITION: ${{ inputs.edition }}
+ AWS_ACCOUNT_ID: ${{ inputs.aws-account-id }}
+ AWS_REGION: ${{ inputs.aws-region }}
+ DOCKERHUB_OWNER: ${{ inputs.dockerhub-owner }}
with:
script: | # js
- const branch = '${{ inputs.branch }}';
- const edition = '${{ inputs.edition }}';
- const owner = '${{ inputs.owner }}';
+ const { REGISTRY, OWNER, BRANCH, EDITION, AWS_ACCOUNT_ID, AWS_REGION, DOCKERHUB_OWNER } = process.env;
- let tag = '${{ inputs.tag}}';
+ let tag = process.env.TAG;
if (!tag) {
- tag = branch === 'master' ? 'latest' : `${branch.replaceAll('/', '-')}-${edition}`;
+ tag = BRANCH === 'master' ? 'latest' : `${BRANCH.replaceAll('/', '-')}-${EDITION}`;
}
- let repo = '${{ inputs.repo }}';
- if (!repo) {
- if (branch === 'master') {
- repo = edition === 'ee' ? `${owner}/metabase-enterprise-head` : `${owner}/metabase-head`;
+ let name = process.env.REPO;
+ if (!name) {
+ if (BRANCH === 'master') {
+ name = EDITION === 'ee' ? 'metabase-enterprise-head' : 'metabase-head';
} else {
- repo = `${owner}/metabase-dev`;
+ name = 'metabase-dev';
+ }
+ }
+
+ let repo;
+ if (REGISTRY === 'ecr') {
+ if (!AWS_ACCOUNT_ID) {
+ core.setFailed('Pushing to AWS ECR requires aws-account-id to be set.');
+ return;
}
+ repo = `${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${name}`;
+ } else if (REGISTRY === 'docker') {
+ repo = `${DOCKERHUB_OWNER}/${name}`;
+ } else {
+ core.setFailed(`Unknown registry "${REGISTRY}", expected "docker" or "ecr".`);
+ return;
}
core.setOutput('repo', repo);
core.setOutput('tag', tag);
core.setOutput('full_image', `${repo}:${tag}`);
- console.log(`Resolved: repo = ${repo}, tag = ${tag}`);
+ console.log(`Resolved: registry = ${REGISTRY}, repo = ${repo}, tag = ${tag}`);
diff --git a/.github/workflows/containerize-jar.yml b/.github/workflows/containerize-jar.yml
index 1495cc61651..028669075c5 100644
--- a/.github/workflows/containerize-jar.yml
+++ b/.github/workflows/containerize-jar.yml
@@ -8,11 +8,15 @@ on:
description: Metabase edition (ee or oss)
type: string
required: true
+ registry:
+ description: Registry the image is pushed to, either "docker" or "ecr".
+ type: string
+ default: docker
repo:
- description: Docker owner and repo, e.g. "metabase/metabase".
+ description: Repository name the image is pushed to, e.g. "metabase-enterprise".
type: string
tag:
- description: Docker tag, e.g. v1.87.2.
+ description: Image tag, e.g. v1.87.2.
type: string
commit:
type: string
@@ -21,6 +25,10 @@ on:
default: false
build-args:
type: string
+ platforms:
+ description: Platforms the image is built for.
+ type: string
+ default: linux/amd64,linux/arm64
workflow_dispatch:
inputs:
edition:
@@ -30,11 +38,18 @@ on:
- ee
- oss
required: true
+ registry:
+ description: Registry the image is pushed to
+ type: choice
+ options:
+ - docker
+ - ecr
+ default: docker
repo:
- description: Docker owner and repo, e.g. "metabase/metabase".
+ description: Repository name the image is pushed to, e.g. "metabase-enterprise".
type: string
tag:
- description: Docker tag, e.g. v1.87.2.
+ description: Image tag, e.g. v1.87.2.
type: string
commit:
description: the full commit hash
@@ -43,6 +58,10 @@ on:
description: Whether this is a release artifact (uses metabase-release- prefix)
type: boolean
default: false
+ platforms:
+ description: Platforms the image is built for.
+ type: string
+ default: linux/amd64,linux/arm64
jobs:
containerize:
@@ -50,95 +69,103 @@ jobs:
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 15
outputs:
- platforms: ${{ steps.platforms.outputs.result }}
- repo: ${{ steps.image.outputs.repo }}
- tag: ${{ steps.image.outputs.tag }}
full_image: ${{ steps.image.outputs.full_image }}
+ env:
+ AWS_REGION: us-east-1
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1
+
# we want the dockerfile from the commit we're building
- run: |
git fetch --depth=1 origin ${{ inputs.commit }}
git checkout ${{ inputs.commit }} -- bin/docker
+
- name: Retrieve uberjar artifact
uses: ./.github/actions/fetch-artifact
with:
commit: ${{ inputs.commit }}
edition: ${{ inputs.edition }}
release: ${{ inputs.release }}
- - name: Prepare release scripts
- uses: ./.github/actions/prepare-release-scripts
+ extract-path: bin/docker
+
- name: Resolve image repo and tag
id: image
uses: ./.github/actions/get-docker-info
with:
+ registry: ${{ inputs.registry }}
repo: ${{ inputs.repo }}
tag: ${{ inputs.tag }}
edition: ${{ inputs.edition }}
- - name: Get platforms
- id: platforms
- uses: actions/github-script@v9
+ aws-account-id: ${{ secrets.PR_ENV_AWS_ACCOUNT_ID }}
+ aws-region: ${{ env.AWS_REGION }}
+ dockerhub-owner: ${{ vars.DOCKERHUB_OWNER }}
+
+ - name: Configure AWS credentials
+ if: ${{ inputs.registry == 'ecr' }}
+ uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6.1.1
with:
- result-encoding: string
- script: | # js
- const { getBuildRequirements, isValidVersionString} = require('${{ github.workspace }}/release/dist/index.cjs');
- const version = "${{ steps.image.outputs.tag }}".split('-')[0];
-
- if (!isValidVersionString(version)) {
- return "linux/amd64,linux/arm64";
- }
- // versions before 53 need to be handled differently
- const buildInfo = getBuildRequirements(version);
- return buildInfo.platforms;
- - name: Move the Uberjar to the context dir
- run: mv ./metabase.jar bin/docker/.
+ role-to-assume: ${{ secrets.PR_ENV_IAM_ROLE }}
+ role-session-name: GitHub_to_AWS_via_FederatedOIDC
+ aws-region: ${{ env.AWS_REGION }}
+
+ - name: Login to Amazon ECR
+ if: ${{ inputs.registry == 'ecr' }}
+ uses: aws-actions/amazon-ecr-login@183a1442edf41672e66566b7fc560e297a290896 # v2
+ with:
+ registries: "${{ secrets.PR_ENV_AWS_ACCOUNT_ID }}"
+
- name: Login to Docker Hub
+ if: ${{ inputs.registry != 'ecr' }}
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
username: ${{ inputs.release && secrets.DOCKERHUB_RELEASE_USERNAME || secrets.DOCKERHUB_USERNAME }}
password: ${{ inputs.release && secrets.DOCKERHUB_RELEASE_TOKEN || secrets.DOCKERHUB_TOKEN }}
+
- name: Set up QEMU
- if: contains(steps.platforms.outputs.result, 'arm')
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
+
- name: Set up Docker Buildx
- if: contains(steps.platforms.outputs.result, 'arm')
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
- - name: Build multi-arch container
- if: contains(steps.platforms.outputs.result, 'arm')
+
+ - name: Build and Push Images
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
with:
context: bin/docker/.
- platforms: ${{ steps.platforms.outputs.result }}
+ platforms: ${{ inputs.platforms }}
network: host
tags: ${{ steps.image.outputs.full_image }}
no-cache: true
push: true
build-args: ${{ inputs.build-args }}
- # we need to do this to get the nice fallback behavior of the legacy manifest file
- - name: Build container (x86 only)
- if: contains(steps.platforms.outputs.result, 'arm') == false
- env:
- BUILD_ARGS: ${{ inputs.build-args }}
- FULL_IMAGE: ${{ steps.image.outputs.full_image }}
- run: | # bash
- args=()
- while IFS= read -r line; do
- [ -n "$line" ] && args+=(--build-arg "$line")
- done <<< "$BUILD_ARGS"
-
- docker build \
- -t "$FULL_IMAGE" \
- "${args[@]}" \
- --network=host \
- --push \
- bin/docker/.
-
- verify-docker-pull:
+ - name: Post link to image on DockerHub
+ if: ${{ inputs.registry != 'ecr' && github.event_name == 'pull_request' }}
+ uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 # v3.0.4
+ with:
+ header: docker-build-status-${{ inputs.edition }}
+ message: |
+ ✅ Docker build completed for commit ${{ inputs.commit || github.event.pull_request.head.sha || github.sha }}
+
+ The uberjar has been built and containerized successfully.
+
+ **Branch:** `${{ github.head_ref || github.ref_name }}`
+ **Docker Image:** `${{ steps.image.outputs.full_image }}`
+ **Docker Hub:** [View on Docker Hub](https://hub.docker.com/r/${{ steps.image.outputs.repo }}/tags?name=${{ steps.image.outputs.tag }})
+ **Triggered by:** @${{ github.actor }}
+
+ Pull the image:
+ ```bash
+ docker pull ${{ steps.image.outputs.full_image }}
+ ```
+
+ verify-docker-pull-amd64:
needs: containerize
- name: verify-docker-pull (${{ inputs.edition }})
+ if: >-
+ inputs.release &&
+ inputs.registry != 'ecr'
+ name: verify-docker-pull-amd64 (${{ inputs.edition }})
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 15
steps:
@@ -158,7 +185,10 @@ jobs:
verify-docker-pull-arm:
needs: containerize
- if: contains(needs.containerize.outputs.platforms, 'linux/arm64')
+ if: >-
+ inputs.release &&
+ inputs.registry != 'ecr' &&
+ contains(inputs.platforms, 'linux/arm64')
name: verify-docker-pull-arm (${{ inputs.edition }})
runs-on: arm-ubuntu-24-2core
timeout-minutes: 15
@@ -176,34 +206,3 @@ jobs:
- name: Wait for Metabase to start
run: while ! curl -s 'http://localhost:3000/api/health' | grep '{"status":"ok"}'; do sleep 1; done
timeout-minutes: 5
-
- post-docker-info-comment:
- needs: [containerize, verify-docker-pull, verify-docker-pull-arm]
- # Only post a comment if all the steps pass and this is a PR.
- if: |
- !cancelled() &&
- !failure() &&
- !inputs.release &&
- github.event_name == 'pull_request'
- name: post-docker-info-comment (${{ inputs.edition }})
- runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
- timeout-minutes: 5
- steps:
- - name: Post PR comment
- uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 # v3.0.4
- with:
- header: docker-build-status-${{ inputs.edition }}
- message: |
- ✅ Docker build completed for commit ${{ inputs.commit || github.event.pull_request.head.sha || github.sha }}
-
- The uberjar has been built and containerized successfully.
-
- **Branch:** `${{ github.head_ref || github.ref_name }}`
- **Docker Image:** `${{ needs.containerize.outputs.full_image }}`
- **Docker Hub:** [View on Docker Hub](https://hub.docker.com/r/${{ needs.containerize.outputs.repo }}/tags?name=${{ needs.containerize.outputs.tag }})
- **Triggered by:** @${{ github.actor }}
-
- Pull the image:
- ```bash
- docker pull ${{ needs.containerize.outputs.full_image }}
- ```
diff --git a/.github/workflows/pr-env.yml b/.github/workflows/env.create.yml
similarity index 73%
rename from .github/workflows/pr-env.yml
rename to .github/workflows/env.create.yml
index 154ce0fab55..4bd8171b47c 100644
--- a/.github/workflows/pr-env.yml
+++ b/.github/workflows/env.create.yml
@@ -1,42 +1,86 @@
-name: CI for PR Review ENV
+name: Deploy PR Environment
run-name: Building Dynamic PR Environment for ${{ github.ref_name }} by @${{ github.actor }}
on:
- workflow_call:
- inputs:
- self_hosting:
- description: "Deploy self-hosting stack"
- required: false
- type: boolean
- default: false
- analytics_dev_mode:
- description: "Enable analytics development mode"
- required: false
- type: boolean
- default: false
- stats_dump:
- description: "Load a recent app DB stats dump on first env creation"
- required: false
- type: boolean
- default: false
+ pull_request:
+ types: [ opened, labeled, synchronize, reopened ]
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+permissions:
+ id-token: write
+ contents: read
+ actions: read
+ pull-requests: write
+
jobs:
build:
- if: github.event.pull_request.head.repo.full_name == github.repository
- name: Build Metabase Docker image
- uses: ./.github/workflows/build-private-ee-docker-image.yml
- secrets:
- PR_ENV_IAM_ROLE: ${{ secrets.PR_ENV_IAM_ROLE }}
- PR_ENV_AWS_ACCOUNT_ID: ${{ secrets.PR_ENV_AWS_ACCOUNT_ID }}
- deploy_pr:
+ if: >-
+ ${{
+ github.event.pull_request.head.repo.full_name == 'metabase/metabase' &&
+ (
+ github.event.action != 'labeled' ||
+ contains(fromJSON('["PR-Env", "PR-Env-self-hosting", "PR-Env-analytics-dev", "PR-Env-Stats-Dump"]'), github.event.label.name)
+ ) &&
+ (
+ contains(github.event.pull_request.labels.*.name, 'PR-Env') ||
+ contains(github.event.pull_request.labels.*.name, 'PR-Env-self-hosting') ||
+ contains(github.event.pull_request.labels.*.name, 'PR-Env-analytics-dev') ||
+ contains(github.event.pull_request.labels.*.name, 'PR-Env-Stats-Dump')
+ )
+ }}
+ uses: ./.github/workflows/uberjar.yml
+ secrets: inherit
+
+ containerize:
needs: [build]
+ uses: ./.github/workflows/containerize-jar.yml
+ secrets: inherit
+ with:
+ edition: ee
+ registry: ecr
+ repo: metabase-enterprise
+ tag: ${{ github.event.pull_request.head.sha }}
+ commit: ${{ github.event.pull_request.head.sha }}
+ platforms: linux/amd64
+
+ deploy:
+ needs: [containerize]
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
name: PR Review ENV
- permissions:
- id-token: write
- contents: read
+ timeout-minutes: 60
+ outputs:
+ self_hosting: ${{ steps.label.outputs.self_hosting }}
+ analytics_dev_mode: ${{ steps.label.outputs.analytics_dev_mode }}
+ stats_dump: ${{ steps.label.outputs.stats_dump }}
steps:
- name: Checkout source code
uses: actions/checkout@v6
+ - name: Resolve Labels
+ id: label
+ env:
+ LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }}
+ run: | # bash
+ self_hosting=false
+ analytics_dev_mode=false
+ stats_dump=false
+
+ while IFS= read -r label; do
+ case "$label" in
+ PR-Env-self-hosting) self_hosting=true ;;
+ PR-Env-analytics-dev) analytics_dev_mode=true ;;
+ PR-Env-Stats-Dump) stats_dump=true ;;
+ esac
+ done < <(jq -r '.[]' <<< "$LABELS")
+
+ echo "self_hosting=${self_hosting} analytics_dev_mode=${analytics_dev_mode} stats_dump=${stats_dump}"
+ {
+ echo "self_hosting=${self_hosting}"
+ echo "analytics_dev_mode=${analytics_dev_mode}"
+ echo "stats_dump=${stats_dump}"
+ } >> "$GITHUB_OUTPUT"
- name: Tailscale
uses: tailscale/github-action@306e68a486fd2350f2bfc3b19fcd143891a4a2d8 # v4.1.2
with:
@@ -75,7 +119,7 @@ jobs:
PR_ENV_DB_NAME: ${{ secrets.PR_ENV_DB_NAME }}
- name: Verify stats dump load status
id: verify_stats_dump
- if: ${{ inputs.stats_dump }}
+ if: ${{ steps.label.outputs.stats_dump == 'true' }}
run: |
export PGPASSWORD="${PR_ENV_DB_PASSWORD}"
ADMIN="psql -h ${PR_ENV_DB_HOST} -U ${PR_ENV_DB_USER} -d ${PR_ENV_DB_NAME}"
@@ -98,7 +142,7 @@ jobs:
PR_ENV_DB_NAME: ${{ secrets.PR_ENV_DB_NAME }}
- name: Locate latest stats dump in S3
id: locate_stats_dump
- if: ${{ inputs.stats_dump && steps.verify_stats_dump.outputs.should_load == 'true' }}
+ if: ${{ steps.label.outputs.stats_dump == 'true' && steps.verify_stats_dump.outputs.should_load == 'true' }}
env:
STATS_DUMP_BUCKET: metabase-cloud-stats-backups-coredev
run: |
@@ -113,7 +157,7 @@ jobs:
echo "Latest dump: $LATEST_KEY"
echo "key=$LATEST_KEY" >> "$GITHUB_OUTPUT"
- name: Download stats dump
- if: ${{ inputs.stats_dump && steps.verify_stats_dump.outputs.should_load == 'true' }}
+ if: ${{ steps.label.outputs.stats_dump == 'true' && steps.verify_stats_dump.outputs.should_load == 'true' }}
env:
STATS_DUMP_BUCKET: metabase-cloud-stats-backups-coredev
run: |
@@ -123,7 +167,7 @@ jobs:
echo "Downloaded $(stat -c%s /tmp/stats-dump.dump) bytes"
file /tmp/stats-dump.dump
- name: Prepare app database schema
- if: ${{ inputs.stats_dump && steps.verify_stats_dump.outputs.should_load == 'true' }}
+ if: ${{ steps.label.outputs.stats_dump == 'true' && steps.verify_stats_dump.outputs.should_load == 'true' }}
run: |
PGPASSWORD="${PR_ENV_DB_PASSWORD}" psql \
-h "${PR_ENV_DB_HOST}" \
@@ -136,7 +180,7 @@ jobs:
PR_ENV_DB_USER: ${{ secrets.PR_ENV_DB_USER }}
PR_ENV_DB_HOST: ${{ secrets.PR_ENV_DB_HOST }}
- name: Restore stats dump into app database
- if: ${{ inputs.stats_dump && steps.verify_stats_dump.outputs.should_load == 'true' }}
+ if: ${{ steps.label.outputs.stats_dump == 'true' && steps.verify_stats_dump.outputs.should_load == 'true' }}
run: |
set +e
echo "::group::pg_restore / pg client versions"
@@ -173,7 +217,7 @@ jobs:
PR_ENV_DB_HOST: ${{ secrets.PR_ENV_DB_HOST }}
PR_ENV_DB_NAME: ${{ secrets.PR_ENV_DB_NAME }}
- name: Mark database as stats-dump loaded
- if: ${{ inputs.stats_dump && steps.verify_stats_dump.outputs.should_load == 'true' }}
+ if: ${{ steps.label.outputs.stats_dump == 'true' && steps.verify_stats_dump.outputs.should_load == 'true' }}
run: |
PGPASSWORD="${PR_ENV_DB_PASSWORD}" psql \
-h "${PR_ENV_DB_HOST}" \
@@ -185,22 +229,22 @@ jobs:
PR_ENV_DB_USER: ${{ secrets.PR_ENV_DB_USER }}
PR_ENV_DB_HOST: ${{ secrets.PR_ENV_DB_HOST }}
- name: Download Deployment YAML template
- if: ${{ !inputs.self_hosting }}
+ if: ${{ steps.label.outputs.self_hosting != 'true' }}
run: aws s3 cp s3://metabase-pr-env/metabase.yml.tmpl ./metabase.yml.tmpl
- name: Render Deployment YAML
- if: ${{ !inputs.self_hosting }}
+ if: ${{ steps.label.outputs.self_hosting != 'true' }}
uses: nowactions/envsubst@c4b8e3977354d294659a7ec164279ce8fba5c2e1 # v1.0.1
with:
input: ./metabase.yml.tmpl
output: ./metabase.yml
env:
- IMAGE_TAG: ${{ needs.build.outputs.tag }}
+ IMAGE_TAG: ${{ github.event.pull_request.head.sha }}
PR_NUMBER: ${{ github.event.number }}
MB_PREMIUM_EMBEDDING_TOKEN: ${{ secrets.PR_ENV_MB_PREMIUM_EMBEDDING_TOKEN }}
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
- MB_ANALYTICS_DEV_MODE: ${{ inputs.analytics_dev_mode && 'true' || 'false' }}
+ MB_ANALYTICS_DEV_MODE: ${{ steps.label.outputs.analytics_dev_mode }}
- name: Inject stats-dump env vars into Deployment YAML
- if: ${{ !inputs.self_hosting && inputs.stats_dump }}
+ if: ${{ steps.label.outputs.self_hosting != 'true' && steps.label.outputs.stats_dump == 'true' }}
env:
MB_ENCRYPTION_SECRET_KEY: ${{ secrets.PR_ENV_STATS_DUMP_ENCRYPTION_KEY }}
run: |
@@ -242,20 +286,20 @@ jobs:
namespace: default
user: oidc-token
- name: Deploy PR Review ENV
- if: ${{ !inputs.self_hosting }}
+ if: ${{ steps.label.outputs.self_hosting != 'true' }}
run: |
kubectl apply -f ./metabase.yml
- name: Download Helm values template (self-hosting)
- if: ${{ inputs.self_hosting }}
+ if: ${{ steps.label.outputs.self_hosting == 'true' }}
run: aws s3 cp s3://metabase-pr-env/values.yaml.tmpl ./values.yaml.tmpl
- name: Render Helm values (self-hosting)
- if: ${{ inputs.self_hosting }}
+ if: ${{ steps.label.outputs.self_hosting == 'true' }}
uses: nowactions/envsubst@c4b8e3977354d294659a7ec164279ce8fba5c2e1 # v1.0.1
with:
input: ./values.yaml.tmpl
output: ./values.yaml
env:
- IMAGE_TAG: ${{ needs.build.outputs.tag }}
+ IMAGE_TAG: ${{ github.event.pull_request.head.sha }}
PR_NUMBER: ${{ github.event.number }}
MB_PREMIUM_EMBEDDING_TOKEN: ${{ secrets.PR_ENV_MB_PREMIUM_EMBEDDING_TOKEN }}
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
@@ -266,15 +310,15 @@ jobs:
DB_USERNAME: ${{ secrets.PR_ENV_DB_USER }}
DB_PASSWORD: ${{ secrets.PR_ENV_DB_PASSWORD }}
CONFIG: ${{ secrets.PR_ENV_CONFIG }}
- MB_ANALYTICS_DEV_MODE: ${{ inputs.analytics_dev_mode && 'true' || 'false' }}
+ MB_ANALYTICS_DEV_MODE: ${{ steps.label.outputs.analytics_dev_mode }}
- name: Setup Helm
- if: ${{ inputs.self_hosting }}
+ if: ${{ steps.label.outputs.self_hosting == 'true' }}
uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0
with:
version: "latest"
- name: Login to Quay.io
- if: ${{ inputs.self_hosting }}
+ if: ${{ steps.label.outputs.self_hosting == 'true' }}
run: |
helm registry login quay.io \
--username "${QUAY_USERNAME}" \
@@ -283,7 +327,7 @@ jobs:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
- name: Deploy PR Review ENV (self-hosting)
- if: ${{ inputs.self_hosting }}
+ if: ${{ steps.label.outputs.self_hosting == 'true' }}
run: |
helm upgrade --install hosting-pr${{ github.event.number }} \
oci://quay.io/enterprisemetabase/chart-metabase-stack \
@@ -295,7 +339,7 @@ jobs:
preview_links:
runs-on: ${{ vars.SLIM_RUNNER_KEY }}
timeout-minutes: 5
- needs: [deploy_pr]
+ needs: [deploy]
steps:
- uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 # v3.0.4
with:
@@ -305,4 +349,4 @@ jobs:
✅ Preview:
https://pr${{ github.event.number }}.coredev.metabase.com
🗒️ [login instructions](https://www.notion.so/metabase/Ephemeral-PR-Environments-c74a3710c87a460dbf4fc0007a001458)
- 📦 Deployment type: ${{ inputs.self_hosting && 'PR-Env-self-hosting' || (inputs.analytics_dev_mode && 'PR-Env-analytics-dev' || (inputs.stats_dump && 'PR-Env-Stats-Dump' || 'PR-Env')) }}
+ 📦 Deployment type: ${{ needs.deploy.outputs.self_hosting == 'true' && 'PR-Env-self-hosting' || (needs.deploy.outputs.analytics_dev_mode == 'true' && 'PR-Env-analytics-dev' || (needs.deploy.outputs.stats_dump == 'true' && 'PR-Env-Stats-Dump' || 'PR-Env')) }}
diff --git a/.github/workflows/pr-env-labeled.yml b/.github/workflows/pr-env-labeled.yml
deleted file mode 100644
index ce6a0ec8dd8..00000000000
--- a/.github/workflows/pr-env-labeled.yml
+++ /dev/null
@@ -1,52 +0,0 @@
-name: PR-Env labeled
-
-on:
- pull_request:
- types: [ labeled ]
-
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
-
-jobs:
- uberjar:
- if: ${{ github.event.label.name == 'PR-Env' || github.event.label.name == 'PR-Env-self-hosting' || github.event.label.name == 'PR-Env-analytics-dev' || github.event.label.name == 'PR-Env-Stats-Dump' }}
- uses: ./.github/workflows/uberjar.yml
- secrets: inherit
-
- pr-env:
- needs: [uberjar]
- if: ${{ github.event.label.name == 'PR-Env' }}
- uses: ./.github/workflows/pr-env.yml
- secrets: inherit
- with:
- self_hosting: false
- analytics_dev_mode: false
-
- pr-env-self-hosting:
- needs: [uberjar]
- if: ${{ github.event.label.name == 'PR-Env-self-hosting' }}
- uses: ./.github/workflows/pr-env.yml
- secrets: inherit
- with:
- self_hosting: true
- analytics_dev_mode: false
-
- pr-env-analytics-dev:
- needs: [uberjar]
- if: ${{ github.event.label.name == 'PR-Env-analytics-dev' }}
- uses: ./.github/workflows/pr-env.yml
- secrets: inherit
- with:
- self_hosting: false
- analytics_dev_mode: true
-
- pr-env-stats-dump:
- needs: [uberjar]
- if: ${{ github.event.label.name == 'PR-Env-Stats-Dump' }}
- uses: ./.github/workflows/pr-env.yml
- secrets: inherit
- with:
- self_hosting: false
- analytics_dev_mode: false
- stats_dump: true
diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml
index 9fe8a160b84..6ac63769fc3 100644
--- a/.github/workflows/pre-release.yml
+++ b/.github/workflows/pre-release.yml
@@ -252,7 +252,7 @@ jobs:
with:
edition: oss
commit: ${{ inputs.commit }}
- repo: ${{ vars.DOCKERHUB_OWNER }}/${{ vars.DOCKERHUB_STAGING_REPO }}
+ repo: ${{ vars.DOCKERHUB_STAGING_REPO }}
tag: ${{ needs.release-artifact.outputs.oss_version }}-${{ inputs.commit }}
release: true
@@ -263,7 +263,7 @@ jobs:
with:
edition: ee
commit: ${{ inputs.commit }}
- repo: ${{ vars.DOCKERHUB_OWNER }}/${{ vars.DOCKERHUB_STAGING_REPO }}
+ repo: ${{ vars.DOCKERHUB_STAGING_REPO }}
tag: ${{ needs.release-artifact.outputs.ee_version }}-${{ inputs.commit }}
release: true
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 6cdaa0aa6b1..c2dc8fe99bd 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -279,7 +279,7 @@ jobs:
with:
edition: oss
commit: ${{ inputs.commit }}
- repo: ${{ vars.DOCKERHUB_OWNER }}/${{ vars.DOCKERHUB_REPO }}
+ repo: ${{ vars.DOCKERHUB_REPO }}
tag: ${{ needs.check-version.outputs.oss }}
release: true
@@ -290,7 +290,7 @@ jobs:
with:
edition: ee
commit: ${{ inputs.commit }}
- repo: ${{ vars.DOCKERHUB_OWNER }}/${{ vars.DOCKERHUB_REPO }}-enterprise
+ repo: ${{ vars.DOCKERHUB_REPO }}-enterprise
tag: ${{ needs.check-version.outputs.ee }}
release: true
@@ -330,6 +330,7 @@ jobs:
get-extra-tags:
needs: [ check-version ]
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
+ timeout-minutes: 10
outputs:
extra_tags: ${{ steps.taglist.outputs.extra_tags }}
steps:
diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml
index 09d7d00a1af..a220e6bb4ec 100644
--- a/.github/workflows/run-tests.yml
+++ b/.github/workflows/run-tests.yml
@@ -152,10 +152,30 @@ jobs:
(needs.should-run.outputs.verdict == 'force-run' ||
needs.files-changed.outputs.no_source_code_changes != 'true')
uses: ./.github/workflows/uberjar.yml
- with:
- containerize: ${{ (github.event_name == 'push' && github.ref_name == 'master') || contains(github.event.pull_request.labels.*.name, 'build-docker-uberjar') }}
secrets: inherit
+ containerize:
+ 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'))
+ )
+ name: containerize (${{ matrix.edition }})
+ strategy:
+ matrix:
+ edition: ['ee', 'oss']
+ uses: ./.github/workflows/containerize-jar.yml
+ secrets: inherit
+ with:
+ build-args: |
+ GIT_COMMIT_SHA=${{ github.event.pull_request.head.sha || github.sha }}
+ commit: ${{ github.event.pull_request.head.sha || github.sha }}
+ edition: ${{ matrix.edition }}
+ release: false
+
# 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:
@@ -403,50 +423,3 @@ jobs:
needs.files-changed.outputs.frontend_sources == 'true'
uses: ./.github/workflows/bundle-size.yml
secrets: inherit
-
- pr-env:
- needs: [uberjar]
- if: |
- !cancelled() &&
- contains(github.event.pull_request.labels.*.name, 'PR-Env') &&
- !contains(github.event.pull_request.labels.*.name, 'PR-Env-self-hosting') &&
- !contains(github.event.pull_request.labels.*.name, 'PR-Env-analytics-dev')
- uses: ./.github/workflows/pr-env.yml
- secrets: inherit
- with:
- self_hosting: false
- analytics_dev_mode: false
-
- pr-env-self-hosting:
- needs: [uberjar]
- if: |
- !cancelled() &&
- contains(github.event.pull_request.labels.*.name, 'PR-Env-self-hosting')
- uses: ./.github/workflows/pr-env.yml
- secrets: inherit
- with:
- self_hosting: true
- analytics_dev_mode: false
-
- pr-env-analytics-dev:
- needs: [uberjar]
- if: |
- !cancelled() &&
- contains(github.event.pull_request.labels.*.name, 'PR-Env-analytics-dev')
- uses: ./.github/workflows/pr-env.yml
- secrets: inherit
- with:
- self_hosting: false
- analytics_dev_mode: true
-
- pr-env-stats-dump:
- needs: [uberjar]
- if: |
- !cancelled() &&
- contains(github.event.pull_request.labels.*.name, 'PR-Env-Stats-Dump')
- uses: ./.github/workflows/pr-env.yml
- secrets: inherit
- with:
- self_hosting: false
- analytics_dev_mode: false
- stats_dump: true
diff --git a/.github/workflows/uberjar.yml b/.github/workflows/uberjar.yml
index 8eaa60a3d21..64b83b4a8e6 100644
--- a/.github/workflows/uberjar.yml
+++ b/.github/workflows/uberjar.yml
@@ -1,6 +1,6 @@
name: Build Uberjar
-# This workflow builds and containerizes an uberjar and pushes it to dockerhub.
+# This workflow builds the uberjar.
concurrency:
group: uberjar-${{ inputs.commit || github.event.pull_request.head.sha || github.sha }}
@@ -14,11 +14,6 @@ on:
type: string
default: ''
required: false
- containerize:
- description: "Set if the uberjar should be containerized and pushed to Dockerhub."
- type: boolean
- default: false
- required: false
workflow_call:
inputs:
commit:
@@ -26,11 +21,6 @@ on:
type: string
default: ''
required: false
- containerize:
- description: "Set if the uberjar should be containerized and pushed to Dockerhub."
- type: boolean
- default: false
- required: false
jobs:
setup:
@@ -101,14 +91,15 @@ jobs:
if: ${{ needs.setup.outputs.build_editions != '[]' }}
name: build (${{ matrix.edition }})
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
- timeout-minutes: 15
+ timeout-minutes: 20
strategy:
matrix:
edition: ${{ fromJson(needs.setup.outputs.build_editions) }}
env:
MB_EDITION: ${{ matrix.edition }}
INTERACTIVE: false
- SKIP_LICENSES: ${{ github.event_name == 'pull_request' && !inputs.containerize }} # faster builds for dev
+ # Faster builds for devs
+ SKIP_LICENSES: ${{ github.event_name == 'pull_request' }}
# Emit bundle stats on trunk/release builds (tracked over time) and on PRs
# (the bundle-size check reads them for both the PR head and its base ref).
EMIT_BUNDLE_STATS: ${{ (github.ref_name == 'master' || startsWith(github.ref_name, 'release-') || github.event_name == 'pull_request') && 'true' || 'false' }}
@@ -135,6 +126,19 @@ jobs:
name: metabase-bundle-stats-${{ matrix.edition }}-${{ inputs.commit || github.event.pull_request.head.sha || github.sha }}
path: target/bundle-stats
if-no-files-found: warn
+ - name: Verify license files are present in uberjar
+ if: ${{ env.SKIP_LICENSES != 'true' }}
+ run: |
+ echo "Checking for license files in uberjar..."
+ unzip -l ./target/uberjar/metabase.jar | grep -q "license-backend-third-party.txt" || (echo "ERROR: license-backend-third-party.txt not found in uberjar" && exit 1)
+ unzip -l ./target/uberjar/metabase.jar | grep -q "license-frontend-third-party.txt" || (echo "ERROR: license-frontend-third-party.txt not found in uberjar" && exit 1)
+ echo "Both license files found in uberjar"
+ - name: Launch uberjar
+ run: >-
+ java --add-opens java.base/java.nio=ALL-UNNAMED -jar ./target/uberjar/metabase.jar &
+ - name: Wait for Metabase to start
+ timeout-minutes: 5
+ run: while ! curl -s 'http://localhost:3000/api/health' | grep '{"status":"ok"}'; do sleep 1; done
- name: Mark with the commit hash
run: git rev-parse --short HEAD > COMMIT-ID
shell: bash
@@ -145,62 +149,9 @@ jobs:
uses: actions/upload-artifact@v7
with:
# Same key the artifact lookups use, so a build for an explicitly dispatched commit
- # uploads where `setup` and `jar-healthcheck` go looking for it.
+ # uploads where `setup` and the containerize workflow go looking for it.
name: metabase-${{ matrix.edition }}-${{ inputs.commit || github.event.pull_request.head.sha || github.sha }}-uberjar
path: |
./target/uberjar/metabase.jar
./COMMIT-ID
./SHA256.sum
-
- jar-healthcheck:
- needs: [setup, build]
- # Health-check whatever we are about to containerize, plus every build on master and release.
- if: ${{ !failure() && !cancelled() && (inputs.containerize || github.ref_name == 'master' || startsWith(github.ref_name, 'release-')) }}
- name: jar-healthcheck (${{ matrix.edition }})
- runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
- timeout-minutes: 10
- strategy:
- matrix:
- edition: [ee, oss]
- steps:
- - name: Check out the code
- uses: actions/checkout@v6
- - name: Prepare JRE (Java Run-time Environment)
- uses: actions/[email protected]
- with:
- java-package: jre
- java-version: ${{ needs.setup.outputs.java_version || 25 }}
- distribution: "temurin"
- - run: java -version
- - name: Retrieve uberjar artifact
- uses: ./.github/actions/fetch-artifact
- with:
- commit: ${{ inputs.commit || github.event.pull_request.head.sha || github.sha }}
- edition: ${{ matrix.edition }}
- - name: Verify license files are present in uberjar
- run: |
- echo "Checking for license files in uberjar..."
- unzip -l ./metabase.jar | grep -q "license-backend-third-party.txt" || (echo "ERROR: license-backend-third-party.txt not found in uberjar" && exit 1)
- unzip -l ./metabase.jar | grep -q "license-frontend-third-party.txt" || (echo "ERROR: license-frontend-third-party.txt not found in uberjar" && exit 1)
- echo "Both license files found in uberjar"
- - name: Launch uberjar
- run: >-
- java --add-opens java.base/java.nio=ALL-UNNAMED -jar ./metabase.jar &
- - name: Wait for Metabase to start
- run: while ! curl 'http://localhost:3000/api/health' | grep '{"status":"ok"}'; do sleep 1; done
-
- containerize:
- needs: [build, jar-healthcheck]
- if: ${{ inputs.containerize && !failure() && !cancelled() }}
- name: containerize (${{ matrix.edition }})
- strategy:
- matrix:
- edition: [ee, oss]
- uses: ./.github/workflows/containerize-jar.yml
- secrets: inherit
- with:
- edition: ${{ matrix.edition }}
- commit: ${{ inputs.commit || github.event.pull_request.head.sha || github.sha }}
- release: false
- build-args: |
- GIT_COMMIT_SHA=${{ inputs.commit || github.event.pull_request.head.sha || github.sha }}