Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[airbyte-ci]: new check on python certified connector to validate their base image use #30527

Conversation

alafanechere
Copy link
Contributor

@alafanechere alafanechere commented Sep 18, 2023

What

Closes #30239

We want to make sure a certified python connectors does not pass the test if:

  • it has a Dockerfile
  • it is not defining a connectorBuildOptions.baseImage in its metadata.yaml

How

  • Add a new step to the python connectors test pipeline: CheckBaseImageIsUsed
  • Run it at the end of the pipeline

@alafanechere alafanechere force-pushed the augustin/09-18-_airbyte-ci_new_check_on_python_certified_connector_to_validate_their_base_image_use branch 2 times, most recently from beef79d to d7c6437 Compare September 18, 2023 15:36
@alafanechere alafanechere marked this pull request as ready for review September 18, 2023 15:53
@alafanechere alafanechere force-pushed the augustin/09-17/airbyte-ci-new-commands-for-migration branch from a1b0d77 to 2d3ee2e Compare September 18, 2023 16:02
@alafanechere alafanechere force-pushed the augustin/09-18-_airbyte-ci_new_check_on_python_certified_connector_to_validate_their_base_image_use branch from 2c2de0c to 26837a3 Compare September 18, 2023 16:02
@alafanechere alafanechere requested a review from a team September 18, 2023 16:13
@@ -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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍 a simple work of art! Loved reading this.

@alafanechere alafanechere force-pushed the augustin/09-17/airbyte-ci-new-commands-for-migration branch from 2d3ee2e to f6e7ab5 Compare September 19, 2023 15:28
@alafanechere alafanechere force-pushed the augustin/09-18-_airbyte-ci_new_check_on_python_certified_connector_to_validate_their_base_image_use branch from 26837a3 to 11a3b4a Compare September 19, 2023 15:28
@alafanechere alafanechere force-pushed the augustin/09-17/airbyte-ci-new-commands-for-migration branch from f6e7ab5 to 4b23511 Compare September 19, 2023 16:29
@vercel
Copy link

vercel bot commented Sep 20, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
airbyte-docs ⬜️ Ignored (Inspect) Visit Preview Oct 20, 2023 9:56am

@alafanechere alafanechere force-pushed the augustin/09-18-_airbyte-ci_new_check_on_python_certified_connector_to_validate_their_base_image_use branch from 11a3b4a to 168f10d Compare September 20, 2023 11:11
@alafanechere alafanechere force-pushed the augustin/09-17/airbyte-ci-new-commands-for-migration branch from 8258a4e to 175e2d0 Compare September 20, 2023 11:21
@alafanechere alafanechere force-pushed the augustin/09-18-_airbyte-ci_new_check_on_python_certified_connector_to_validate_their_base_image_use branch from 168f10d to c013a0a Compare September 20, 2023 11:21
@alafanechere alafanechere changed the base branch from augustin/09-17/airbyte-ci-new-commands-for-migration to augustin/09-18-_airbyte-ci_Implement_pre/post_build_hooks September 20, 2023 11:51
@alafanechere alafanechere force-pushed the augustin/09-18-_airbyte-ci_Implement_pre/post_build_hooks branch from 92be7ae to 276f1b0 Compare September 21, 2023 11:03
@alafanechere alafanechere force-pushed the augustin/09-18-_airbyte-ci_new_check_on_python_certified_connector_to_validate_their_base_image_use branch from 8fe96a6 to de9a417 Compare September 21, 2023 11:03
@alafanechere alafanechere force-pushed the augustin/09-18-_airbyte-ci_Implement_pre/post_build_hooks branch from 276f1b0 to 404346d Compare September 21, 2023 11:05
@alafanechere alafanechere force-pushed the augustin/09-18-_airbyte-ci_new_check_on_python_certified_connector_to_validate_their_base_image_use branch from de9a417 to 29ded3d Compare September 21, 2023 11:05
Comment on lines 291 to 294
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.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alafanechere I think I'm missing something here - does this actually give us whether the connector is certified? As far as I can tell this will give us certified, community or None (since it's optional).

If the supportLevel is set to community, then is_certified = 'community' if not is_certified = False and we run the check on community connectors 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahah nice catch, thank you

