Skip to content

Commit b753ade

Browse files
authored
conectors-qa: verify connector breaking changes are at least 7 days ahead (#35387)
1 parent b2e7f37 commit b753ade

File tree

5 files changed

+80
-11
lines changed

5 files changed

+80
-11
lines changed

airbyte-ci/connectors/connectors_qa/README.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ following command from this directory:
1616
pipx install .
1717
```
1818

19-
This will make `connectors-qa` available in your `PATH`. Run `connectors-qa --help` to see the
20-
available commands and options.
19+
This will make `connectors-qa` available in your `PATH`.
20+
21+
Feel free to run `connectors-qa --help` to see the available commands and options.
2122

2223
### Examples
2324

@@ -63,7 +64,7 @@ connectors-qa generate-documentation qa_checks.md
6364
## Development
6465

6566
```bash
66-
poetry install
67+
poetry install --with dev
6768
```
6869

6970
### Dependencies
@@ -104,9 +105,12 @@ poe type_check
104105
```bash
105106
poe lint
106107
```
107-
108108
## Changelog
109109

110+
### 1.2.0
111+
112+
Added `ValidateBreakingChangesDeadlines` check that verifies the minimal compliance of breaking change rollout deadline.
113+
110114
### 1.1.0
111115
Introduced the `Check.run_on_released_connectors` flag.
112116

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

131135
### 1.0.0
132-
133136
Initial release of `connectors-qa` package.

airbyte-ci/connectors/connectors_qa/pyproject.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "connectors-qa"
3-
version = "1.1.0"
3+
version = "1.2.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"
@@ -9,9 +9,9 @@ packages = [
99
]
1010
[tool.poetry.dependencies]
1111
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}
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 }
1515
pydash = "^6.0.2"
1616
jinja2 = "^3.1.3"
1717
toml = "^0.10.2"
@@ -42,4 +42,4 @@ lint = "ruff check src"
4242
[tool.airbyte_ci]
4343
optional_poetry_groups = ["dev"]
4444
poe_tasks = ["type_check", "lint", "test"]
45-
required_environment_variables = ["DOCKER_HUB_USERNAME", "DOCKER_HUB_PASSWORD",]
45+
required_environment_variables = ["DOCKER_HUB_USERNAME", "DOCKER_HUB_PASSWORD"]

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

+61
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
import os
5+
from datetime import datetime, timedelta
56

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

151152

153+
class ValidateBreakingChangesDeadlines(MetadataCheck):
154+
"""
155+
Verify that _if_ the the most recent connector version has a breaking change,
156+
it's deadline is at least a week in the future.
157+
"""
158+
159+
name = "Breaking change deadline should be a week in the future"
160+
description = "If the connector version has a breaking change, the deadline field must be set to at least a week in the future."
161+
runs_on_released_connectors = False
162+
minimum_days_until_deadline = 7
163+
164+
def _run(self, connector: Connector) -> CheckResult:
165+
166+
# fetch the current branch version of the connector first.
167+
# we'll try and see if there are any breaking changes associated
168+
# with it next.
169+
current_version = connector.version
170+
if current_version is None:
171+
return self.fail(
172+
connector=connector,
173+
message="Can't verify breaking changes deadline: connector version is not defined.",
174+
)
175+
176+
breaking_changes = connector.metadata.get("releases", {}).get("breakingChanges")
177+
178+
if not breaking_changes:
179+
return self.pass_(
180+
connector=connector,
181+
message="No breaking changes found on this connector.",
182+
)
183+
184+
current_version_breaking_changes = breaking_changes.get(current_version)
185+
186+
if not current_version_breaking_changes:
187+
return self.pass_(
188+
connector=connector,
189+
message="No breaking changes found for the current version.",
190+
)
191+
192+
upgrade_deadline = current_version_breaking_changes.get("upgradeDeadline")
193+
194+
if not upgrade_deadline:
195+
return self.fail(
196+
connector=connector,
197+
message=f"No upgrade deadline found for the breaking changes in {current_version}.",
198+
)
199+
200+
upgrade_deadline_datetime = datetime.strptime(upgrade_deadline, "%Y-%m-%d")
201+
one_week_from_now = datetime.utcnow() + timedelta(days=self.minimum_days_until_deadline)
202+
203+
if upgrade_deadline_datetime <= one_week_from_now:
204+
return self.fail(
205+
connector=connector,
206+
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",
207+
)
208+
209+
return self.pass_(connector=connector, message="The upgrade deadline is set to at least a week in the future")
210+
211+
152212
ENABLED_CHECKS = [
153213
ValidateMetadata(),
154214
CheckConnectorLanguageTag(),
155215
CheckConnectorCDKTag(),
216+
ValidateBreakingChangesDeadlines(),
156217
]

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class TestCheck:
1010
def test_fail_when_requires_metadata_and_metata_is_missing(self, mocker):
1111
# Arrange
12-
connector = mocker.MagicMock(metadata={})
12+
connector = mocker.MagicMock(metadata={}, is_released=False)
1313

1414
# Act
1515
results = []

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

+5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ Connectors must have a language tag in their metadata. It must be set in the `ta
4343
*Applies to the following connector languages: python, low-code*
4444

4545
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`.
46+
### Breaking change deadline should be a week in the future
47+
*Applies to the following connector types: source, destination*
48+
*Applies to the following connector languages: java, low-code, python*
49+
50+
If the connector version has a breaking change, the deadline field must be set to at least a week in the future.
4651

4752
## 📦 Packaging
4853

0 commit comments

Comments
 (0)