Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate releasing embedding SDK #42516

Merged
merged 47 commits into from May 16, 2024
Merged

Automate releasing embedding SDK #42516

merged 47 commits into from May 16, 2024

Conversation

WiNloSt
Copy link
Member

@WiNloSt WiNloSt commented May 10, 2024

Closes #42498

Description

This PR adds a workflow that will be triggered by workflow_dispatch by providing an optional commit sha.

How to verify

  1. I tested using 0.1.3-test1 as the sdk_version input to the workflow
  2. The current uberjar.yml workflow only builds 1 EE jar since we don't need OSS for this.
    image
  3. The build passes
  4. The PR to update docs + package.json template. Only contains 3 line changes to 2 files regarding the version number upgrade.
  5. Docker image is updated at https://hub.docker.com/layers/metabase/metabase-dev/embedding-sdk-0.1.3-test1/images/sha256-74c6374bbbaf90bf9a805d40f06b54221465cf537ef977d6b528baffaf838360?context=explore
  6. Jar file is updated at https://downloads.metabase.com/sdk/v0.1.3-test1/metabase.jar
  7. The npm package is published at (TODO: Implement the publish step, now it only runs with --dry-run flag). The result is here

@WiNloSt WiNloSt force-pushed the 42498-automate-sdk-release branch from 06b5cbd to a7c1de2 Compare May 13, 2024 12:13
@WiNloSt WiNloSt force-pushed the 42498-automate-sdk-release branch from a7c1de2 to c038d2e Compare May 13, 2024 13:33
@WiNloSt WiNloSt force-pushed the 42498-automate-sdk-release branch from 7997bc5 to c038d2e Compare May 13, 2024 13:48
@WiNloSt WiNloSt mentioned this pull request May 13, 2024
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@WiNloSt WiNloSt added the no-backport Do not backport this PR to any branch label May 14, 2024
Copy link
Member

@nemanjaglumac nemanjaglumac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments that I hope you'll find usefull.

Just to repeat once again, I think we should start with a separate uberjar-sdk.yml workflow until we learn how are we going to use this.

Great work overall! 🥇

Comment on lines 11 to 12
commit:
description: 'Optional full-length commit SHA-1 hash'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to make commit required in the future.
This really depends on how we end up using this workflow, or rather - what are we going to "tie" the SDK to.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0639cfb

Comment on lines +14 to +18
concurrency:
# We want to ensure only one job is running at a time because
# there could be a conflict when updating the readme file.
group: ${{ github.workflow }}
cancel-in-progress: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

run: |
git push origin ${{ env.tag }}
- if: failure()
run: echo "Make sure the tag '${{ env.tag }}' doesn't exist."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably expand this message a bit.
A failure can happen for many reasons. Just one of them can be that the tag exists.

Btw, this is the reason why I prefer what @iethree did with the release process where he is using the official GitHub's "OctoKit" REST endpoints. The response might contain the reason why something failed.

runs-on: ubuntu-22.04
timeout-minutes: 20
steps:
- name: Check out the code using the provided commit, or HEAD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the description to reflect the proper ref used here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0639cfb

name: metabase-${{ github.sha }}-sdk
path: ./resources/embedding-sdk

build-jar:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this has the chance to be only a temporary solution, I wouldn't alter the existing uberjar.yml workflow (it's heavy already).

WDYT about creating a temporary uberjar-sdk.yml instead?
The benefit is that you can create it either as a workflow or as a composite action even.

I feel 90% confident that we should not modify the existing uberjar workflow for now.

runs-on: ubuntu-22.04
timeout-minutes: 20
steps:
- name: Check out the code using the provided commit, or HEAD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the description, or omit it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 0639cfb

- name: Check out the code using the provided commit, or HEAD
uses: actions/checkout@v4
with:
ref: master
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be useful to have as an actual comment in the code.

