The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Measure Embedding SDK Hosted Bundle bundle size (#69743)
Timofey Kachalov127132f8a677
diff --git a/.github/actions/sdk-bundle-size-check/action.yml b/.github/actions/sdk-bundle-size-check/action.ymlnew file mode 100644index 00000000000..3bff3ef8d16--- /dev/null+++ b/.github/actions/sdk-bundle-size-check/action.yml@@ -0,0 +1,71 @@+name: Embedding SDK Bundle Size Check+description: |+ Downloads the current branch's uberjar and the base ref's uberjar,+ extracts embedding-sdk.js from both, compares their sizes,+ and sets output if the size change exceeds the threshold.++inputs:+ edition:+ description: 'Metabase edition (ee or oss)'+ required: true+ base-ref-commit:+ description: 'Commit SHA of the base ref (e.g. merge base).'+ required: true+ threshold-percent:+ description: 'Percent threshold for bundle size change'+ required: true++outputs:+ status:+ description: "Bundle size status: increased, decreased, or stable"+ value: ${{ steps.compare.outputs.status }}+ size_change_percent:+ description: "size change percent (positive = increase, negative = decrease)"+ value: ${{ steps.compare.outputs.size_change_percent }}++runs:+ using: "composite"+ steps:+ - name: Download current uberjar+ uses: actions/download-artifact@v4+ with:+ name: metabase-${{ inputs.edition }}-${{ github.event.pull_request.head.sha || github.sha }}-uberjar+ path: temp/current-uberjar+ - name: Extract embedding-sdk.js from current uberjar+ shell: bash+ run: unzip -j temp/current-uberjar/target/uberjar/metabase.jar frontend_client/app/embedding-sdk.js -d temp/current-bundle+ - name: Download base-ref uberjar+ uses: ./.github/actions/fetch-artifact+ with:+ commit: ${{ inputs.base-ref-commit }}+ edition: ${{ inputs.edition }}+ extract-path: temp/base-ref-uberjar+ - name: Extract embedding-sdk.js from base-ref uberjar+ shell: bash+ run: unzip -j temp/base-ref-uberjar/metabase.jar frontend_client/app/embedding-sdk.js -d temp/base-ref-bundle+ - name: Compare sizes and set output+ id: compare+ shell: bash+ run: |+ current_size=$(wc -c < temp/current-bundle/embedding-sdk.js) || { echo "::error::Failed to read current bundle"; exit 1; }+ base_ref_size=$(wc -c < temp/base-ref-bundle/embedding-sdk.js) || { echo "::error::Failed to read base-ref bundle"; exit 1; }+ [ "$current_size" -gt 0 ] && [ "$base_ref_size" -gt 0 ] || { echo "::error::Bundle file is empty"; exit 1; }++ diff=$((current_size - base_ref_size))+ percent=$(( diff * 100 / base_ref_size ))++ echo "Current size: $current_size bytes"+ echo "Base ref size: $base_ref_size bytes"+ echo "Difference: $diff bytes ($percent%)"++ threshold="${{ inputs.threshold-percent }}"+ if [ "$percent" -gt "$threshold" ]; then+ status="increased"+ elif [ "$percent" -lt "$(( -threshold ))" ]; then+ status="decreased"+ else+ status="stable"+ fi++ echo "status=$status" >> $GITHUB_OUTPUT+ echo "size_change_percent=$percent" >> $GITHUB_OUTPUTdiff --git a/.github/workflows/embedding-sdk.yml b/.github/workflows/embedding-sdk.ymlindex eb91342596a..a85766e9546 100644--- a/.github/workflows/embedding-sdk.yml+++ b/.github/workflows/embedding-sdk.yml@@ -23,6 +23,10 @@ on:description: "Whether to run host and sample apps compatibility tests."required: truetype: boolean+ bundle-size-check:+ description: "Whether to run bundle size check."+ required: true+ type: booleanskip:description: Whether to skip running tests due to one of the artifacts failing to build.required: true@@ -124,8 +128,52 @@ jobs:uses: ./.github/workflows/embedding-sdk-host-sample-apps-tests.ymlsecrets: inherit+ embedding-sdk-bundle-size-check:+ if: inputs.bundle-size-check+ continue-on-error: true+ runs-on: ubuntu-22.04+ timeout-minutes: 5+ env:+ BUNDLE_SIZE_THRESHOLD_PERCENT: 2+ steps:+ - uses: actions/checkout@v4+ - uses: ./.github/actions/sdk-bundle-size-check+ id: compare+ with:+ edition: ee+ base-ref-commit: ${{ github.event.pull_request.base.sha }}+ threshold-percent: ${{ env.BUNDLE_SIZE_THRESHOLD_PERCENT }}++ - name: Comment on PR if bundle size has increased+ uses: ./.github/actions/notify-pull-request+ if: success() && steps.compare.outputs.status == 'increased'+ with:+ remove-previous-comment: true+ add-new-comment: true+ message: "⚠️ Embedding SDK bundle size increased by ${{ steps.compare.outputs.size_change_percent }}% compared to the ${{ github.base_ref }} branch (threshold: ${{ env.BUNDLE_SIZE_THRESHOLD_PERCENT }}%). Please contact Embedding team."+ include-log: false++ - name: Send notification to Slack via Zapier+ if: success() && steps.compare.outputs.status == 'increased'+ shell: bash+ run: |+ curl -s -X POST "${{ secrets.EMBEDDING_ZAPIER_WEBHOOK_URL }}" \+ -d '⚠️ Embedding SDK bundle size increased by ${{ steps.compare.outputs.size_change_percent }}% (threshold: ${{ env.BUNDLE_SIZE_THRESHOLD_PERCENT }}%)++ PR #${{ github.event.pull_request.number }} ${{ github.event.pull_request.title }} (${{ github.event.pull_request.html_url }})'++ - name: Comment on PR if bundle size has decreased+ uses: ./.github/actions/notify-pull-request+ if: success() && steps.compare.outputs.status == 'decreased'+ with:+ remove-previous-comment: true+ add-new-comment: true+ message: "🎉 Embedding SDK bundle size decreased by ${{ steps.compare.outputs.size_change_percent }}% compared to the ${{ github.base_ref }} branch. Nice work!"+ include-log: false+embedding-sdk-tests-result:needs:+ - embedding-sdk-bundle-size-check- embedding-sdk-cli-snippets-type-check- embedding-sdk-docs-snippets-type-check- embedding-sdk-api-documentation-generation-validationdiff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.ymlindex 41c309279ec..d8a419a35ea 100644--- a/.github/workflows/run-tests.yml+++ b/.github/workflows/run-tests.yml@@ -113,6 +113,7 @@ jobs:uses: ./.github/workflows/embedding-sdk.ymlsecrets: inheritwith:+ bundle-size-check: ${{ github.event_name == 'pull_request' && needs.uberjar.result == 'success' && needs.files-changed.outputs.frontend_sources == 'true' }}cli-snippets-type-check: ${{ needs.files-changed.outputs.frontend_sources == 'true' }}docs-snippets-type-check: ${{ needs.files-changed.outputs.embedding_documentation == 'true' }}documentation-validation: ${{ needs.files-changed.outputs.frontend_sources == 'true' }}