Skip to content

Commit 8264b74

Browse files
alafanecherejatinyadav-cc
authored andcommitted
connectors_qa: make CheckPublishToPyPiIsEnabled only run on source connectors (airbytehq#35426)
1 parent bf3a88b commit 8264b74

File tree

7 files changed

+56
-2
lines changed

7 files changed

+56
-2
lines changed

airbyte-ci/connectors/connectors_qa/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,13 @@ poe type_check
9797

9898
```bash
9999
poe lint
100-
```
100+
```
101+
102+
## Changelog
103+
104+
### 1.0.1
105+
* Add `applies_to_connector_types` attribute to `Check` class to specify the connector types that the check applies to.
106+
* Make `CheckPublishToPyPiIsEnabled` run on source connectors only.
107+
108+
### 1.0.0
109+
Initial release of `connectors-qa` package.

airbyte-ci/connectors/connectors_qa/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "connectors-qa"
3-
version = "1.0.0"
3+
version = "1.0.1"
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class CheckPublishToPyPiIsEnabled(PackagingCheck):
4949
ConnectorLanguage.PYTHON,
5050
ConnectorLanguage.LOW_CODE,
5151
]
52+
applies_to_connector_types = ["source"]
5253

5354
def _run(self, connector: Connector) -> CheckResult:
5455
publish_to_pypi_is_enabled = get(connector.metadata, "remoteRegistries.pypi.enabled", False)

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
ConnectorLanguage.PYTHON,
2020
]
2121

22+
ALL_TYPES = ["source", "destination"]
23+
2224

2325
class CheckCategory(Enum):
2426
"""The category of a QA check"""
@@ -110,6 +112,15 @@ def applies_to_connector_languages(self) -> List[ConnectorLanguage]:
110112
"""
111113
return ALL_LANGUAGES
112114

115+
@property
116+
def applies_to_connector_types(self) -> List[str]:
117+
"""The connector types that the QA check applies to
118+
119+
Returns:
120+
List[str]: The connector types that the QA check applies to
121+
"""
122+
return ALL_TYPES
123+
113124
@property
114125
@abstractmethod
115126
def category(self) -> CheckCategory:
@@ -136,6 +147,11 @@ def run(self, connector: Connector) -> CheckResult:
136147
connector,
137148
f"Check does not apply to {connector.language.value} connectors",
138149
)
150+
if connector.type not in self.applies_to_connector_types:
151+
return self.skip(
152+
connector,
153+
f"Check does not apply to {connector.type} connectors",
154+
)
139155
return self._run(connector)
140156

141157
def _run(self, connector: Connector) -> CheckResult:

airbyte-ci/connectors/connectors_qa/src/connectors_qa/templates/qa_checks.md.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ They are by no mean replacing the need for a manual review of the connector code
1010
## {{ category.value }}
1111
{% for check in checks %}
1212
### {{ check.name }}
13+
*Applies to the following connector types: {{ ', '.join(check.applies_to_connector_types) }}*
1314
*Applies to the following connector languages: {{ ', '.join(check.applies_to_connector_languages) }}*
1415

1516
{{ check.description }}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,16 @@ def test_skip_when_language_does_not_apply(self, mocker):
5050

5151
# Assert
5252
assert all(result.status == CheckStatus.SKIPPED for result in results)
53+
54+
def test_skip_when_type_does_not_apply(self, mocker):
55+
# Arrange
56+
connector = mocker.MagicMock(type="destination")
57+
58+
# Act
59+
results = []
60+
for check in ENABLED_CHECKS:
61+
if connector.type not in check.applies_to_connector_types:
62+
results.append(check.run(connector))
63+
64+
# Assert
65+
assert all(result.status == CheckStatus.SKIPPED for result in results)

docs/contributing-to-airbyte/resources/qa-checks.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,71 +10,85 @@ They are by no mean replacing the need for a manual review of the connector code
1010
## 📄 Documentation
1111

1212
### Breaking changes must be accompanied by a migration guide
13+
*Applies to the following connector types: source, destination*
1314
*Applies to the following connector languages: java, low-code, python*
1415

1516
When a breaking change is introduced, we check that a migration guide is available. It should be stored under `./docs/integrations/<connector-type>s/<connector-name>-migrations.md`.
1617
This document should contain a section for each breaking change, in order of the version descending. It must explain users which action to take to migrate to the new version.
1718
### Connectors must have user facing documentation
19+
*Applies to the following connector types: source, destination*
1820
*Applies to the following connector languages: java, low-code, python*
1921

2022
The user facing connector documentation should be stored under `./docs/integrations/<connector-type>s/<connector-name>.md`.
2123
### Connectors documentation follows our guidelines
24+
*Applies to the following connector types: source, destination*
2225
*Applies to the following connector languages: java, low-code, python*
2326

2427
The user facing connector documentation should follow the guidelines defined in the [documentation standards](https://hackmd.io/Bz75cgATSbm7DjrAqgl4rw).
2528
### Connectors must have a changelog entry for each version
29+
*Applies to the following connector types: source, destination*
2630
*Applies to the following connector languages: java, low-code, python*
2731

2832
Each new version of a connector must have a changelog entry defined in the user facing documentation in `./docs/integrations/<connector-type>s/<connector-name>.md`.
2933

3034
## 📝 Metadata
3135

3236
### Connectors must have valid metadata.yaml file
37+
*Applies to the following connector types: source, destination*
3338
*Applies to the following connector languages: java, low-code, python*
3439

3540
Connectors must have a `metadata.yaml` file at the root of their directory. This file is used to build our connector registry. Its structure must follow our metadata schema. Field values are also validated. This is to ensure that all connectors have the required metadata fields and that the metadata is valid. More details in this [documentation](https://docs.airbyte.com/connector-development/connector-metadata-file).
3641

3742
## 📦 Packaging
3843

3944
### Connectors must use Poetry for dependency management
45+
*Applies to the following connector types: source, destination*
4046
*Applies to the following connector languages: python, low-code*
4147

4248
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.
4349
### Connectors must be licensed under MIT or Elv2
50+
*Applies to the following connector types: source, destination*
4451
*Applies to the following connector languages: java, low-code, python*
4552

4653
Connectors must be licensed under the MIT or Elv2 license. This is to ensure that all connectors are licensed under a permissive license. More details in our [License FAQ](https://docs.airbyte.com/developer-guides/licenses/license-faq).
4754
### Connector license in metadata.yaml and pyproject.toml file must match
55+
*Applies to the following connector types: source, destination*
4856
*Applies to the following connector languages: python, low-code*
4957

5058
Connectors license in metadata.yaml and pyproject.toml file must match. This is to ensure that all connectors are consistently licensed.
5159
### Connector version must follow Semantic Versioning
60+
*Applies to the following connector types: source, destination*
5261
*Applies to the following connector languages: java, low-code, python*
5362

5463
Connector version must follow the Semantic Versioning scheme. This is to ensure that all connectors follow a consistent versioning scheme. Refer to our [Semantic Versioning for Connectors](https://docs.airbyte.com/contributing-to-airbyte/#semantic-versioning-for-connectors) for more details.
5564
### Connector version in metadata.yaml and pyproject.toml file must match
65+
*Applies to the following connector types: source, destination*
5666
*Applies to the following connector languages: python, low-code*
5767

5868
Connector version in metadata.yaml and pyproject.toml file must match. This is to ensure that connector release is consistent.
5969
### Python connectors must have PyPi publishing enabled
70+
*Applies to the following connector types: source*
6071
*Applies to the following connector languages: python, low-code*
6172

6273
Python connectors must have [PyPi](https://pypi.org/) publishing enabled in their `metadata.yaml` file. This is declared by setting `remoteRegistries.pypi.enabled` to `true` in metadata.yaml. This is to ensure that all connectors can be published to PyPi and can be used in `airbyte-lib`.
6374

6475
## 💼 Assets
6576

6677
### Connectors must have an icon
78+
*Applies to the following connector types: source, destination*
6779
*Applies to the following connector languages: java, low-code, python*
6880

6981
Each connector must have an icon available in at the root of the connector code directory. It must be an SVG file named `icon.svg` and must be a square.
7082

7183
## 🔒 Security
7284

7385
### Connectors must use HTTPS only
86+
*Applies to the following connector types: source, destination*
7487
*Applies to the following connector languages: java, low-code, python*
7588

7689
Connectors must use HTTPS only when making requests to external services.
7790
### Python connectors must not use a Dockerfile and must declare their base image in metadata.yaml file
91+
*Applies to the following connector types: source, destination*
7892
*Applies to the following connector languages: python, low-code*
7993

8094
Connectors must use our Python connector base image (`docker.io/airbyte/python-connector-base`), declared through the `connectorBuildOptions.baseImage` in their `metadata.yaml`.

0 commit comments

Comments
 (0)