-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
airbyte-ci: build manifest only with local CDK when flag is passed #48818
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f234eb5
build manifest only with local CDK when flag is passed
alafanechere 9a6814c
bring back `apply_python_development_overrides` test (https://github.…
aaronsteers 026c434
build manifest only with local CDK when flag is passed
alafanechere 48c6381
bring back `apply_python_development_overrides` test (https://github.…
aaronsteers 786360c
fix tests
alafanechere File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,11 @@ | |
from pathlib import Path | ||
from typing import List, Optional, Sequence | ||
|
||
from click import UsageError | ||
from dagger import Container, Directory | ||
from pipelines import hacks | ||
from pipelines.airbyte_ci.connectors.context import ConnectorContext, PipelineContext | ||
from pipelines.consts import PATH_TO_LOCAL_CDK | ||
from pipelines.dagger.containers.python import with_pip_cache, with_poetry_cache, with_python_base, with_testing_dependencies | ||
from pipelines.helpers.utils import check_path_in_workdir, get_file_contents | ||
|
||
|
@@ -238,15 +240,16 @@ def with_python_connector_source(context: ConnectorContext) -> Container: | |
return with_python_package(context, testing_environment, connector_source_path) | ||
|
||
|
||
async def apply_python_development_overrides(context: ConnectorContext, connector_container: Container) -> Container: | ||
def apply_python_development_overrides(context: ConnectorContext, connector_container: Container) -> Container: | ||
# Run the connector using the local cdk if flag is set | ||
if context.use_local_cdk: | ||
# Assume CDK is cloned in a sibling dir to `airbyte`: | ||
path_to_cdk = str(Path("../airbyte-python-cdk").resolve()) | ||
path_to_cdk = str(Path(PATH_TO_LOCAL_CDK).resolve()) | ||
if not Path(path_to_cdk).exists(): | ||
raise FileExistsError(f"Local CDK not found at '{path_to_cdk}'") | ||
raise UsageError( | ||
f"Local CDK not found at '{path_to_cdk}'. Please clone the CDK repository in a sibling directory to the airbyte repository. Or use --use-cdk-ref to specify a CDK ref." | ||
) | ||
Comment on lines
+249
to
+251
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
context.logger.info(f"Using local CDK found at: '{path_to_cdk}'") | ||
|
||
directory_to_mount = context.dagger_client.host().directory(path_to_cdk) | ||
cdk_mount_dir = "/airbyte-cdk/python" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] | ||
name = "pipelines" | ||
version = "4.43.1" | ||
version = "4.44.0" | ||
description = "Packaged maintained by the connector operations team to perform CI for connectors' pipelines" | ||
authors = ["Airbyte <[email protected]>"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
# | ||
|
||
import pytest | ||
from click import UsageError | ||
from pipelines.airbyte_ci.connectors.context import ConnectorContext | ||
from pipelines.dagger.actions.python import common | ||
from pipelines.helpers.connectors.modifed import ConnectorWithModifiedFiles | ||
|
@@ -28,24 +29,32 @@ def connector_context(dagger_client): | |
return context | ||
|
||
|
||
@pytest.mark.skip( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
reason=( | ||
"This is broken since CDK has moved to a separate package. " | ||
"Dagger appears to not have access to the sibling directory. " | ||
+ "See https://github.com/airbytehq/airbyte-internal-issues/issues/10779" | ||
) | ||
) | ||
@pytest.mark.parametrize("use_local_cdk", [True, False]) | ||
async def test_apply_python_development_overrides(connector_context, use_local_cdk): | ||
@pytest.mark.parametrize("use_local_cdk, local_cdk_is_available", [(True, True), (True, False), (False, None)]) | ||
async def test_apply_python_development_overrides( | ||
dagger_client, mocker, tmp_path, connector_context, use_local_cdk, local_cdk_is_available | ||
): | ||
local_cdk_path = tmp_path / "airbyte-python-cdk" | ||
mocker.patch.object(common, "PATH_TO_LOCAL_CDK", local_cdk_path) | ||
if local_cdk_is_available: | ||
local_cdk_path.mkdir() | ||
await dagger_client.git("https://github.com/airbytehq/airbyte-python-cdk", keep_git_dir=False).branch("main").tree().export( | ||
str(local_cdk_path) | ||
) | ||
connector_context.use_local_cdk = use_local_cdk | ||
fake_connector_container = connector_context.dagger_client.container().from_("airbyte/python-connector-base:2.0.0") | ||
before_override_pip_freeze = await fake_connector_container.with_exec(["pip", "freeze"], use_entrypoint=True).stdout() | ||
|
||
assert "airbyte-cdk" not in before_override_pip_freeze.splitlines(), "The base image should not have the airbyte-cdk installed." | ||
connector_with_overrides = await common.apply_python_development_overrides(connector_context, fake_connector_container) | ||
|
||
after_override_pip_freeze = await connector_with_overrides.with_exec(["pip", "freeze"], use_entrypoint=True).stdout() | ||
if use_local_cdk: | ||
assert "airbyte-cdk" not in after_override_pip_freeze.splitlines(), "The override should not install the airbyte-cdk package." | ||
if use_local_cdk and not local_cdk_is_available: | ||
# We assume the local cdk is not available so a UsageError should be raised. | ||
with pytest.raises(UsageError): | ||
await common.apply_python_development_overrides(connector_context, fake_connector_container) | ||
else: | ||
assert "airbyte-cdk" not in after_override_pip_freeze.splitlines(), "The override should install the airbyte-cdk package." | ||
overriden_container = await common.apply_python_development_overrides(connector_context, fake_connector_container) | ||
after_override_pip_freeze = await overriden_container.with_exec(["pip", "freeze"], use_entrypoint=True).stdout() | ||
|
||
if use_local_cdk and local_cdk_is_available: | ||
assert ( | ||
"airbyte-cdk @ file:///airbyte-cdk/python" in after_override_pip_freeze.splitlines() | ||
), "The override should install the airbyte-cdk package." | ||
else: | ||
assert after_override_pip_freeze == before_override_pip_freeze, "The override should not change the pip freeze output." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed - this is no longer a coroutine but the return value (Container) is still awaitable. 👍