Skip to content

Commit

Permalink
conectors-qa: verify connector breaking changes are at least 7 days a…
Browse files Browse the repository at this point in the history
…head (#35387)
  • Loading branch information
natikgadzhi committed Apr 8, 2024
1 parent b2e7f37 commit b753ade
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 11 deletions.
13 changes: 8 additions & 5 deletions airbyte-ci/connectors/connectors_qa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ following command from this directory:
pipx install .
```

This will make `connectors-qa` available in your `PATH`. Run `connectors-qa --help` to see the
available commands and options.
This will make `connectors-qa` available in your `PATH`.

Feel free to run `connectors-qa --help` to see the available commands and options.

### Examples

Expand Down Expand Up @@ -63,7 +64,7 @@ connectors-qa generate-documentation qa_checks.md
## Development

```bash
poetry install
poetry install --with dev
```

### Dependencies
Expand Down Expand Up @@ -104,9 +105,12 @@ poe type_check
```bash
poe lint
```

## Changelog

### 1.2.0

Added `ValidateBreakingChangesDeadlines` check that verifies the minimal compliance of breaking change rollout deadline.

### 1.1.0
Introduced the `Check.run_on_released_connectors` flag.

Expand All @@ -129,5 +133,4 @@ Fix access to connector types: it should be accessed from the `Connector.connect
- Make `CheckPublishToPyPiIsEnabled` run on source connectors only.

### 1.0.0

Initial release of `connectors-qa` package.
10 changes: 5 additions & 5 deletions airbyte-ci/connectors/connectors_qa/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "connectors-qa"
version = "1.1.0"
version = "1.2.0"
description = "A package to run QA checks on Airbyte connectors, generate reports and documentation."
authors = ["Airbyte <contact@airbyte.io>"]
readme = "README.md"
Expand All @@ -9,9 +9,9 @@ packages = [
]
[tool.poetry.dependencies]
python = "^3.10"
airbyte-connectors-base-images = {path = "../base_images", develop = false}
connector-ops = {path = "../connector_ops", develop = false}
metadata-service = {path = "../metadata_service/lib", develop = false}
airbyte-connectors-base-images = { path = "../base_images", develop = false }
connector-ops = { path = "../connector_ops", develop = false }
metadata-service = { path = "../metadata_service/lib", develop = false }
pydash = "^6.0.2"
jinja2 = "^3.1.3"
toml = "^0.10.2"
Expand Down Expand Up @@ -42,4 +42,4 @@ lint = "ruff check src"
[tool.airbyte_ci]
optional_poetry_groups = ["dev"]
poe_tasks = ["type_check", "lint", "test"]
required_environment_variables = ["DOCKER_HUB_USERNAME", "DOCKER_HUB_PASSWORD",]
required_environment_variables = ["DOCKER_HUB_USERNAME", "DOCKER_HUB_PASSWORD"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import os
from datetime import datetime, timedelta

import toml
from connector_ops.utils import Connector, ConnectorLanguage # type: ignore
Expand Down Expand Up @@ -149,8 +150,68 @@ def _run(self, connector: Connector) -> CheckResult:
)


class ValidateBreakingChangesDeadlines(MetadataCheck):
"""
Verify that _if_ the the most recent connector version has a breaking change,
it's deadline is at least a week in the future.
"""

name = "Breaking change deadline should be a week in the future"
description = "If the connector version has a breaking change, the deadline field must be set to at least a week in the future."
runs_on_released_connectors = False
minimum_days_until_deadline = 7

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

# fetch the current branch version of the connector first.
# we'll try and see if there are any breaking changes associated
# with it next.
current_version = connector.version
if current_version is None:
return self.fail(
connector=connector,
message="Can't verify breaking changes deadline: connector version is not defined.",
)

breaking_changes = connector.metadata.get("releases", {}).get("breakingChanges")

if not breaking_changes:
return self.pass_(
connector=connector,
message="No breaking changes found on this connector.",
)

current_version_breaking_changes = breaking_changes.get(current_version)

if not current_version_breaking_changes:
return self.pass_(
connector=connector,
message="No breaking changes found for the current version.",
)

upgrade_deadline = current_version_breaking_changes.get("upgradeDeadline")

if not upgrade_deadline:
return self.fail(
connector=connector,
message=f"No upgrade deadline found for the breaking changes in {current_version}.",
)

upgrade_deadline_datetime = datetime.strptime(upgrade_deadline, "%Y-%m-%d")
one_week_from_now = datetime.utcnow() + timedelta(days=self.minimum_days_until_deadline)

if upgrade_deadline_datetime <= one_week_from_now:
return self.fail(
connector=connector,
message=f"The upgrade deadline for the breaking changes in {current_version} is less than {self.minimum_days_until_deadline} days from today. Please extend the deadline",
)

return self.pass_(connector=connector, message="The upgrade deadline is set to at least a week in the future")


ENABLED_CHECKS = [
ValidateMetadata(),
CheckConnectorLanguageTag(),
CheckConnectorCDKTag(),
ValidateBreakingChangesDeadlines(),
]
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class TestCheck:
def test_fail_when_requires_metadata_and_metata_is_missing(self, mocker):
# Arrange
connector = mocker.MagicMock(metadata={})
connector = mocker.MagicMock(metadata={}, is_released=False)

# Act
results = []
Expand Down
5 changes: 5 additions & 0 deletions docs/contributing-to-airbyte/resources/qa-checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ Connectors must have a language tag in their metadata. It must be set in the `ta
*Applies to the following connector languages: python, low-code*

Python connectors must have a CDK tag in their metadata. It must be set in the `tags` field in metadata.yaml. The values can be `cdk:low-code`, `cdk:python`, or `cdk:file`.
### Breaking change deadline should be a week in the future
*Applies to the following connector types: source, destination*
*Applies to the following connector languages: java, low-code, python*

If the connector version has a breaking change, the deadline field must be set to at least a week in the future.

## 📦 Packaging

Expand Down

0 comments on commit b753ade

Please sign in to comment.