Skip to content

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

containerize uberjar from uberjar workflow (#81238)

Chris Vandoodewaard2b35888297a2
diff --git a/.github/actions/fetch-artifact/action.yml b/.github/actions/fetch-artifact/action.yml
index 97cf80a09f2..bcc1a59a0b9 100644
--- a/.github/actions/fetch-artifact/action.yml
+++ b/.github/actions/fetch-artifact/action.yml
@@ -20,6 +20,15 @@ inputs:
description: Directory path where the jar should be extracted (defaults to current directory)
required: false
default: "."
+ download:
+ description: Default is true. Set to false to only look the artifact up and report `fetch-hit`.
+ required: false
+ default: "true"
+
+outputs:
+ fetch-hit:
+ description: Boolean indicating if an artifact was successfully found and downloaded.
+ value: ${{ steps.find_release_artifact.outputs.fetch-hit }}
runs:
using: "composite"
@@ -28,11 +37,12 @@ runs:
id: find_release_artifact
uses: actions/github-script@v9
with:
- result-encoding: string
script: | # js
const fs = require('fs');
const isRelease = "${{ inputs.release }}" === "true";
+ const failOnMiss = "${{ inputs.fail-on-fetch-miss }}" !== "false";
+ const shouldDownload = "${{ inputs.download }}" !== "false";
const prefix = isRelease ? "metabase-release" : "metabase";
const artifactName = `${prefix}-${{ inputs.edition }}-${{ inputs.commit }}-uberjar`;
console.log(`Looking for artifact: ${artifactName}`);
@@ -44,12 +54,18 @@ runs:
per_page: 1,
});
- if (!artifacts.data?.artifacts?.[0]?.id) {
- core.setFailed(`No artifacts found for ${artifactName}`);
- return;
+ const artifact_id = artifacts.data?.artifacts?.[0]?.id;
+
+ if (!artifact_id) {
+ core.setOutput('fetch-hit', 'false');
+ } else {
+ core.setOutput('fetch-hit', 'true');
}
- const artifact_id = artifacts.data.artifacts[0].id;
+ if (!shouldDownload) {
+ console.log(`skipping download (download: false)`);
+ return;
+ }
let download;
const maxAttempts = 3;
@@ -74,6 +90,7 @@ runs:
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/mb.zip`, Buffer.from(download.data));
- name: Extract and rename JAR
+ if: ${{ steps.find_release_artifact.outputs.fetch-hit == 'true' && inputs.download != 'false' }}
shell: bash
run: | # bash
OUTPUT_NAME="${{ inputs.output-name }}"
@@ -119,12 +136,14 @@ runs:
fi
- name: Verify that this is a valid JAR file
+ if: ${{ steps.find_release_artifact.outputs.fetch-hit == 'true' && inputs.download != 'false' }}
shell: bash
run: |
echo "Verifying JAR at: $JAR_PATH"
file --mime-type "$JAR_PATH"
- name: Reveal its version.properties
+ if: ${{ steps.find_release_artifact.outputs.fetch-hit == 'true' && inputs.download != 'false' }}
shell: bash
run: |
echo "Extracting version.properties from: $JAR_PATH"
diff --git a/.github/actions/get-docker-info/action.yml b/.github/actions/get-docker-info/action.yml
index 7d8c27a03d8..9e0317402d1 100644
--- a/.github/actions/get-docker-info/action.yml
+++ b/.github/actions/get-docker-info/action.yml
@@ -1,7 +1,15 @@
name: Get Docker Info
-description: Determines Docker repository and tag based on branch and edition
+description: Determines the registry, repository, and tag a container image is pushed to.
inputs:
+ repo:
+ description: Registry and repo, e.g. "metabase/metabase". Overrides branch derived repo.
+ required: false
+ default: ''
+ tag:
+ description: Docker tag, e.g. v1.87.2. Overrides a branch derived tag.
+ required: false
+ default: ''
branch:
description: Branch name (defaults to current branch)
required: false
@@ -25,9 +33,6 @@ outputs:
full_image:
description: Full Docker image name (repo:tag)
value: ${{ steps.docker-info.outputs.full_image }}
- editions:
- description: JSON array of editions to build
- value: ${{ steps.docker-info.outputs.editions }}
runs:
using: "composite"
@@ -41,34 +46,22 @@ runs:
const edition = '${{ inputs.edition }}';
const owner = '${{ inputs.owner }}';
- console.log(`Determining Docker info for branch: ${branch}, edition: ${edition}`);
-
- let repo, tag, editions;
-
- if (branch === 'master') {
- // Master builds both editions with specific repos
- editions = ['ee', 'oss'];
- tag = 'latest';
+ let tag = '${{ inputs.tag}}';
+ if (!tag) {
+ tag = branch === 'master' ? 'latest' : `${branch.replaceAll('/', '-')}-${edition}`;
+ }
- if (edition === 'ee') {
- repo = `${owner}/metabase-enterprise-head`;
+ let repo = '${{ inputs.repo }}';
+ if (!repo) {
+ if (branch === 'master') {
+ repo = edition === 'ee' ? `${owner}/metabase-enterprise-head` : `${owner}/metabase-head`;
} else {
- repo = `${owner}/metabase-head`;
+ repo = `${owner}/metabase-dev`;
}
- } else {
- // All other branches only build EE to metabase-dev
- editions = ['ee'];
- tag = branch.replaceAll('/', '-'); // slashes make docker sad
- repo = `${owner}/metabase-dev`;
}
- const fullImage = `${repo}:${tag}`;
-
- // Set outputs
core.setOutput('repo', repo);
core.setOutput('tag', tag);
- core.setOutput('full_image', fullImage);
- core.setOutput('editions', JSON.stringify(editions));
+ core.setOutput('full_image', `${repo}:${tag}`);
- console.log(`Docker image: ${fullImage}`);
- console.log(`Editions: ${JSON.stringify(editions)}`);
+ console.log(`Resolved: repo = ${repo}, tag = ${tag}`);
diff --git a/.github/workflows/containerize-jar.yml b/.github/workflows/containerize-jar.yml
index 1ff6e2fe2ed..1495cc61651 100644
--- a/.github/workflows/containerize-jar.yml
+++ b/.github/workflows/containerize-jar.yml
@@ -1,5 +1,5 @@
name: Containerize Uberjar
-run-name: Containerize ${{ inputs.tag }} Uberjar
+run-name: Containerize ${{ inputs.edition }} ${{ inputs.tag }} Uberjar
on:
workflow_call:
@@ -9,9 +9,10 @@ on:
type: string
required: true
repo:
- description: owner and repo like "metabase/metabase"
+ description: Docker owner and repo, e.g. "metabase/metabase".
type: string
tag:
+ description: Docker tag, e.g. v1.87.2.
type: string
commit:
type: string
@@ -30,10 +31,10 @@ on:
- oss
required: true
repo:
- description: docker owner and repo like "metabase/metabase"
+ description: Docker owner and repo, e.g. "metabase/metabase".
type: string
tag:
- description: usually a version like v1.87.2
+ description: Docker tag, e.g. v1.87.2.
type: string
commit:
description: the full commit hash
@@ -45,10 +46,14 @@ on:
jobs:
containerize:
+ name: containerize (${{ inputs.edition }})
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 }}
steps:
- uses: actions/checkout@v6
with:
@@ -65,6 +70,13 @@ jobs:
release: ${{ inputs.release }}
- name: Prepare release scripts
uses: ./.github/actions/prepare-release-scripts
+ - name: Resolve image repo and tag
+ id: image
+ uses: ./.github/actions/get-docker-info
+ with:
+ repo: ${{ inputs.repo }}
+ tag: ${{ inputs.tag }}
+ edition: ${{ inputs.edition }}
- name: Get platforms
id: platforms
uses: actions/github-script@v9
@@ -72,7 +84,7 @@ jobs:
result-encoding: string
script: | # js
const { getBuildRequirements, isValidVersionString} = require('${{ github.workspace }}/release/dist/index.cjs');
- const version = "${{ inputs.tag }}".split('-')[0];
+ const version = "${{ steps.image.outputs.tag }}".split('-')[0];
if (!isValidVersionString(version)) {
return "linux/amd64,linux/arm64";
@@ -100,7 +112,7 @@ jobs:
context: bin/docker/.
platforms: ${{ steps.platforms.outputs.result }}
network: host
- tags: ${{ inputs.repo }}:${{ inputs.tag }}
+ tags: ${{ steps.image.outputs.full_image }}
no-cache: true
push: true
build-args: ${{ inputs.build-args }}
@@ -108,16 +120,26 @@ jobs:
# 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 ${{ inputs.repo }}:${{ inputs.tag }} \
+ -t "$FULL_IMAGE" \
+ "${args[@]}" \
--network=host \
--push \
bin/docker/.
verify-docker-pull:
- runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
needs: containerize
+ name: verify-docker-pull (${{ inputs.edition }})
+ runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 15
steps:
- name: Login to Docker Hub
@@ -126,18 +148,19 @@ jobs:
username: ${{ inputs.release && secrets.DOCKERHUB_RELEASE_USERNAME || secrets.DOCKERHUB_USERNAME }}
password: ${{ inputs.release && secrets.DOCKERHUB_RELEASE_TOKEN || secrets.DOCKERHUB_TOKEN }}
- name: Pull the container image
- run: docker pull ${{ inputs.repo }}:${{ inputs.tag }}
+ run: docker pull ${{ needs.containerize.outputs.full_image }}
- name: Launch container
- run: docker run --rm -dp 3000:3000 ${{ inputs.repo }}:${{ inputs.tag }}
+ run: docker run --rm -dp 3000:3000 ${{ needs.containerize.outputs.full_image }}
timeout-minutes: 5
- 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
verify-docker-pull-arm:
- runs-on: arm-ubuntu-24-2core
needs: containerize
if: contains(needs.containerize.outputs.platforms, 'linux/arm64')
+ name: verify-docker-pull-arm (${{ inputs.edition }})
+ runs-on: arm-ubuntu-24-2core
timeout-minutes: 15
steps:
- name: Login to Docker Hub
@@ -146,10 +169,41 @@ jobs:
username: ${{ inputs.release && secrets.DOCKERHUB_RELEASE_USERNAME || secrets.DOCKERHUB_USERNAME }}
password: ${{ inputs.release && secrets.DOCKERHUB_RELEASE_TOKEN || secrets.DOCKERHUB_TOKEN }}
- name: Pull the container image
- run: docker pull ${{ inputs.repo }}:${{ inputs.tag }}
+ run: docker pull ${{ needs.containerize.outputs.full_image }}
- name: Launch container
- run: docker run --rm -dp 3000:3000 ${{ inputs.repo }}:${{ inputs.tag }}
+ run: docker run --rm -dp 3000:3000 ${{ needs.containerize.outputs.full_image }}
timeout-minutes: 5
- 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/containerize-uberjar.yml b/.github/workflows/containerize-uberjar.yml
deleted file mode 100644
index fd39d078f56..00000000000
--- a/.github/workflows/containerize-uberjar.yml
+++ /dev/null
@@ -1,102 +0,0 @@
-name: Containerize Uberjar
-
-on:
- workflow_call:
- workflow_dispatch:
- inputs:
- commit:
- description: the full commit hash to containerize (defaults to the triggering commit)
- type: string
-
-jobs:
- get-container-info:
- runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
- timeout-minutes: 5
- name: Get container info
- outputs:
- editions: ${{ steps.ee-info.outputs.editions }}
- ee: ${{ toJson(fromJson(steps.build-matrix.outputs.result).ee) }}
- oss: ${{ toJson(fromJson(steps.build-matrix.outputs.result).oss) }}
- steps:
- - name: Check out the code
- uses: actions/checkout@v6
- - name: Get EE Docker info
- id: ee-info
- uses: ./.github/actions/get-docker-info
- with:
- edition: ee
- - name: Get OSS Docker info
- id: oss-info
- uses: ./.github/actions/get-docker-info
- with:
- edition: oss
- - name: Build matrix info
- id: build-matrix
- uses: actions/github-script@v9
- with:
- script: | # js
- const editions = JSON.parse('${{ steps.ee-info.outputs.editions }}');
- const result = {
- editions: editions,
- ee: {
- repo: '${{ steps.ee-info.outputs.repo }}',
- tag: '${{ steps.ee-info.outputs.tag }}'
- },
- oss: {
- repo: '${{ steps.oss-info.outputs.repo }}',
- tag: '${{ steps.oss-info.outputs.tag }}'
- }
- };
- console.log('Build matrix:', result);
- return result;
-
- containerize:
- needs: [get-container-info]
- if: needs.get-container-info.result == 'success'
- strategy:
- matrix:
- edition: ${{ fromJson(needs.get-container-info.outputs.editions) }}
- uses: ./.github/workflows/containerize-jar.yml
- secrets: inherit
- with:
- edition: ${{ matrix.edition }}
- commit: ${{ github.event.inputs.commit || github.event.pull_request.head.sha || github.sha }}
- repo: ${{ fromJson(needs.get-container-info.outputs[matrix.edition]).repo }}
- tag: ${{ fromJson(needs.get-container-info.outputs[matrix.edition]).tag }}
- release: false
- build-args: |
- GIT_COMMIT_SHA=${{ github.event.inputs.commit || github.event.pull_request.head.sha || github.sha }}
-
- post-comment:
- needs: [get-container-info, containerize]
- if: github.event_name == 'pull_request'
- runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
- name: Post PR comment
- steps:
- - name: Check out the code
- uses: actions/checkout@v6
- - name: Get Docker info for comment
- id: docker-info
- uses: ./.github/actions/get-docker-info
- with:
- branch: ${{ github.head_ref || github.ref_name }}
- edition: ee
-
- - name: Post PR comment
- uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 # v3.0.4
- with:
- header: docker-build-status
- message: |
- ✅ Docker build completed for 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.docker-info.outputs.full_image }}`
- **Docker Hub:** [View on Docker Hub](https://hub.docker.com/r/${{ steps.docker-info.outputs.repo }}/tags?name=${{ steps.docker-info.outputs.tag }})
- **Triggered by:** @${{ github.actor }}
-
- Pull the image:
- ```bash
- docker pull ${{ steps.docker-info.outputs.full_image }}
- ```
diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml
index 229f20504d7..d2f1d3790ab 100644
--- a/.github/workflows/run-tests.yml
+++ b/.github/workflows/run-tests.yml
@@ -148,6 +148,8 @@ 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
# Compile CLJS in parallel with the uberjar and pass it to each e2e group.
@@ -414,15 +416,3 @@ jobs:
self_hosting: false
analytics_dev_mode: false
stats_dump: true
-
- containerize:
- needs: [uberjar]
- if: |
- !cancelled() &&
- needs.uberjar.result == 'success' &&
- (
- (github.event_name == 'push' && contains(fromJson('["master", "metabot-v3-main", "internal-tools"]'), github.ref_name)) ||
- (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'build-docker-uberjar'))
- )
- uses: ./.github/workflows/containerize-uberjar.yml
- secrets: inherit
diff --git a/.github/workflows/uberjar-containerize-labeled.yml b/.github/workflows/uberjar-containerize-labeled.yml
deleted file mode 100644
index 5b1291da266..00000000000
--- a/.github/workflows/uberjar-containerize-labeled.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-name: Uberjar Containerize labeled
-
-on:
- pull_request:
- types: [ labeled, opened, synchronize, reopened ]
-
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
-
-jobs:
- uberjar:
- if: ${{ contains(github.event.pull_request.labels.*.name, 'build-docker-uberjar') || github.event.label.name == 'build-docker-uberjar' }}
- uses: ./.github/workflows/uberjar.yml
- secrets: inherit
-
- containerize:
- needs: [uberjar]
- if: ${{ contains(github.event.pull_request.labels.*.name, 'build-docker-uberjar') || github.event.label.name == 'build-docker-uberjar' }}
- uses: ./.github/workflows/containerize-uberjar.yml
- secrets: inherit
diff --git a/.github/workflows/uberjar.yml b/.github/workflows/uberjar.yml
index 84fc4d5f65d..8eaa60a3d21 100644
--- a/.github/workflows/uberjar.yml
+++ b/.github/workflows/uberjar.yml
@@ -1,108 +1,89 @@
name: Build Uberjar
-# This workflow builds an uberjar and pushes it to dockerhub for any branch, either on-demand,
-# or automatically for the listed branches
+# This workflow builds and containerizes an uberjar and pushes it to dockerhub.
concurrency:
group: uberjar-${{ inputs.commit || github.event.pull_request.head.sha || github.sha }}
cancel-in-progress: false
on:
- push:
- branches:
- - master
- - internal-tools
- - ai-service-port
- - metabot-mbql-improvements
- paths-ignore:
- # config files
- - ".**"
- # documentation
- - "docs/**"
- - "**.md"
- # this covers both BE and FE unit tests, as well as E2E tests
- - "**test/**"
- - "**_test.clj"
- - "**/frontend/**.unit.*"
workflow_dispatch:
inputs:
commit:
description: "Optional full-length commit SHA-1 hash"
+ 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:
description: "Optional full-length commit SHA-1 hash"
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:
- check-existing-artifacts:
+ setup:
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 5
outputs:
- ee_exists: ${{ steps.check-ee.outcome == 'success' }}
- oss_exists: ${{ steps.check-oss.outcome == 'success' }}
- should_build: ${{ steps.decide.outputs.should_build }}
+ build_editions: ${{ steps.matrix.outputs.build_editions }}
+ java_version: ${{ steps.dependencies.outputs.java_version }}
+ node_version: ${{ steps.dependencies.outputs.node_version }}
steps:
- - name: Check out the code
- uses: actions/checkout@v6
- - name: Try to fetch existing EE artifact
+ - uses: actions/checkout@v6
+
+ - name: Check for existing EE uberjar
id: check-ee
- continue-on-error: true
uses: ./.github/actions/fetch-artifact
+ continue-on-error: true
with:
commit: ${{ inputs.commit || github.event.pull_request.head.sha || github.sha }}
edition: ee
- output-name: metabase-ee.jar
+ download: false
- - name: Try to fetch existing OSS artifact
+ - name: Check for existing OSS uberjar
id: check-oss
- continue-on-error: true
uses: ./.github/actions/fetch-artifact
+ continue-on-error: true
with:
commit: ${{ inputs.commit || github.event.pull_request.head.sha || github.sha }}
edition: oss
- output-name: metabase-oss.jar
+ download: false
- - name: Decide if build is needed
- id: decide
- run: |
- EE_EXISTS="${{ steps.check-ee.outcome == 'success' }}"
- OSS_EXISTS="${{ steps.check-oss.outcome == 'success' }}"
-
- echo "EE exists: $EE_EXISTS"
- echo "OSS exists: $OSS_EXISTS"
-
- # Build only if artifacts don't exist for this commit hash
- # Since we build by hash, if artifacts exist for this hash, we don't need to rebuild
- if [[ "$EE_EXISTS" == "false" ]] || [[ "$OSS_EXISTS" == "false" ]]; then
- SHOULD_BUILD="true"
- echo "Will build: ee_exists=$EE_EXISTS, oss_exists=$OSS_EXISTS"
- else
- SHOULD_BUILD="false"
- echo "Skipping build: artifacts exist for this commit hash"
- fi
-
- echo "should_build=$SHOULD_BUILD" >> "$GITHUB_OUTPUT"
-
- # if this is on a release branch, we need to check the build requirements
- get-build-requirements:
- if: |
- !cancelled() &&
- contains(github.ref, 'release-x')
- runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
- timeout-minutes: 10
- outputs:
- java_version: ${{ fromJson(steps.dependencies.outputs.result).java_version }}
- node_version: ${{ fromJson(steps.dependencies.outputs.result).node_version }}
- steps:
- - uses: actions/checkout@v6
+ - name: Create build matrix
+ id: matrix
+ uses: actions/github-script@v9
with:
- sparse-checkout: |
- release
- .github
+ script: | # js
+ const hit = {
+ ee: "${{ steps.check-ee.outputs.fetch-hit }}" === "true",
+ oss: "${{ steps.check-oss.outputs.fetch-hit }}" === "true",
+ };
+
+ // Don't rebuild an edition whose uberjar already exists for this commit.
+ const editions = ['ee', 'oss'].filter((edition) => !hit[edition]);
+
+ core.info(`build: ${editions.join(', ') || '(nothing, both artifacts already exist)'}`);
+
+ core.setOutput('build_editions', JSON.stringify(editions));
+
- name: Prepare release scripts
+ if: ${{ contains(github.ref, 'release-x') }}
uses: ./.github/actions/prepare-release-scripts
+
- name: Get build dependencies
+ if: ${{ contains(github.ref, 'release-x') }}
uses: actions/github-script@v9
id: dependencies
with:
@@ -112,26 +93,22 @@ jobs:
const version = getVersionFromReleaseBranch('${{ github.ref }}');
const requirements = getBuildRequirements(version);
- return {
- java_version: requirements.java,
- node_version: requirements.node,
- };
-
+ core.setOutput('java_version', requirements.java);
+ core.setOutput('node_version', requirements.node);
build:
- needs:
- [check-existing-artifacts, get-build-requirements]
- if: always() && !cancelled() && needs.check-existing-artifacts.outputs.should_build == 'true' && (needs.get-build-requirements.result == 'success' || needs.get-build-requirements.result == 'skipped')
- name: Build MB ${{ matrix.edition }}
+ needs: [setup]
+ if: ${{ needs.setup.outputs.build_editions != '[]' }}
+ name: build (${{ matrix.edition }})
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 15
strategy:
matrix:
- edition: ["ee", "oss"]
+ edition: ${{ fromJson(needs.setup.outputs.build_editions) }}
env:
MB_EDITION: ${{ matrix.edition }}
INTERACTIVE: false
- SKIP_LICENSES: ${{ github.event_name == 'pull_request' }} # faster builds for dev
+ SKIP_LICENSES: ${{ github.event_name == 'pull_request' && !inputs.containerize }} # faster builds for dev
# 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' }}
@@ -143,11 +120,11 @@ jobs:
- name: Prepare front-end environment
uses: ./.github/actions/prepare-frontend
with:
- node-version: "${{ needs.get-build-requirements.outputs.node_version || '22' }}"
+ node-version: "${{ needs.setup.outputs.node_version || '22' }}"
- name: Prepare back-end environment
uses: ./.github/actions/prepare-backend
with:
- java-version: "${{ needs.get-build-requirements.outputs.java_version || 25 }}"
+ java-version: "${{ needs.setup.outputs.java_version || 25 }}"
- name: Build
run: ./bin/build.sh
- name: Upload bundle stats
@@ -168,29 +145,23 @@ jobs:
uses: actions/upload-artifact@v7
with:
# Same key the artifact lookups use, so a build for an explicitly dispatched commit
- # uploads where `check-existing-artifacts` and `check-jar-health` go looking for it.
+ # uploads where `setup` and `jar-healthcheck` 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
- check-jar-health:
+ 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 }}
- name: Is ${{ matrix.edition }} (java ${{ matrix.java-version }}) healthy?
- needs: [build, check-existing-artifacts]
- # We only care about the explicit JAR health check on push to `master` and the `release-` branches.
- # JARs created in random branches on PRs are 99% of the time treated as ephemeral, and used only in e2e tests.
- # E2E tests already have a step where they wait for the instance health check.
- if: |
- always() && !cancelled() &&
- (github.ref_name == 'master' || startsWith(github.ref_name, 'release-')) &&
- (needs.build.result == 'success' || (needs.check-existing-artifacts.outputs.should_build == 'false' && needs.check-existing-artifacts.outputs.ee_exists == 'true' && needs.check-existing-artifacts.outputs.oss_exists == 'true'))
timeout-minutes: 10
strategy:
matrix:
- edition: ["ee", "oss"]
- java-version: [25]
+ edition: [ee, oss]
steps:
- name: Check out the code
uses: actions/checkout@v6
@@ -198,7 +169,7 @@ jobs:
uses: actions/[email protected]
with:
java-package: jre
- java-version: ${{ matrix.java-version }}
+ java-version: ${{ needs.setup.outputs.java_version || 25 }}
distribution: "temurin"
- run: java -version
- name: Retrieve uberjar artifact
@@ -217,3 +188,19 @@ jobs:
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 }}