Comment on lines 296 to 310
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 (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.",
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we'll first tell people to set the baseImage. Then if they run again with both, we tell them to remove the dockerfile and set the base image. They shouldn't be able to reach this second conditional if the base image is already set, so we can remove and set connectorBuildOptions.baseImage in the connector metadata from the stdout

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a suggestion in the error message to run the migration command. It will make sure that metadata is using the base image and that the dockerfile is removed.

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 (await self.context.get_connector_dir(include="Dockerfile")).entries()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we reuse the property from this PR here?

Copy link
Contributor Author

@alafanechere alafanechere Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could but it's. a bit less reliable.
When we call the has_dockerfile property on the Connector object it examines the current filesystem to check for the existence of a dockerfile.
When we check with get_connector_dir we check within a Directory object that is build by the context. The get_connector_dir implementation can change in the future to fetch the connector code from elsewhere (another container or a remote git branch returned by Dagger as a Directory).
This is why we have an explicit check here.
But unfortunately this rule is not consistently used in the rest of the codebase, has accessing the Connector attribute is far more simple.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible/worth it to to make the attribute call get_connector_dir as well?

@alafanechere alafanechere force-pushed the augustin/09-18-_airbyte-ci_Implement_pre/post_build_hooks branch 4 times, most recently from a728afd to fcecb62 Compare October 11, 2023 13:32
Base automatically changed from augustin/09-18-_airbyte-ci_Implement_pre/post_build_hooks to master October 11, 2023 13:53
@alafanechere alafanechere force-pushed the augustin/09-18-_airbyte-ci_new_check_on_python_certified_connector_to_validate_their_base_image_use branch from 29ded3d to b30969f Compare October 14, 2023 13:25
@github-actions
Copy link
Contributor

Coverage report for source-postgres

File Coverage [90.14%] 🍏
InitialSyncCtidIterator.java 90.14% 🍏
Total Project Coverage 71.71% 🍏

@alafanechere alafanechere force-pushed the augustin/09-18-_airbyte-ci_new_check_on_python_certified_connector_to_validate_their_base_image_use branch from fc12ce3 to d88e299 Compare October 14, 2023 13:49
@airbyte-oss-build-runner
Copy link
Collaborator

source-google-sheets test report (commit d88e2997ea) - ❌

⏲️ Total pipeline duration: 03mn25s

Step Result
Build source-google-sheets docker image for platform(s) linux/x86_64
Unit tests
Acceptance tests
Check our base image is used
Code format checks
Validate metadata for source-google-sheets
Connector version semver check
QA checks

🔗 View the logs here

☁️ View runs for commit in Dagger Cloud

Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command

airbyte-ci connectors --name=source-google-sheets test

@airbyte-oss-build-runner
Copy link
Collaborator

source-file test report (commit d88e2997ea) - ✅

⏲️ Total pipeline duration: 05mn15s

Step Result
Build source-file docker image for platform(s) linux/x86_64
Unit tests
Integration tests
Acceptance tests
Check our base image is used
Code format checks
Validate metadata for source-file
Connector version semver check
QA checks

🔗 View the logs here

☁️ View runs for commit in Dagger Cloud

Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command

airbyte-ci connectors --name=source-file test

@alafanechere alafanechere force-pushed the augustin/09-18-_airbyte-ci_new_check_on_python_certified_connector_to_validate_their_base_image_use branch from d88e299 to be10db7 Compare October 14, 2023 13:57
@alafanechere
Copy link
Contributor Author

alafanechere commented Oct 14, 2023

☝️ These test results confirm the correct behavior of the new check.

@alafanechere alafanechere force-pushed the augustin/09-18-_airbyte-ci_new_check_on_python_certified_connector_to_validate_their_base_image_use branch 2 times, most recently from 8c05020 to 817e796 Compare October 16, 2023 16:55
@alafanechere alafanechere force-pushed the augustin/09-18-_airbyte-ci_new_check_on_python_certified_connector_to_validate_their_base_image_use branch from 817e796 to 787ec57 Compare October 20, 2023 09:41
@alafanechere alafanechere merged commit e77959c into master Oct 20, 2023
14 checks passed
@alafanechere alafanechere deleted the augustin/09-18-_airbyte-ci_new_check_on_python_certified_connector_to_validate_their_base_image_use branch October 20, 2023 10:14
ariesgun pushed a commit to ariesgun/airbyte that referenced this pull request Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make Python certified connector tests fail if it has a Dockerfile and a build.gradle file
4 participants