Skip to content

Commit 8f55503

Browse files
committed
Revamp QA check into a battery included package
1 parent 27abc6d commit 8f55503

31 files changed

+5205
-482
lines changed

airbyte-ci/connectors/connector_ops/poetry.lock

+399-480
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

airbyte-ci/connectors/connector_ops/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ GitPython = "^3.1.29"
1717
pydantic = "^1.9"
1818
PyGithub = "^1.58.0"
1919
rich = "^13.0.0"
20-
pydash = "^7.0.4"
20+
pydash = "^6.0.2"
2121
google-cloud-storage = "^2.8.0"
2222
ci-credentials = {path = "../ci_credentials"}
2323
pandas = "^2.0.3"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Connectors QA
2+
3+
This package has two main purposes:
4+
* Running QA checks on connectors.
5+
* Generating the QA checks documentation that are run on connectors.
6+
7+
8+
9+
## Usage
10+
11+
### Install
12+
13+
```bash
14+
pipx install .
15+
```
16+
17+
This will make `connectors-qa` available in your `PATH`.
18+
19+
20+
Feel free to run `connectors-qa --help` to see the available commands and options.
21+
22+
23+
### Examples
24+
25+
#### Running QA checks on one or more connectors:
26+
27+
```bash
28+
# This command must run from the root of the Airbyte repo
29+
connectors-qa run --name=source-faker --name=source-google-sheets
30+
```
31+
#### Running QA checks on all connectors:
32+
33+
```bash
34+
# This command must run from the root of the Airbyte repo
35+
connectors-qa run --connector-directory=airbyte-integrations/connectors
36+
```
37+
38+
#### Running QA checks on all connectors and generating a JSON report:
39+
40+
```bash
41+
### Generating documentation for QA checks:
42+
connectors-qa run --connector-directory=airbyte-integrations/connectors --report-path=qa_report.json
43+
```
44+
45+
#### Running only specific QA checks on one or more connectors:
46+
47+
```bash
48+
connectors-qa run --name=source-faker --name=source-google-sheets --check=CheckConnectorIconIsAvailable --check=CheckConnectorUsesPythonBaseImage
49+
```
50+
51+
#### Running only specific QA checks on all connectors:
52+
53+
```bash
54+
connectors-qa run --connector-directory=airbyte-integrations/connectors --check=CheckConnectorIconIsAvailable --check=CheckConnectorUsesPythonBaseImage
55+
```
56+
57+
#### Generating documentation for QA checks:
58+
59+
```bash
60+
connectors-qa generate-documentation qa_checks.md
61+
```
62+
63+
## Development
64+
65+
```bash
66+
poetry install
67+
```
68+
69+
### Dependencies
70+
This package uses two local dependencies:
71+
* [`connector_ops`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/connector_ops): To interact with the `Connector` object.
72+
* [`metadata_service/lib`]((https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/metadata_service/lib)): To validate the metadata of the connectors.
73+
74+
### Adding a new QA check
75+
76+
To add a new QA check, you have to create add new class in one of the `checks` module. This class must inherit from `models.Check` and implement the `_run` method. Then, you need to add an instance of this class to the `ENABLED_CHECKS` list of the module.
77+
78+
**Please run the `generate-doumentation` command to update the documentation with the new check and commit it in your PR.**
79+
80+
### Running tests
81+
82+
```bash
83+
poe test
84+
```
85+
86+
### Running type checks
87+
88+
```bash
89+
poe type_check
90+
```
91+
92+
### Running the linter
93+
94+
```bash
95+
poe lint
96+
```

airbyte-ci/connectors/connectors_qa/poetry.lock

+2,457
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[tool.poetry]
2+
name = "connectors-qa"
3+
version = "1.0.0"
4+
description = "A package to run QA checks on Airbyte connectors, generate reports and documentation."
5+
authors = ["Airbyte <[email protected]>"]
6+
readme = "README.md"
7+
packages = [
8+
{ include = "connectors_qa", from = "src" },
9+
]
10+
[tool.poetry.dependencies]
11+
python = "^3.10"
12+
airbyte-connectors-base-images = {path = "../base_images", develop = false}
13+
connector-ops = {path = "../connector_ops", develop = false}
14+
metadata-service = {path = "../metadata_service/lib", develop = false}
15+
pydash = "^6.0.2"
16+
jinja2 = "^3.1.3"
17+
toml = "^0.10.2"
18+
asyncclick = "^8.1.7.1"
19+
asyncer = "^0.0.4"
20+
21+
[tool.poetry.scripts]
22+
connectors-qa = "connectors_qa.cli:connectors_qa"
23+
24+
[tool.poetry.group.dev.dependencies]
25+
ruff = "^0.2.1"
26+
pytest = "^8.0.0"
27+
pytest-mock = "^3.12.0"
28+
mypy = "^1.8.0"
29+
types-toml = "^0.10.8.7"
30+
31+
[build-system]
32+
requires = ["poetry-core"]
33+
build-backend = "poetry.core.masonry.api"
34+
35+
[tool.poe.tasks]
36+
test = "pytest tests"
37+
type_check = "mypy src --disallow-untyped-defs"
38+
lint = "ruff check src"
39+
40+
[tool.airbyte_ci]
41+
extra_poetry_groups = ["dev"]
42+
poe_tasks = ["type_check", "lint", "test"]
43+
required_environment_variables = ["DOCKER_HUB_USERNAME", "DOCKER_HUB_PASSWORD",]

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

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
2+
from .assets import ENABLED_CHECKS as ASSETS_CHECKS
3+
from .metadata import ENABLED_CHECKS as METADATA_CORRECTNESS_CHECKS
4+
from .security import ENABLED_CHECKS as SECURITY_CHECKS
5+
from .packaging import ENABLED_CHECKS as PACKAGING_CHECKS
6+
from .documentation import ENABLED_CHECKS as DOCUMENTATION_CHECKS
7+
8+
ENABLED_CHECKS = (
9+
DOCUMENTATION_CHECKS
10+
+ METADATA_CORRECTNESS_CHECKS
11+
+ PACKAGING_CHECKS
12+
+ ASSETS_CHECKS
13+
+ SECURITY_CHECKS
14+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
2+
3+
4+
from connector_ops.utils import Connector # type: ignore
5+
from connectors_qa.models import Check, CheckCategory, CheckResult
6+
7+
8+
class AssetsCheck(Check):
9+
category = CheckCategory.ASSETS
10+
11+
12+
class CheckConnectorIconIsAvailable(AssetsCheck):
13+
name = "Connectors must have an icon"
14+
description = "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`."
15+
requires_metadata = False
16+
17+
def _run(self, connector: Connector) -> CheckResult:
18+
if not connector.icon_path or not connector.icon_path.exists():
19+
return self.create_check_result(
20+
connector=connector,
21+
passed=False,
22+
message="Icon file is missing. Please create an icon file at the root of the connector code directory.",
23+
)
24+
if not connector.icon_path.name == "icon.svg":
25+
return self.create_check_result(
26+
connector=connector,
27+
passed=False,
28+
message="Icon file is not named 'icon.svg'",
29+
)
30+
return self.create_check_result(connector=connector, passed=True, message="Icon file exists")
31+
32+
33+
ENABLED_CHECKS = [CheckConnectorIconIsAvailable()]

0 commit comments

Comments
 (0)