Skip to content

Commit 2690277

Browse files
alafanecherejbfbell
authored andcommitted
connectors-ci: fix unhashable type 'set' (#29064)
1 parent 1b77e37 commit 2690277

File tree

8 files changed

+67
-8
lines changed

8 files changed

+67
-8
lines changed

airbyte-ci/connectors/pipelines/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ This command runs the Python tests for a airbyte-ci poetry package.
380380

381381
| Version | PR | Description |
382382
| ------- | --------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
383+
| 0.4.4 | [#29064](https://github.com/airbytehq/airbyte/pull/29064) | Make connector modified files a frozen set. |
383384
| 0.4.3 | [#29033](https://github.com/airbytehq/airbyte/pull/29033) | Disable dependency scanning for Java connectors. |
384385
| 0.4.2 | [#29030](https://github.com/airbytehq/airbyte/pull/29030) | Make report path always have the same prefix: `airbyte-ci/`. |
385386
| 0.4.1 | [#28855](https://github.com/airbytehq/airbyte/pull/28855) | Improve the selected connectors detection for connectors commands. |

airbyte-ci/connectors/pipelines/pipelines/bases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
@dataclass(frozen=True)
4040
class ConnectorWithModifiedFiles(Connector):
41-
modified_files: Set[Path] = field(default_factory=list)
41+
modified_files: Set[Path] = field(default_factory=frozenset)
4242

4343
@property
4444
def has_metadata_change(self) -> bool:

airbyte-ci/connectors/pipelines/pipelines/commands/groups/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@ async def run_test(airbyte_ci_package_path: str) -> bool:
7878
except dagger.ExecError as e:
7979
logger.error("Tests failed")
8080
logger.error(e.stderr)
81-
return False
81+
sys.exit(1)

airbyte-ci/connectors/pipelines/pipelines/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from glob import glob
1616
from io import TextIOWrapper
1717
from pathlib import Path
18-
from typing import TYPE_CHECKING, Any, Callable, List, Optional, Set, Tuple, Union
18+
from typing import TYPE_CHECKING, Any, Callable, FrozenSet, List, Optional, Set, Tuple, Union
1919

2020
import anyio
2121
import asyncer
@@ -359,13 +359,13 @@ def get_modified_connectors(modified_files: Set[Path], all_connectors: Set[Conne
359359
return modified_connectors
360360

361361

362-
def get_connector_modified_files(connector: Connector, all_modified_files: Set[Path]) -> Set[Path]:
362+
def get_connector_modified_files(connector: Connector, all_modified_files: Set[Path]) -> FrozenSet[Path]:
363363
connector_modified_files = set()
364364
for modified_file in all_modified_files:
365365
modified_file_path = Path(modified_file)
366366
if modified_file_path.is_relative_to(connector.code_directory):
367367
connector_modified_files.add(modified_file)
368-
return connector_modified_files
368+
return frozenset(connector_modified_files)
369369

370370

371371
def get_modified_metadata_files(modified_files: Set[Union[str, Path]]) -> Set[Path]:

airbyte-ci/connectors/pipelines/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "pipelines"
7-
version = "0.4.3"
7+
version = "0.4.4"
88
description = "Packaged maintained by the connector operations team to perform CI for connectors' pipelines"
99
authors = ["Airbyte <[email protected]>"]
1010

airbyte-ci/connectors/pipelines/tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
from tests.utils import ALL_CONNECTORS
1616

1717

18-
@pytest.fixture(scope="session")
18+
@pytest.fixture(scope="module")
1919
def anyio_backend():
2020
return "asyncio"
2121

2222

23-
@pytest.fixture(scope="session")
23+
@pytest.fixture(scope="module")
2424
async def dagger_client():
2525
async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client:
2626
yield client
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3+
#
4+
from pathlib import Path
5+
6+
import pytest
7+
from pipelines import bases, gradle
8+
9+
pytestmark = [
10+
pytest.mark.anyio,
11+
]
12+
13+
14+
class TestGradleTask:
15+
class DummyStep(gradle.GradleTask):
16+
gradle_task_name = "dummyTask"
17+
18+
async def _run(self) -> bases.StepResult:
19+
return bases.StepResult(self, bases.StepStatus.SUCCESS)
20+
21+
@pytest.fixture
22+
def test_context(self, mocker, dagger_client):
23+
return mocker.Mock(
24+
secrets_to_mask=[],
25+
dagger_client=dagger_client,
26+
connector=bases.ConnectorWithModifiedFiles(
27+
"source-postgres", frozenset({Path("airbyte-integrations/connectors/source-postgres/metadata.yaml")})
28+
),
29+
)
30+
31+
async def test_build_include(self, test_context):
32+
step = self.DummyStep(test_context)
33+
assert step.build_include

airbyte-ci/connectors/pipelines/tests/test_utils.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,28 @@ def test_get_modified_connectors_with_dependency_scanning(all_connectors, enable
140140
else:
141141
assert not_modified_java_connector not in modified_connectors
142142
assert modified_java_connector in modified_connectors
143+
144+
145+
def test_get_connector_modified_files():
146+
connector = pick_a_random_connector()
147+
other_connector = pick_a_random_connector(other_picked_connectors=[connector])
148+
149+
all_modified_files = {
150+
connector.code_directory / "setup.py",
151+
other_connector.code_directory / "README.md",
152+
}
153+
154+
result = utils.get_connector_modified_files(connector, all_modified_files)
155+
assert result == frozenset({connector.code_directory / "setup.py"})
156+
157+
158+
def test_no_modified_files_in_connector_directory():
159+
connector = pick_a_random_connector()
160+
other_connector = pick_a_random_connector(other_picked_connectors=[connector])
161+
162+
all_modified_files = {
163+
other_connector.code_directory / "README.md",
164+
}
165+
166+
result = utils.get_connector_modified_files(connector, all_modified_files)
167+
assert result == frozenset()

0 commit comments

Comments
 (0)