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

fix: combined publish flow for CDK/SDM #77

Merged
merged 43 commits into from
Nov 20, 2024

Conversation

ChristoGrab
Copy link
Collaborator

@ChristoGrab ChristoGrab commented Nov 20, 2024

What

  • Consolidates the steps to publish the CDK to PyPI and Source Declarative Manifest to Dockerhub into a single workflow.
  • Updates the path of the uploaded build artifacts to match the path used during the build
  • Updates the SDM Dockerfile to use the build artifacts

Warning

99% sure the workflow_dispatch trigger is still broken. I ran into issues with the input version not being respected by the build step, leading to all sorts of shenanigans. Decided to prioritize getting the release trigger working to unblock us on publishing new CDK/SDM versions. Fow now, the following should run and work:

  • Build: any push
  • Publish (PYPI + DOCKERHUB): new releases

Summary by CodeRabbit

  • New Features

    • Enhanced packaging and publishing workflow for Python projects, including new version input and improved artifact management.
    • Added a new job for publishing Docker images to DockerHub, ensuring multi-platform support and tag management.
  • Improvements

    • Streamlined Dockerfile for Python projects, simplifying installation by using pre-built wheel files.
  • Bug Fixes

    • Removed unnecessary build steps in the Dockerfile to optimize the build process.

ChristoGrab and others added 30 commits November 19, 2024 09:05
@github-actions github-actions bot added bug Something isn't working security labels Nov 20, 2024
uses: actions/download-artifact@v4
with:
name: Packages-${{ github.run_id }}
path: dist
Copy link
Collaborator Author

@ChristoGrab ChristoGrab Nov 20, 2024

Choose a reason for hiding this comment

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

Adding this step is necessary to ensure that the SDM image has access to the build artifact and can utilize the correct CDK version

@@ -13,6 +14,6 @@ RUN poetry config virtualenvs.create false \
COPY airbyte_cdk ./airbyte_cdk

