From b7846caf7dc98f195604ab4e8d748626e3124736 Mon Sep 17 00:00:00 2001 From: alafanechere Date: Fri, 5 Jan 2024 18:53:01 +0100 Subject: [PATCH] airbyte-ci: fix assertion error on report existence --- airbyte-ci/connectors/pipelines/README.md | 1 + .../pipelines/airbyte_ci/connectors/publish/context.py | 1 + .../pipelines/pipelines/airbyte_ci/metadata/pipeline.py | 9 ++++++--- .../pipelines/models/contexts/pipeline_context.py | 3 +-- airbyte-ci/connectors/pipelines/pyproject.toml | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/airbyte-ci/connectors/pipelines/README.md b/airbyte-ci/connectors/pipelines/README.md index b5a49f30f64db..a6545035ce77e 100644 --- a/airbyte-ci/connectors/pipelines/README.md +++ b/airbyte-ci/connectors/pipelines/README.md @@ -521,6 +521,7 @@ E.G.: running `pytest` on a specific test folder: | Version | PR | Description | | ------- | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | +| 3.0.1 | [#33979](https://github.com/airbytehq/airbyte/pull/33979) | Fix AssertionError on report existence again | | 3.0.0 | [#33582](https://github.com/airbytehq/airbyte/pull/33582) | Upgrade to Dagger 0.9.5 | | 2.14.3 | [#33964](https://github.com/airbytehq/airbyte/pull/33964) | Reintroduce mypy with fixes for AssertionError on publish and missing report URL on connector test commit status. | | 2.14.2 | [#33954](https://github.com/airbytehq/airbyte/pull/33954) | Revert mypy changes | diff --git a/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/publish/context.py b/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/publish/context.py index 5bd5a29f91754..a4471bac7ecaf 100644 --- a/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/publish/context.py +++ b/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/publish/context.py @@ -120,6 +120,7 @@ def create_slack_message(self) -> str: message += "🔴" message += f" {self.state.value['description']}\n" if self.state is ContextState.SUCCESSFUL: + assert self.report is not None, "Report should be set when state is successful" message += f"⏲️ Run duration: {format_duration(self.report.run_duration)}\n" if self.state is ContextState.FAILURE: message += "\ncc. " # @dev-connector-ops diff --git a/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/metadata/pipeline.py b/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/metadata/pipeline.py index 60f3d222dd16c..8a50bdb280eca 100644 --- a/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/metadata/pipeline.py +++ b/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/metadata/pipeline.py @@ -162,6 +162,8 @@ async def run_metadata_orchestrator_deploy_pipeline( pipeline_start_timestamp: Optional[int], ci_context: Optional[str], ) -> bool: + success: bool = False + metadata_pipeline_context = PipelineContext( pipeline_name="Metadata Service Orchestrator Unit Test Pipeline", is_local=is_local, @@ -173,7 +175,6 @@ async def run_metadata_orchestrator_deploy_pipeline( pipeline_start_timestamp=pipeline_start_timestamp, ci_context=ci_context, ) - async with dagger.Connection(DAGGER_CONFIG) as dagger_client: metadata_pipeline_context.dagger_client = dagger_client.pipeline(metadata_pipeline_context.pipeline_name) @@ -190,9 +191,11 @@ async def run_metadata_orchestrator_deploy_pipeline( ), ] steps_results = await run_steps(steps) - metadata_pipeline_context.report = Report( + report = Report( pipeline_context=metadata_pipeline_context, steps_results=list(steps_results.values()), name="METADATA ORCHESTRATOR DEPLOY RESULTS", ) - return metadata_pipeline_context.report.success + metadata_pipeline_context.report = report + success = report.success + return success diff --git a/airbyte-ci/connectors/pipelines/pipelines/models/contexts/pipeline_context.py b/airbyte-ci/connectors/pipelines/pipelines/models/contexts/pipeline_context.py index 029196e9e7bda..fd86ca6b3760d 100644 --- a/airbyte-ci/connectors/pipelines/pipelines/models/contexts/pipeline_context.py +++ b/airbyte-ci/connectors/pipelines/pipelines/models/contexts/pipeline_context.py @@ -149,8 +149,7 @@ def repo(self) -> GitRepository: return self.dagger_client.git(AIRBYTE_REPO_URL, keep_git_dir=True) @property - def report(self) -> Report | ConnectorReport: - assert self._report is not None, "The report was not set on this PipelineContext." + def report(self) -> Report | ConnectorReport | None: return self._report @report.setter diff --git a/airbyte-ci/connectors/pipelines/pyproject.toml b/airbyte-ci/connectors/pipelines/pyproject.toml index 937991c589c9c..69ff22b71dca3 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.0.0" +version = "3.0.1" description = "Packaged maintained by the connector operations team to perform CI for connectors' pipelines" authors = ["Airbyte "]