Skip to content

Commit

Permalink
[airbyte-ci]: new check on python certified connector to validate the…
Browse files Browse the repository at this point in the history
…ir base image use
  • Loading branch information
alafanechere committed Sep 18, 2023
1 parent 2d3ee2e commit 82eb7d1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
25 changes: 25 additions & 0 deletions airbyte-ci/connectors/pipelines/pipelines/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,28 @@ async def _build_connector_acceptance_test(self, connector_under_test_image_tar:
)

return cat_container.with_unix_socket("/var/run/docker.sock", self.context.dagger_client.host().unix_socket("/var/run/docker.sock"))


class CheckBaseImageIsUsed(Step):
title = "Check our base image is used"

async def _run(self, *args, **kwargs) -> StepResult:
is_certified = self.context.connector.metadata.get("supportLevel")
if not is_certified:
self.skip("Connector is not certified, it does not require the use of our base image.")

is_using_base_image = self.context.connector.metadata.get("connectorBuildOptions", {}).get("baseImage")
if not is_using_base_image:
return StepResult(
self,
StepStatus.FAILURE,
stdout="Connector is certified but does not use our base image. Please set connectorBuildOptions.baseImage in the connector metadata.",
)
has_dockerfile = "Dockerfile" in await self.context.get_connector_dir(include="Dockerfile").entries()
if has_dockerfile:
return StepResult(
self,
StepStatus.FAILURE,
stdout="Connector is certified but is still using a Dockerfile. Please remove the Dockerfile and set connectorBuildOptions.baseImage in the connector metadata.",
)
return StepResult(self, StepStatus.SUCCESS, stdout="Connector is certified and uses our base image.")
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pipelines.builds import LOCAL_BUILD_PLATFORM
from pipelines.builds.python_connectors import BuildConnectorImage
from pipelines.contexts import ConnectorContext
from pipelines.tests.common import AcceptanceTests
from pipelines.tests.common import AcceptanceTests, CheckBaseImageIsUsed
from pipelines.utils import export_container_to_tarball


Expand Down Expand Up @@ -195,6 +195,7 @@ async def run_all_tests(context: ConnectorContext) -> List[StepResult]:
tasks = [
task_group.soonify(IntegrationTests(context).run)(connector_container),
task_group.soonify(AcceptanceTests(context).run)(connector_image_tar_file),
task_group.soonify(CheckBaseImageIsUsed(context).run)(),
]

return step_results + [task.value for task in tasks]
Expand Down

0 comments on commit 82eb7d1

Please sign in to comment.