Skip to content

Conversation

aaronsteers
Copy link
Contributor

@aaronsteers aaronsteers commented Nov 12, 2024

Summary by CodeRabbit

  • New Features

    • Introduced the source-chargebee connector to the testing workflow, enhancing the range of connectors tested.
  • Bug Fixes

    • Improved job efficiency by aborting unnecessary tests based on changes in specified connectors.
  • Improvements

    • Enhanced version validation logic for manifest files, providing clearer error handling and feedback regarding version compatibility.
    • Expanded test coverage for manifest configurations, improving validation and error handling for various scenarios.

@aaronsteers aaronsteers requested a review from pnilan November 12, 2024 16:53
@github-actions github-actions bot added the ci label Nov 12, 2024
Copy link
Contributor

coderabbitai bot commented Nov 12, 2024

📝 Walkthrough
## Walkthrough
The pull request introduces updates to the GitHub Actions workflow configuration for testing connectors in the `.github/workflows/connector-tests.yml` file. It specifically adds the `source-chargebee` connector to the testing matrix of the `connectors_ci` job, which runs on `ubuntu-latest` with a timeout of 360 minutes. The structure of the `cdk_changes` job remains unchanged, but it continues to conditionally trigger the `connectors_ci` job based on modifications detected in relevant directories and files.

## Changes

| File Path                                    | Change Summary                                               |
|----------------------------------------------|-------------------------------------------------------------|
| `.github/workflows/connector-tests.yml`     | Added `source-chargebee` connector to the `connectors_ci` job matrix. |
| `airbyte_cdk/sources/declarative/manifest_declarative_source.py` | Removed `re` module import; added `packaging.version` for version parsing; replaced `_get_version_parts` with `_parse_version` for better version validation. |
| `unit_tests/sources/declarative/test_manifest_declarative_source.py` | Added new test cases for manifest version validation; enhanced error handling and refactored existing tests for clarity. |

## Possibly related PRs
- #42: The changes in the `connectors_ci` job of the `.github/workflows/connector-tests.yml` file in both PRs involve modifications to the job's matrix, specifically the addition of connectors for testing, indicating a direct relationship in the context of workflow configuration.

## Suggested labels
`ci`

How does that look? Anything you'd like to adjust or add? 😊


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 (1)
.github/workflows/connector-tests.yml (1)

73-74: Consider adding test timeouts for individual connectors?

Currently, all connectors share the global 90-minute timeout. Would it make sense to add connector-specific timeouts in the matrix for better resource management? For example:

           - connector: source-chargebee
             cdk_extra: n/a
+            timeout: 45  # or whatever is appropriate based on typical test duration

This could help catch performance regressions earlier. WDYT? 🤔

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 707faac and 42d28eb.

📒 Files selected for processing (1)
  • .github/workflows/connector-tests.yml (1 hunks)
🔇 Additional comments (2)
.github/workflows/connector-tests.yml (2)

73-74: LGTM! The matrix configuration looks good.

The addition of source-chargebee with cdk_extra: n/a follows the same pattern as other similar connectors. This will ensure it's tested consistently with the rest of the suite.


73-74: Verify test stability for source-chargebee

Let's check the test history to ensure we're not adding a flaky test to the required set.

Copy link
Contributor

@pnilan pnilan left a comment

Choose a reason for hiding this comment

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

LGTM

@aaronsteers aaronsteers changed the title ci: always test source-chargbee ci: always test source-chargebee Nov 13, 2024
@aaronsteers
Copy link
Contributor Author

aaronsteers commented Nov 13, 2024

/autofix

Auto-Fix Job Info

This job attempts to auto-fix any linting or formating issues. If any fixes are made,
those changes will be automatically committed and pushed back to the PR.

Note: This job can only be run by maintainers. On PRs from forks, this command requires
that the PR author has enabled the Allow edits from maintainers option.

PR auto-fix job started... Check job output.

✅ Changes applied successfully.

@aaronsteers
Copy link
Contributor Author

The manifest connector runs a version comparison that was not handling the pre-release part of a version number.

image

Resolving by parsing with version.Version from the packaging library.

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 (2)
airbyte_cdk/sources/declarative/manifest_declarative_source.py (2)

257-273: Simplify version comparisons by comparing Version objects directly?

Instead of unpacking and comparing version components as tuples, we can compare Version objects directly since they support rich comparison operations. This can make the code more concise and maintainable. Wdyt?

Apply this diff to simplify the version comparison logic:

-        if (cdk_version.major, cdk_version.minor, cdk_version.micro) == (0, 0, 0):
+        if cdk_version == Version("0.0.0"):
             # Skipping version compatibility check on unreleased dev branch
             pass
-        elif (cdk_version.major, cdk_version.minor) < (
-            manifest_version.major,
-            manifest_version.minor,
-        ):
+        elif cdk_version < manifest_version:
             raise ValidationError(
                 f"The manifest version {manifest_version!s} is greater than the airbyte-cdk package version ({cdk_version!s}). Your "
                 f"manifest may contain features that are not in the current CDK version."
             )
-        elif (manifest_version.major, manifest_version.minor) < (0, 29):
+        elif manifest_version < Version("0.29.0"):
             raise ValidationError(
                 "The low-code framework was promoted to Beta in airbyte-cdk version 0.29.0 and contains many breaking changes to the "
                 f"language. The manifest version {manifest_version!s} is incompatible with the airbyte-cdk package version "
                 f"{cdk_version!s} which contains these breaking changes."
             )

276-287: Update the docstring to reflect the new implementation?