# Build and install the package
RUN poetry build && pip install dist/*.whl
RUN pip install dist/*.whl
Copy link
Collaborator Author

@ChristoGrab ChristoGrab Nov 20, 2024

Choose a reason for hiding this comment

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

Updated this as it would overwrite the CDK version obtained from the build artifact

@@ -4,6 +4,7 @@ WORKDIR /airbyte/integration_code

# Copy project files needed for build
COPY pyproject.toml poetry.lock README.md ./
COPY dist/*.whl ./dist/
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy the packages obtained from the build

Copy link
Contributor

Choose a reason for hiding this comment

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

A comment + link to code on what builds it and why we think it'll be there would help!

@ChristoGrab ChristoGrab marked this pull request as ready for review November 20, 2024 11:56
Copy link
Contributor

coderabbitai bot commented Nov 20, 2024

📝 Walkthrough

Walkthrough

The pull request includes the deletion of the .github/workflows/cdk-publish.yml file, which defined a GitHub Actions workflow for testing and publishing Docker images related to the Airbyte project. Additionally, the .github/workflows/pypi_publish.yml file has been updated to enhance its functionality, including adding a version input for publishing, improving artifact management, and introducing a new job for publishing SDM to DockerHub. The Dockerfile has also been modified to streamline the build process by simplifying the installation of Python packages.

Changes

File Change Summary
.github/workflows/cdk-publish.yml Deleted. Defined a workflow for testing and publishing Docker images, including jobs for building and testing images, and pushing to Docker Hub.
.github/workflows/pypi_publish.yml Updated workflow name to "Packaging and Publishing," added a version input for publishing, modified the build job to conditionally use the version input, introduced an artifact upload step, renamed the publish job to "Publish CDK version to PyPI," and added a new job publish_sdm for DockerHub publishing.
Dockerfile Modified to copy built wheel files from the dist directory into the Docker image and simplified the installation command by removing the poetry build step, using pip install dist/*.whl instead.

Possibly related PRs

  • Feat: Incorporate SDM in CDK and add publish workflow #58: The changes in this PR introduce a new GitHub Actions workflow for publishing Docker images, which is directly related to the deleted workflow in the main PR that also handled publishing Docker images for the Source Declarative Manifest.

Suggested labels

ci, enhancement

Suggested reviewers

  • aaronsteers
  • alafanechere

Wdyt about having a discussion with the reviewers to clarify any points before merging?


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (5)
Dockerfile (1)

7-7: Consider adding error handling for missing wheel files?

The COPY command will fail silently if no wheel files exist in the dist directory. Maybe we could add a quick check before the copy? wdyt?

+RUN [ -d dist ] && [ "$(ls -A dist/*.whl 2>/dev/null)" ] || (echo "No wheel files found in dist directory" && exit 1)
 COPY dist/*.whl ./dist/
.github/workflows/pypi_publish.yml (4)

3-9: Consider limiting the push trigger scope

The current push trigger runs on all pushes to all branches. Would it make more sense to limit this to specific paths or branches to avoid unnecessary builds? For example:

on:
  push:
+    paths:
+      - 'airbyte/**'
+      - 'setup.py'
+      - 'pyproject.toml'
+    branches:
+      - main
+      - 'v*'
  workflow_dispatch:

wdyt? 🤔


Line range hint 46-54: Add error handling for release upload

The release upload step could benefit from some error handling. Maybe something like:

  - name: Upload wheel to release
    if: startsWith(github.ref, 'refs/tags/v')
    uses: svenstaro/upload-release-action@v2
    with:
      repo_token: ${{ secrets.GITHUB_TOKEN }}
      file: dist/*.whl
      tag: ${{ github.ref }}
      overwrite: true
      file_glob: true
+     fail_on_unmatched_files: true

This would fail explicitly if no wheel files are found. What do you think? 🛠️


101-114: Enhance tag existence check robustness

The tag check is good, but we could make it more resilient:

  - name: Check for existing tag
    run: |
+     set -euo pipefail
      tag="airbyte/source-declarative-manifest:${{ env.VERSION }}"
-     if [ -z "$tag" ]; then
+     if [ -z "${tag:-}" ]; then
        echo "Error: VERSION is not set. Ensure the tag follows the format 'refs/tags/vX.Y.Z'."
        exit 1
      fi

This adds better error handling and safer variable expansion. Thoughts? 🤔


115-124: Consider extracting platform list to reusable variable

For better maintainability, we could define platforms as a variable:

+ env:
+   PLATFORMS: linux/amd64,linux/arm64

  - name: Build and push
    uses: docker/build-push-action@v5
    with:
      context: .
-     platforms: linux/amd64,linux/arm64
+     platforms: ${{ env.PLATFORMS }}
      push: true

This makes it easier to update supported platforms in the future. What do you think? 💭

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 19afe5a and 598d11e.

📒 Files selected for processing (3)
  • .github/workflows/cdk-publish.yml (0 hunks)
  • .github/workflows/pypi_publish.yml (2 hunks)
  • Dockerfile (2 hunks)
💤 Files with no reviewable changes (1)
  • .github/workflows/cdk-publish.yml
🧰 Additional context used
🪛 actionlint
.github/workflows/pypi_publish.yml

72-72: shellcheck reported issue in this script: SC2086:info:2:54: Double quote to prevent globbing and word splitting

(shellcheck)


78-78: shellcheck reported issue in this script: SC2086:info:2:42: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (2)
Dockerfile (1)

17-17: LGTM! Simple and effective approach.

Using pre-built wheels is more deterministic than building during the Docker build. Would you consider adding a quick version check after installation to ensure we got the right version? Something like:

 RUN pip install dist/*.whl
+RUN pip freeze | grep airbyte-cdk
.github/workflows/pypi_publish.yml (1)

22-28: Consider adding artifact retention policy

The artifact upload looks good, but we might want to add retention settings to manage storage. How about:

  - uses: actions/upload-artifact@v4
    with:
      name: Packages-${{ github.run_id }}
+     retention-days: 5
      path: |
        /tmp/baipp/dist/*.whl
        /tmp/baipp/dist/*.tar.gz

Also, could you verify that /tmp/baipp/dist/ is the correct path for the build artifacts? 🔍

.github/workflows/pypi_publish.yml Show resolved Hide resolved
with:
name: Packages-${{ github.run_id }}
path: |
/tmp/baipp/dist/*.whl
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Had to specify this path for uploading build artifacts as the /dist directory was not matching the path in the previous step

steps:
- uses: actions/download-artifact@v4
with:
name: Packages
name: Packages-${{ github.run_id }}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Had to make this name unique for each run to avoid 409 errors being thrown

@aaronsteers aaronsteers merged commit b276f10 into main Nov 20, 2024
25 of 26 checks passed
@aaronsteers aaronsteers deleted the christo/publish-flow-debugging branch November 20, 2024 20:47
tags: |
airbyte/source-declarative-manifest:latest
airbyte/source-declarative-manifest:${{ env.VERSION }}
airbyte/source-declarative-manifest:${{ github.sha }}
Copy link
Contributor

Choose a reason for hiding this comment

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

@aaronsteers and @ChristoGrab: do we really want to push builds for sha tags to public dockerhub repo? Wouldn't it be too noisy?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants