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

connectors-ci: fix unhashable type 'set' #29064

Merged
merged 6 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions airbyte-ci/connectors/pipelines/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ This command runs the Python tests for a airbyte-ci poetry package.

| Version | PR | Description |
| ------- | --------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| 0.4.4 | [#29064](https://github.com/airbytehq/airbyte/pull/29064) | Make connector modified files a frozen set. |
| 0.4.3 | [#29033](https://github.com/airbytehq/airbyte/pull/29033) | Disable dependency scanning for Java connectors. |
| 0.4.2 | [#29030](https://github.com/airbytehq/airbyte/pull/29030) | Make report path always have the same prefix: `airbyte-ci/`. |
| 0.4.1 | [#28855](https://github.com/airbytehq/airbyte/pull/28855) | Improve the selected connectors detection for connectors commands. |
Expand Down
2 changes: 1 addition & 1 deletion airbyte-ci/connectors/pipelines/pipelines/bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

@dataclass(frozen=True)
class ConnectorWithModifiedFiles(Connector):
modified_files: Set[Path] = field(default_factory=list)
modified_files: Set[Path] = field(default_factory=frozenset)

@property
def has_metadata_change(self) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ async def run_test(airbyte_ci_package_path: str) -> bool:
except dagger.ExecError as e:
logger.error("Tests failed")
logger.error(e.stderr)
return False
sys.exit(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this one changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I figured the return False did not lead to a 1 exit code and the test looked passing from a GHA standpoint...

6 changes: 3 additions & 3 deletions airbyte-ci/connectors/pipelines/pipelines/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from glob import glob
from io import TextIOWrapper
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, List, Optional, Set, Tuple, Union
from typing import TYPE_CHECKING, Any, Callable, FrozenSet, List, Optional, Set, Tuple, Union

import anyio
import asyncer
Expand Down Expand Up @@ -359,13 +359,13 @@ def get_modified_connectors(modified_files: Set[Path], all_connectors: Set[Conne
return modified_connectors


def get_connector_modified_files(connector: Connector, all_modified_files: Set[Path]) -> Set[Path]:
def get_connector_modified_files(connector: Connector, all_modified_files: Set[Path]) -> FrozenSet[Path]:
connector_modified_files = set()
for modified_file in all_modified_files:
modified_file_path = Path(modified_file)
if modified_file_path.is_relative_to(connector.code_directory):
connector_modified_files.add(modified_file)
return connector_modified_files
return frozenset(connector_modified_files)


def get_modified_metadata_files(modified_files: Set[Union[str, Path]]) -> Set[Path]:
Expand Down
2 changes: 1 addition & 1 deletion airbyte-ci/connectors/pipelines/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "pipelines"
version = "0.4.3"
version = "0.4.4"
description = "Packaged maintained by the connector operations team to perform CI for connectors' pipelines"
authors = ["Airbyte <contact@airbyte.io>"]

Expand Down
4 changes: 2 additions & 2 deletions airbyte-ci/connectors/pipelines/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
from tests.utils import ALL_CONNECTORS


@pytest.fixture(scope="session")
@pytest.fixture(scope="module")
def anyio_backend():
return "asyncio"


@pytest.fixture(scope="session")
@pytest.fixture(scope="module")
async def dagger_client():
async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client:
yield client
Expand Down
33 changes: 33 additions & 0 deletions airbyte-ci/connectors/pipelines/tests/test_gradle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
from pathlib import Path

import pytest
from pipelines import bases, gradle

pytestmark = [
pytest.mark.anyio,
]


class TestGradleTask:
class DummyStep(gradle.GradleTask):
gradle_task_name = "dummyTask"

async def _run(self) -> bases.StepResult:
return bases.StepResult(self, bases.StepStatus.SUCCESS)

@pytest.fixture
def test_context(self, mocker, dagger_client):
return mocker.Mock(
secrets_to_mask=[],
dagger_client=dagger_client,
connector=bases.ConnectorWithModifiedFiles(
"source-postgres", frozenset({Path("airbyte-integrations/connectors/source-postgres/metadata.yaml")})
),
)

async def test_build_include(self, test_context):
step = self.DummyStep(test_context)
assert step.build_include
25 changes: 25 additions & 0 deletions airbyte-ci/connectors/pipelines/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,28 @@ def test_get_modified_connectors_with_dependency_scanning(all_connectors, enable
else:
assert not_modified_java_connector not in modified_connectors
assert modified_java_connector in modified_connectors


def test_get_connector_modified_files():
connector = pick_a_random_connector()
other_connector = pick_a_random_connector(other_picked_connectors=[connector])

all_modified_files = {
connector.code_directory / "setup.py",
other_connector.code_directory / "README.md",
}

result = utils.get_connector_modified_files(connector, all_modified_files)
assert result == frozenset({connector.code_directory / "setup.py"})


def test_no_modified_files_in_connector_directory():
connector = pick_a_random_connector()
other_connector = pick_a_random_connector(other_picked_connectors=[connector])

all_modified_files = {
other_connector.code_directory / "README.md",
}

result = utils.get_connector_modified_files(connector, all_modified_files)
assert result == frozenset()