Skip to content

Commit 8a10c02

Browse files
committed
doc: Document our connectors QA checks
1 parent 553c9b0 commit 8a10c02

File tree

13 files changed

+198
-62
lines changed

13 files changed

+198
-62
lines changed

airbyte-ci/connectors/connectors_qa/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ This package uses two local dependencies:
7575

7676
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.
7777

78-
**Please run the `generate-doumentation` command to update the documentation with the new check and commit it in your PR.**
78+
**Please run the `generate-documentation` command to update the documentation with the new check and commit it in your PR.**:
79+
```bash
80+
# From airbyte repo root
81+
connectors-qa generate-documentation docs/contributing-to-airbyte/resources/qa-checks.md
82+
```
7983

8084
### Running tests
8185

airbyte-ci/connectors/connectors_qa/poetry.lock

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

airbyte-ci/connectors/connectors_qa/pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ pytest = "^8.0.0"
2727
pytest-mock = "^3.12.0"
2828
mypy = "^1.8.0"
2929
types-toml = "^0.10.8.7"
30+
pytest-asyncio = "^0.23.5"
31+
gitpython = "^3.1.42"
3032

3133
[build-system]
3234
requires = ["poetry-core"]

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class AssetsCheck(Check):
1111

1212
class CheckConnectorIconIsAvailable(AssetsCheck):
1313
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`."
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` and must be a square."
1515
requires_metadata = False
1616

1717
def _run(self, connector: Connector) -> CheckResult:
@@ -27,6 +27,7 @@ def _run(self, connector: Connector) -> CheckResult:
2727
passed=False,
2828
message="Icon file is not named 'icon.svg'",
2929
)
30+
# TODO check that the icon is a square
3031
return self.create_check_result(connector=connector, passed=True, message="Icon file exists")
3132

3233

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class DocumentationCheck(Check):
1515

1616
class CheckMigrationGuide(DocumentationCheck):
1717
name = "Breaking changes must be accompanied by a migration guide"
18-
description = "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`.\nThis 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."
18+
description = "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`.\nThis 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."
1919

2020
def _run(self, connector: Connector) -> CheckResult:
2121
breaking_changes = get(connector.metadata, "releases.breakingChanges")

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def _run(self, connector: Connector) -> CheckResult:
8686

