Skip to content

Commit b2e7f37

Browse files
authored
connectors-qa: introduce run_on_released_connectors flag (#36818)
1 parent 0e8a9a9 commit b2e7f37

File tree

8 files changed

+48
-3
lines changed

8 files changed

+48
-3
lines changed

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

+20
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151

5252
def download_catalog(catalog_url):
5353
response = requests.get(catalog_url)
54+
response.raise_for_status()
5455
return response.json()
5556

5657

@@ -555,6 +556,25 @@ def normalization_tag(self) -> Optional[str]:
555556
def is_using_poetry(self) -> bool:
556557
return Path(self.code_directory / "pyproject.toml").exists()
557558

559+
@property
560+
def is_released(self) -> bool:
561+
"""Pull the the OSS registry and check if it the current definition ID and docker image tag are in the registry.
562+
If there is a match it means the connector is released.
563+
We use the OSS registry as the source of truth for released connectors as the cloud registry can be a subset of the OSS registry.
564+
565+
Returns:
566+
bool: True if the connector is released, False otherwise.
567+
"""
568+
metadata = self.metadata
569+
registry = download_catalog(OSS_CATALOG_URL)
570+
for connector in registry[f"{self.connector_type}s"]:
571+
if (
572+
connector[f"{self.connector_type}DefinitionId"] == metadata["definitionId"]
573+
and connector["dockerImageTag"] == metadata["dockerImageTag"]
574+
):
575+
return True
576+
return False
577+
558578
def get_secret_manager(self, gsm_credentials: str):
559579
return SecretsManager(connector_name=self.technical_name, gsm_credentials=gsm_credentials)
560580

airbyte-ci/connectors/connector_ops/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

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

airbyte-ci/connectors/connectors_qa/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ poe lint
107107

108108
## Changelog
109109

110+
### 1.1.0
111+
Introduced the `Check.run_on_released_connectors` flag.
112+
110113
### 1.0.4
111114

112115
Adds `htmlcov` to list of ignored directories for `CheckConnectorUsesHTTPSOnly` check.

airbyte-ci/connectors/connectors_qa/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "connectors-qa"
3-
version = "1.0.4"
3+
version = "1.1.0"
44
description = "A package to run QA checks on Airbyte connectors, generate reports and documentation."
55
authors = ["Airbyte <[email protected]>"]
66
readme = "README.md"

airbyte-ci/connectors/connectors_qa/src/connectors_qa/checks/packaging.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class CheckConnectorUsesPoetry(PackagingCheck):
1717
name = "Connectors must use Poetry for dependency management"
1818
description = "Connectors must use [Poetry](https://python-poetry.org/) for dependency management. This is to ensure that all connectors use a dependency management tool which locks dependencies and ensures reproducible installs."
1919
requires_metadata = False
20+
runs_on_released_connectors = False
2021
applies_to_connector_languages = [
2122
ConnectorLanguage.PYTHON,
2223
ConnectorLanguage.LOW_CODE,

airbyte-ci/connectors/connectors_qa/src/connectors_qa/checks/security.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class CheckConnectorUsesHTTPSOnly(SecurityCheck):
1717
name = "Connectors must use HTTPS only"
1818
description = "Connectors must use HTTPS only when making requests to external services."
1919
requires_metadata = False
20+
runs_on_released_connectors = False
2021

2122
ignore_comment = "# ignore-https-check" # Define the ignore comment pattern
2223

airbyte-ci/connectors/connectors_qa/src/connectors_qa/models.py

+6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def __repr__(self) -> str:
6363
class Check(ABC):
6464

6565
requires_metadata: bool = True
66+
runs_on_released_connectors: bool = True
6667

6768
@property
6869
@abstractmethod
@@ -135,6 +136,11 @@ def category(self) -> CheckCategory:
135136
raise NotImplementedError("Subclasses must implement category property/attribute")
136137

137138
def run(self, connector: Connector) -> CheckResult:
139+
if not self.runs_on_released_connectors and connector.is_released:
140+
return self.skip(
141+
connector,
142+
"Check does not apply to released connectors",
143+
)
138144
if not connector.metadata and self.requires_metadata:
139145
return self.fail(
140146
connector,

airbyte-ci/connectors/connectors_qa/tests/unit_tests/test_models.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_fail_when_requires_metadata_and_metata_is_missing(self, mocker):
2727

2828
def test_fail_when_language_is_missing(self, mocker):
2929
# Arrange
30-
connector = mocker.MagicMock(language=None)
30+
connector = mocker.MagicMock(language=None, is_released=False)
3131

3232
# Act
3333
results = []
@@ -63,3 +63,17 @@ def test_skip_when_type_does_not_apply(self, mocker):
6363

6464
# Assert
6565
assert all(result.status == CheckStatus.SKIPPED for result in results)
66+
67+
def test_skip_when_check_does_not_apply_to_released_connectors(self, mocker):
68+
# Arrange
69+
connector = mocker.MagicMock(is_released=True)
70+
71+
# Act
72+
results = []
73+
for check in ENABLED_CHECKS:
74+
if not check.runs_on_released_connectors:
75+
results.append(check.run(connector))
76+
77+
# Assert
78+
assert all(result.status == CheckStatus.SKIPPED for result in results)
79+
assert all(result.message == "Check does not apply to released connectors" for result in results)

0 commit comments

Comments
 (0)