The docstring mentions splitting the version into a tuple and not returning the prerelease part, but the method now returns a Version object. Should we update the docstring to match the current behavior? Wdyt?

Suggested updated docstring:

    """Parses a semantic version string into a Version object.

    Args:
        version (str): The semantic version string to parse.
        version_type (str): A descriptor for the version type used in error messages.

    Returns:
        Version: The parsed version object.

    Raises:
        ValidationError: If the version string is not a valid semantic version.
    """
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4d6b015 and b90a0f0.

📒 Files selected for processing (1)
  • airbyte_cdk/sources/declarative/manifest_declarative_source.py (2 hunks)
🔇 Additional comments (1)
airbyte_cdk/sources/declarative/manifest_declarative_source.py (1)

11-11: Should we add 'packaging' to the project's dependencies?

The packaging module is being imported, but let's ensure it's included in the project's dependencies to avoid any import errors. Wdyt?

Run the following script to check if packaging is listed in the dependencies:

@aaronsteers aaronsteers changed the title ci: always test source-chargebee fix(manifest-connectors): improved version parsing Nov 13, 2024
@aaronsteers aaronsteers changed the title fix(manifest-connectors): improved version parsing fix(manifest-connectors): resolve parsing errors during version comparisons Nov 13, 2024
@github-actions github-actions bot added the bug Something isn't working label Nov 13, 2024
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 (2)
unit_tests/sources/declarative/test_manifest_declarative_source.py (2)

673-679: Is the version parameter necessary in the function signature?

It appears that the version parameter might not be used within the test_manifest_versions function. Removing it could simplify the code. What do you think?

Apply this diff to remove the unused parameter:

 def test_manifest_versions(
     self,
-    version,
     cdk_version,
     manifest_version,
     expected_error,
 ) -> None:

Line range hint 955-1070: Consider moving helper functions outside the test function for reusability

The helper functions load_yaml, extract_refs, resolve_pointer, and validate_refs are defined within the test_declarative_component_schema_valid_ref_links function. Moving them to the module level could improve readability and allow for reuse in other tests. Wdyt?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b90a0f0 and 50b00d5.

📒 Files selected for processing (2)
  • .github/workflows/connector-tests.yml (1 hunks)
  • unit_tests/sources/declarative/test_manifest_declarative_source.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/connector-tests.yml
🔇 Additional comments (1)
unit_tests/sources/declarative/test_manifest_declarative_source.py (1)

647-662: Additional test cases improve version comparison coverage

It's great to see test cases added for release candidates and versions with extra version parts. This enhances the robustness of the version comparison tests. Nice work!

@aaronsteers
Copy link
Contributor Author

aaronsteers commented Nov 18, 2024

/autofix

Auto-Fix Job Info

This job attempts to auto-fix any linting or formating issues. If any fixes are made,
those changes will be automatically committed and pushed back to the PR.

Note: This job can only be run by maintainers. On PRs from forks, this command requires
that the PR author has enabled the Allow edits from maintainers option.

PR auto-fix job started... Check job output.

✅ Changes applied successfully.

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 (2)
airbyte_cdk/sources/declarative/manifest_declarative_source.py (2)

248-272: The version validation logic looks solid! Would you consider a few enhancements? 🤔

The logic is working well, but we could make it even more robust. What do you think about:

  1. Using Version's built-in comparison operators to simplify the code? For example:
-elif (cdk_version.major, cdk_version.minor) < (
-    manifest_version.major,
-    manifest_version.minor,
-):
+elif cdk_version.release[:2] < manifest_version.release[:2]:
  1. Making the error message more specific about version requirements? For example:
-                f"The manifest version {manifest_version!s} is greater than the airbyte-cdk package version ({cdk_version!s}). Your "
-                f"manifest may contain features that are not in the current CDK version."
+                f"The manifest version {manifest_version!s} requires airbyte-cdk version >={manifest_version.major}.{manifest_version.minor}.0, "
+                f"but found version {cdk_version!s}. Please upgrade your CDK version."

wdyt? 🙂


276-295: The implementation looks great! Small suggestion about the docstring 📝

The docstring mentions "splits it into a tuple" and "fourth part (prerelease) is not returned in the tuple", but the method actually returns a Version object. Would you like to update it to better reflect the actual behavior? Maybe something like:

-        """Takes a semantic version represented as a string and splits it into a tuple.
-
-        The fourth part (prerelease) is not returned in the tuple.
+        """Parses a semantic version string into a Version object.
+
+        Args:
+            version: A string representing the semantic version
+            version_type: A string indicating the type of version (for error messages)

         Returns:
             Version: the parsed version object
+        Raises:
+            ValidationError: if the version string is not a valid semantic version
         """

wdyt? 🤔

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 50b00d5 and 08abb7f.

📒 Files selected for processing (1)
  • airbyte_cdk/sources/declarative/manifest_declarative_source.py (2 hunks)
🔇 Additional comments (2)
airbyte_cdk/sources/declarative/manifest_declarative_source.py (2)

10-11: Nice choice using packaging.version! 👍

Using packaging.version is indeed the most reliable way to handle semantic versioning in Python. It's the same library that pip uses internally.


287-295: Verify test coverage for version parsing edge cases

The error handling looks good! Let's make sure we have test coverage for various version formats.

@aaronsteers aaronsteers merged commit 72117aa into main Nov 18, 2024
21 of 22 checks passed
@aaronsteers aaronsteers deleted the aj/ci/add-source-chargbee-to-test branch November 18, 2024 18:51
@aaronsteers aaronsteers added ci and removed ci labels Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ci
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants