diff --git a/airbyte-ci/connectors/pipelines/README.md b/airbyte-ci/connectors/pipelines/README.md index eb438aab3009..e762b5705d24 100644 --- a/airbyte-ci/connectors/pipelines/README.md +++ b/airbyte-ci/connectors/pipelines/README.md @@ -547,6 +547,7 @@ E.G.: running `pytest` on a specific test folder: | Version | PR | Description | | ------- | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | +| 3.5.3 | [#34339](https://github.com/airbytehq/airbyte/pull/34339) | only do minimal changes on a connector version_bump | | 3.5.2 | [#34381](https://github.com/airbytehq/airbyte/pull/34381) | Bind a sidecar docker host for `airbyte-ci test` | | 3.5.1 | [#34321](https://github.com/airbytehq/airbyte/pull/34321) | Upgrade to Dagger 0.9.6 . | | 3.5.0 | [#33313](https://github.com/airbytehq/airbyte/pull/33313) | Pass extra params after Gradle tasks. | diff --git a/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/bump_version/pipeline.py b/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/bump_version/pipeline.py index cf330b5c5a9e..b6319dc0c917 100644 --- a/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/bump_version/pipeline.py +++ b/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/bump_version/pipeline.py @@ -2,13 +2,13 @@ # Copyright (c) 2023 Airbyte, Inc., all rights reserved. # import datetime -from copy import deepcopy from typing import TYPE_CHECKING import semver from dagger import Container, Directory from pipelines.airbyte_ci.connectors.context import ConnectorContext from pipelines.airbyte_ci.connectors.reports import ConnectorReport, Report +from pipelines.airbyte_ci.metadata.pipeline import MetadataValidation from pipelines.helpers import git from pipelines.helpers.connectors import metadata_change_helpers from pipelines.models.steps import Step, StepResult, StepStatus @@ -87,7 +87,7 @@ def add_changelog_entry(self, og_doc_content: str) -> str: line_index_for_new_entry = self.find_line_index_for_new_entry(og_doc_content) new_entry = f"| {self.new_version} | {today} | [{self.pull_request_number}](https://github.com/airbytehq/airbyte/pull/{self.pull_request_number}) | {self.changelog_entry} |" lines.insert(line_index_for_new_entry, new_entry) - return "\n".join(lines) + return "\n".join(lines) + "\n" class BumpDockerImageTagInMetadata(Step): @@ -105,17 +105,13 @@ def __init__( self.new_version = new_version @staticmethod - def get_metadata_with_bumped_version(previous_version: str, new_version: str, current_metadata: dict) -> dict: - updated_metadata = deepcopy(current_metadata) - updated_metadata["data"]["dockerImageTag"] = new_version - # Bump strict versions - if current_metadata["data"].get("registries", {}).get("cloud", {}).get("dockerImageTag") == previous_version: - updated_metadata["data"]["registries"]["cloud"]["dockerImageTag"] = new_version - return updated_metadata + def get_metadata_with_bumped_version(previous_version: str, new_version: str, metadata_str: str) -> str: + return metadata_str.replace("dockerImageTag: " + previous_version, "dockerImageTag: " + new_version) async def _run(self) -> StepResult: metadata_path = self.context.connector.metadata_file_path current_metadata = await metadata_change_helpers.get_current_metadata(self.repo_dir, metadata_path) + current_metadata_str = await metadata_change_helpers.get_current_metadata_str(self.repo_dir, metadata_path) current_version = metadata_change_helpers.get_current_version(current_metadata) if current_version is None: return StepResult( @@ -124,11 +120,16 @@ async def _run(self) -> StepResult: stdout="Can't retrieve the connector current version.", output_artifact=self.repo_dir, ) - updated_metadata = self.get_metadata_with_bumped_version(current_version, self.new_version, current_metadata) - repo_dir_with_updated_metadata = metadata_change_helpers.get_repo_dir_with_updated_metadata( - self.repo_dir, metadata_path, updated_metadata + updated_metadata_str = self.get_metadata_with_bumped_version(current_version, self.new_version, current_metadata_str) + repo_dir_with_updated_metadata = metadata_change_helpers.get_repo_dir_with_updated_metadata_str( + self.repo_dir, metadata_path, updated_metadata_str ) + metadata_validation_results = await MetadataValidation(self.context).run() + # Exit early if the metadata file is invalid. + if metadata_validation_results.status is not StepStatus.SUCCESS: + return metadata_validation_results + return StepResult( self, StepStatus.SUCCESS, diff --git a/airbyte-ci/connectors/pipelines/pipelines/helpers/connectors/metadata_change_helpers.py b/airbyte-ci/connectors/pipelines/pipelines/helpers/connectors/metadata_change_helpers.py index 6dd55b93bffb..7fe4d1be191d 100644 --- a/airbyte-ci/connectors/pipelines/pipelines/helpers/connectors/metadata_change_helpers.py +++ b/airbyte-ci/connectors/pipelines/pipelines/helpers/connectors/metadata_change_helpers.py @@ -14,9 +14,17 @@ async def get_current_metadata(repo_dir: Directory, metadata_path: Path) -> dict return yaml.safe_load(await repo_dir.file(str(metadata_path)).contents()) +async def get_current_metadata_str(repo_dir: Directory, metadata_path: Path) -> str: + return await repo_dir.file(str(metadata_path)).contents() + + def get_repo_dir_with_updated_metadata(repo_dir: Directory, metadata_path: Path, updated_metadata: dict) -> Directory: return repo_dir.with_new_file(str(metadata_path), contents=yaml.safe_dump(updated_metadata)) +def get_repo_dir_with_updated_metadata_str(repo_dir: Directory, metadata_path: Path, updated_metadata_str: str) -> Directory: + return repo_dir.with_new_file(str(metadata_path), contents=updated_metadata_str) + + def get_current_version(current_metadata: dict) -> str: return current_metadata.get("data", {}).get("dockerImageTag") diff --git a/airbyte-ci/connectors/pipelines/pyproject.toml b/airbyte-ci/connectors/pipelines/pyproject.toml index 984dbf7389c1..226fccfde693 100644 --- a/airbyte-ci/connectors/pipelines/pyproject.toml +++ b/airbyte-ci/connectors/pipelines/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "pipelines" -version = "3.5.2" +version = "3.5.3" description = "Packaged maintained by the connector operations team to perform CI for connectors' pipelines" authors = ["Airbyte "]