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: account for dynamic CDK version #72

Closed
wants to merge 1 commit into from

Conversation

ChristoGrab
Copy link
Collaborator

@ChristoGrab ChristoGrab commented Nov 19, 2024

What

Fixes the publish flow for SDM by accounting for dynamic CDK versioning.

How

  • Use dynamic versioning to determine latest CDK version, then sanitize the tag to use only SemVer-compliant version
  • Modify the workflow to run on any changes to the CDK library code, rather than pyproject

Notes

  • The dependency scan is failing in my tests. This isn't a blocker since the workflow will still complete regardless, but wanted to call it out early.
Screenshot 2024-11-19 at 9 42 07 AM
  • I'm seeing a keyring failure in the logs during the publish flow. Again, not blocking the action from completing successfully, but worth noting here so we can investigate later.
Screenshot 2024-11-19 at 9 13 12 AM

@github-actions github-actions bot added bug Something isn't working security labels Nov 19, 2024
airbyte/source-declarative-manifest:latest
airbyte/source-declarative-manifest:${{ env.CDK_VERSION }}
airbyte/source-declarative-manifest:${{ env.CDK_VERSION }}-${{ github.run_number }}
airbyte/source-declarative-manifest:test
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TODO: Revert the tags before merging to main

paths:
- 'airbyte_cdk/pyproject.toml' # To only publish on CDK version change
- 'airbyte_cdk/**' # Check for any changes in the CDK directory
- '!airbyte_cdk/test/**' # Ignore changes in test CDK test directory
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since the version in pyproject is static and doesn't reflect the actual dynamic CDK version, we default to pushing a new image on any changes to the CDK (except test files)

@ChristoGrab ChristoGrab marked this pull request as ready for review November 19, 2024 17:29
Copy link
Contributor

coderabbitai bot commented Nov 19, 2024

📝 Walkthrough

Walkthrough

The pull request modifies the GitHub Actions workflow file .github/workflows/cdk-publish.yml. Key updates include refined trigger conditions for the main branch, expanded path monitoring for the airbyte_cdk directory, and the introduction of new environment variables for Python Poetry. Enhancements in the publish job include improved CDK version retrieval with error handling, updated Docker tag creation logic, and a new naming convention for tags. Overall, these changes aim to enhance error handling and version management within the workflow.

Changes

File Change Summary
.github/workflows/cdk-publish.yml - Updated trigger conditions to include branch filter for main.
- Expanded monitored paths to include all files in airbyte_cdk, excluding test subdirectory.
- Introduced environment variables for Poetry: POETRY_NO_INTERACTION, POETRY_VIRTUALENVS_CREATE, POETRY_VIRTUALENVS_IN_PROJECT.
- Added steps to set up Python environment, including virtual environment creation and Poetry installation.
- Improved CDK version retrieval with checks for valid semantic versions and error handling.
- Adjusted Docker tag creation logic with a new naming convention including a test prefix.

Possibly related PRs

  • chore: use dynamic versioning #24: The changes in this PR involve updates to the pyproject.toml file, which is directly related to the modifications in the .github/workflows/cdk-publish.yml file regarding the management of environment variables for Poetry and dynamic versioning.
  • Feat: Incorporate SDM in CDK and add publish workflow #58: This PR includes updates to the .github/workflows/cdk-publish.yml file, which aligns with the main PR's changes to enhance the workflow for publishing and managing the Source Declarative Manifest (SDM).

Suggested labels

ci, enhancement

Suggested reviewers

  • aaronsteers
  • alafanechere

Wdyt about these suggestions?


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: 0

🧹 Outside diff range and nitpick comments (3)
.github/workflows/cdk-publish.yml (3)

4-8: LGTM! Consider documenting the trigger conditions?

The trigger conditions are well-structured, focusing on relevant changes while excluding tests. Would it be helpful to add a comment explaining why we're watching the entire airbyte_cdk directory instead of specific files? This could help future maintainers understand the decision, wdyt? 🤔


79-86: How about adding some error handling here?

The Python setup looks good, but what if any of these steps fail? Maybe we could add some error checking? Here's a thought:

 python -m venv .venv || exit 1
 source .venv/bin/activate
-pip install --upgrade pip
-pip install poetry==1.6.1
+pip install --upgrade pip || exit 1
+pip install poetry==1.6.1 || exit 1

What do you think? 🤔


89-119: Great error handling! Small shell scripting enhancement?

The version management is robust with excellent error handling! 🎉 Just a couple of small suggestions:

  1. The grep command could be more precise with word boundaries:
-valid_cdk_version=$(echo "$cdk_version" | grep -Eo '^[0-9]+\.[0-9]+\.[0-9]+')
+valid_cdk_version=$(echo "$cdk_version" | grep -Eo '^\b[0-9]+\.[0-9]+\.[0-9]+\b')
  1. Let's quote the PATH addition to prevent word splitting:
-export PATH="/home/runner/.local/bin:$PATH"
+export PATH="/home/runner/.local/bin:${PATH}"

What are your thoughts on these changes? 🤔

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

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

📒 Files selected for processing (1)
  • .github/workflows/cdk-publish.yml (5 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/cdk-publish.yml

88-88: shellcheck reported issue in this script: SC2086:info:30:46: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (3)
.github/workflows/cdk-publish.yml (3)

44-47: LGTM! Good security practice enhancement

The SARIF format output for Trivy scan results will make it easier to track and analyze vulnerabilities over time. 👍


58-61: LGTM! Well-configured Poetry environment

The Poetry environment variables are appropriately set for CI/CD context, preventing interactive prompts and managing virtualenvs efficiently. 🎯


134-136: ⚠️ Potential issue

Remember to address the TODO about reverting tags

I notice there's a TODO comment about reverting the tags before merging to main. Should we handle this now? Also, the test prefix in the tags suggests this might be temporary - is that intentional? 🤔

source .venv/bin/activate
pip install --upgrade pip
pip install poetry==1.6.1
poetry config virtualenvs.create false
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Probably can either delete this line or the ENV variable on line 61

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.

1 participant