8787
class CheckConnectorLicenseMatchInPyproject(PackagingCheck):
8888
name = f"Connector license in {consts.METADATA_FILE_NAME} and {consts.PYPROJECT_FILE_NAME} file must match"
89-
description = f"Connectors license in {consts.METADATA_FILE_NAME} and {consts.PYPROJECT_FILE_NAME} file must match. This is to ensure that all connectors are consistently licensed"
89+
description = f"Connectors license in {consts.METADATA_FILE_NAME} and {consts.PYPROJECT_FILE_NAME} file must match. This is to ensure that all connectors are consistently licensed."
9090
applies_to_connector_languages = [
9191
ConnectorLanguage.PYTHON,
9292
ConnectorLanguage.LOW_CODE,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ They are by no mean replacing the need for a manual review of the connector code
1313
*Applies to the following connector languages: {{ ', '.join(check.applies_to_connector_languages) }}*
1414

1515
{{ check.description }}
16-
{% endfor %}
1716
{%- endfor %}
17+
{% endfor %}

airbyte-ci/connectors/connectors_qa/tests/integration_tests/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
2+
3+
4+
from pathlib import Path
5+
6+
import git
7+
import pytest
8+
from asyncclick.testing import CliRunner
9+
from connectors_qa.cli import generate_documentation
10+
11+
DOCUMENTATION_FILE_PATH_IN_AIRBYTE_REPO = Path("docs/contributing-to-airbyte/resources/qa-checks.md")
12+
13+
@pytest.fixture
14+
def airbyte_repo():
15+
return git.Repo(search_parent_directories=True)
16+
17+
@pytest.mark.asyncio
18+
async def test_generated_qa_checks_documentation_is_up_to_date(airbyte_repo, tmp_path):
19+
# Arrange
20+
current_doc = (airbyte_repo.working_dir / DOCUMENTATION_FILE_PATH_IN_AIRBYTE_REPO).read_text()
21+
newly_generated_doc_path = tmp_path / "qa-checks.md"
22+
23+
# Act
24+
await CliRunner().invoke(generate_documentation, [str(tmp_path / "qa-checks.md")], catch_exceptions=False)
25+
26+
# Assert
27+
suggested_command = f"connectors-qa generate-documentation {DOCUMENTATION_FILE_PATH_IN_AIRBYTE_REPO}"
28+
assert newly_generated_doc_path.read_text() == current_doc, f"The generated documentation is not up to date. Please run `{suggested_command}` and commit the changes."

docs/contributing-to-airbyte/change-cdk-connector.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ Make sure you're working on an issue had been already triaged to not have your c
2121
3. Code the change
2222
4. Write a unit test for each custom function you added or changed
2323
5. Ensure all tests, including connector acceptance tests, pass
24-
6. Update the `metadata.yaml` and `Dockerfile` version following the [guidelines](./resources/pull-requests-handbook.md#semantic-versioning-for-connectors)
24+
6. Update the `metadata.yaml` following the [guidelines](./resources/pull-requests-handbook.md#semantic-versioning-for-connectors)
2525
7. Update the changelog entry in documentation in `docs/integrations/<connector-name>.md`
26+
8. Make sure your contribution passes our [QA checks](./resources/qa-checks.md)
2627

27-
A comment will automatically be added to your PR with a checklist containing the necessary steps to complete your contribution and get it merged.
2828

2929
:::info
3030
There is a README file inside each connector folder containing instructions to run that connector's tests locally.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Airbyte connectors QA checks
2+
3+
This document is listing all the static-analysis checks that are performed on the Airbyte connectors.
4+
These checks are running in our CI/CD pipeline and are used to ensure a connector is following the best practices and is respecting the Airbyte standards.
5+
Meeting these standards means that the connector will be able to be safely integrated into the Airbyte platform and released to registries (DockerHub, Pypi etc.).
6+
You can consider these checks as a set of guidelines to follow when developing a connector.
7+
They are by no mean replacing the need for a manual review of the connector codebase and the implementation of good test suites.
8+
9+
10+
## 📄 Documentation
11+
12+
### Breaking changes must be accompanied by a migration guide
13+
*Applies to the following connector languages: java, low-code, python*
14+
15+
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`.
16+
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.
17+
### Connectors must have user facing documentation
18+
*Applies to the following connector languages: java, low-code, python*
19+
20+
The user facing connector documentation should be stored under `./docs/integrations/<connector-type>s/<connector-name>.md`.
21+
### Connectors documentation follows our guidelines
22+
*Applies to the following connector languages: java, low-code, python*
23+
24+
The user facing connector documentation should follow the guidelines defined in the [documentation standards](https://hackmd.io/Bz75cgATSbm7DjrAqgl4rw).
25+
### Connectors must have a changelog entry for each version
26+
*Applies to the following connector languages: java, low-code, python*
27+
28+
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`.
29+
30+
## 📝 Metadata
31+
32+
### Connectors must have valid metadata.yaml file
33+
*Applies to the following connector languages: java, low-code, python*
34+
35+
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).
36+
37+
## 📦 Packaging
38+
39+
### Connectors must use Poetry for dependency management
40+
*Applies to the following connector languages: python, low-code*
41+
42+
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.
43+
### Connectors must be licensed under MIT or Elv2
44+
*Applies to the following connector languages: java, low-code, python*
45+
46+
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).
47+
### Connector license in metadata.yaml and pyproject.toml file must match
48+
*Applies to the following connector languages: python, low-code*
49+
50+
Connectors license in metadata.yaml and pyproject.toml file must match. This is to ensure that all connectors are consistently licensed.
51+
### Connector version must follow Semantic Versioning
52+
*Applies to the following connector languages: java, low-code, python*
53+
54+
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.
55+
### Connector version in metadata.yaml and pyproject.toml file must match
56+
*Applies to the following connector languages: python, low-code*
57+
58+
Connector version in metadata.yaml and pyproject.toml file must match. This is to ensure that connector release is consistent.
59+
### Python connectors must have PyPi publishing enabled
60+
*Applies to the following connector languages: python, low-code*
61+
62+
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`.
63+
64+
## 💼 Assets
65+
66+
### Connectors must have an icon
67+
*Applies to the following connector languages: java, low-code, python*
68+
69+
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.
70+
71+
## 🔒 Security
72+
73+
### Connectors must use HTTPS only
74+
*Applies to the following connector languages: java, low-code, python*
75+
76+
Connectors must use HTTPS only when making requests to external services.
77+
### Python connectors must not use a Dockerfile and must declare their base image in metadata.yaml file
78+
*Applies to the following connector languages: python, low-code*
79+
80+
Connectors must use our Python connector base image (`docker.io/airbyte/python-connector-base`), declared through the `connectorBuildOptions.baseImage` in their `metadata.yaml`.
81+
This is to ensure that all connectors use a base image which is maintained and has security updates.

docs/contributing-to-airbyte/submit-new-connector.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This will enable our team to make sure your contribution does not overlap with e
1919
3. Code the change
2020
4. Ensure all tests pass. For connectors, this includes acceptance tests as well.
2121
5. Update documentation in `docs/integrations/<connector-name>.md`
22+
6. Make sure your contribution passes our [QA checks](./resources/qa-checks.md)
2223

2324

2425
#### Open a pull request

docusaurus/sidebars.js

+1
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ const contributeToAirbyte = {
312312
"contributing-to-airbyte/resources/pull-requests-handbook",
313313
"contributing-to-airbyte/resources/code-style",
314314
"contributing-to-airbyte/resources/code-formatting",
315+
"contributing-to-airbyte/resources/qa-checks",
315316
"contributing-to-airbyte/resources/developing-locally",
316317
"contributing-to-airbyte/resources/developing-on-docker",
317318
],

0 commit comments

Comments
 (0)