@@ -26,15 +36,15 @@ jobs:
timeout-minutes: 40
strategy:
matrix:
edition: [ee, oss]
edition: ${{ fromJSON(inputs.only_ee && '["ee"]' || '["ee", "oss"]') }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't modify the existing workflow.
But if we do end up doing that, the alternative to parameterizing the matrix is to have a conditional step execution. You can provide something like if workflow_call AND edition is EE, then execute this step.

This comes with tradeoffs, for sure.
If you have to do this for every single step out there, then it makes sense to parameterize the matrix, for sure.

Please check include and exclude

env:
MB_EDITION: ${{ matrix.edition }}
INTERACTIVE: false
steps:
- name: Check out the code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.commit }}
ref: ${{ inputs.commit }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the commit that comes from SDK is optional.
Which means that it's going to default to the HEAD.

So what happens in SDK builds from commit abc on master, and by the time this workflow kicks in someone pushed another commit. In that case the uberjar workflow will build from commit def.

This is not hard to imagine given the frequency we push to master (especially just prior to the release).

@WiNloSt WiNloSt removed the request for review from deniskaber May 16, 2024 09:19
@WiNloSt WiNloSt force-pushed the 42498-automate-sdk-release branch from 78650e3 to 5df46dd Compare May 16, 2024 10:14
env:
BUCKET: ${{ vars.AWS_S3_DOWNLOADS_BUCKET }}
BUCKET_PATH: sdk/v${{ inputs.sdk_version }}/metabase.jar
OUTPUT_FILE: ./target/uberjar/metabase.jar
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the name "output file" a bit ambiguous in this context as it's used as the first parameter of cp, can we just inline it in the cp command as it seems it's only used once?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I shamelessly copied that from

BUCKET: ${{ inputs.bucket }}
OUTPUT_FILE: ${{ inputs.output-name }}
😅 .

The reason I don't inline all of theme since it makes it hard to read since the line would be superlong. Would renaming this env instead help? e.g. INPUT_FILE or just FILE since we're copying files also I think we don't need a bracket just $FILE should work

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 87b22fc

app-id: ${{ secrets.METABASE_BOT_APP_ID }}
private-key: ${{ secrets.METABASE_BOT_APP_PRIVATE_KEY }}

- name: Create a PR updating readme + published version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure, this PR that gets created will update the versions, but the package with the specified version will already be published right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, but to be specific the package would be published in the last step within this job. The PR would have been created at this step and we will have to manually merge the PR.

Realistically, by the time we look at the PR, the SDK package would already likely be published.

@@ -0,0 +1,149 @@
name: Build + Docker Uberjar for SDK
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is copied over from uberjar.yml and

  1. strip out unused parts e.g. steps that only run on master
  2. all triggers outside workflow_call
  3. Simplify the artifact name to metabase-ee-uberjar
  4. accepts a new input image_name previously the image name is determined from a branch name that triggers the workflow, but we want to use the tag name (which created within the workflow) instead.

@WiNloSt WiNloSt assigned nemanjaglumac and unassigned WiNloSt May 16, 2024
Comment on lines 131 to 133
- name: Retag and push images if dev branch
if: ${{ !(startsWith(github.ref_name,'master') || startsWith(github.ref_name,'backport')) && matrix.edition == 'ee' }}
run: docker tag localhost:5000/metabase-dev:${{ env.image_name }}-ee ${{ github.repository_owner }}/metabase-dev:${{ env.image_name }} && docker push ${{ github.repository_owner }}/metabase-dev:${{ env.image_name }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, if you build from master, this will not push to DockerHub.
Is it the intended behavior?

Copy link
Member Author

@WiNloSt WiNloSt May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. I need to fix this. Not intended by any mean. This is just a stripdown version of uberjar.yml


- name: Create a new git tag
run: |
git tag ${{ env.tag }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:
Do we intentionally provide only a lightweight tag here?

cc @WiNloSt

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have any information we want to include in the annotated tag other than repeating the version in the tag name itself, so it should be safe to use a lightweight tag here.

Copy link
Member

@nemanjaglumac nemanjaglumac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's always tricky to review GH actions workflows because it's so easy to overlook something. But you're already testing the workflows by running then successfully ✅

Overall, this looks good to me.
Thanks for addressing the comments.

P.S. Depending on what the future for SDK holds, I think it makes sense to move a lot of the logic to the release/ folder that @iethree maintains. That would give you the ability to test and validate utils thoroughly.

@WiNloSt WiNloSt enabled auto-merge (squash) May 16, 2024 12:39
@WiNloSt WiNloSt merged commit 3dbeb3b into master May 16, 2024
109 checks passed
@WiNloSt WiNloSt deleted the 42498-automate-sdk-release branch May 16, 2024 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.CI & Tests no-backport Do not backport this PR to any branch .Team/Embedding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automate releasing Metabase Embedding SDK for React
5 participants