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

connectors-ci: sanitize the publish logic and write tests for it #26068

Merged
merged 7 commits into from
May 15, 2023

Conversation

alafanechere
Copy link
Contributor

@alafanechere alafanechere commented May 15, 2023

What

We need tests to double check that our publish logic is working as expected.

How

  • Rewrite run_connector_publish_pipeline to make it 💯 explicit (at the expense of parallelization)
  • Fix the schema of the written spec to the cache bucket
  • Run spec schema validation on specs that will be written to the cache bucket
  • Write tests on the publish logic to make sure:
    • The spec file we upload to the spec cache matches the spec format available in the registry
    • No docker push / spec upload happens if the connector image already exists
  • ref: move some code around to avoid circular dependency problems

@alafanechere alafanechere requested review from bnchrch and a team May 15, 2023 14:31
@@ -10,32 +10,20 @@
import uuid
from typing import TYPE_CHECKING, List, Optional, Tuple

from ci_connector_ops.pipelines.consts import (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to avoid circular deps problems

from ci_connector_ops.pipelines.utils import check_path_in_workdir, slugify, with_exit_code, with_stderr, with_stdout
from ci_connector_ops.utils import Connector, console
from dagger import CacheVolume, Container, Directory, QueryError
from ci_connector_ops.pipelines.consts import PYPROJECT_TOML_FILE_PATH
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to avoid circular deps problems

@@ -365,130 +363,3 @@ def print(self):

main_panel = Panel(Group(*to_render), title=main_panel_title, subtitle=duration_subtitle)
console.print(main_panel)


class GradleTask(Step, ABC):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving this to a dedicated module just to avoid circular deps problems

Copy link
Contributor

@bnchrch bnchrch left a comment

Choose a reason for hiding this comment

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

Looks Fantastic! Thanks for these tests 👏

Comment on lines +175 to 181
check_connector_image_results = await CheckConnectorImageDoesNotExist(context).run()
results.append(check_connector_image_results)
if check_connector_image_results.status is not StepStatus.SUCCESS:
if check_connector_image_results.status is StepStatus.SKIPPED:
context.logger.info(
"The connector version is already published. Let's upload metadata.yaml to GCS even if no version bump happened."
)
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 could remove one layer of nesting if we breakout the on skip logic

Suggested change
check_connector_image_results = await CheckConnectorImageDoesNotExist(context).run()
results.append(check_connector_image_results)
if check_connector_image_results.status is not StepStatus.SUCCESS:
if check_connector_image_results.status is StepStatus.SKIPPED:
context.logger.info(
"The connector version is already published. Let's upload metadata.yaml to GCS even if no version bump happened."
)
check_connector_image_results = await CheckConnectorImageDoesNotExist(context).run()
results.append(check_connector_image_results)
# Run metadata upload if skipped
if check_connector_image_results.status is StepStatus.SKIPPED:
context.logger.info(
"The connector version is already published. Let's upload metadata.yaml to GCS even if no version bump happened."
)
metadata_upload_results = await metadata.MetadataUpload(context).run()
results.append(metadata_upload_results)
# Exit if not success
if check_connector_image_results.status is not StepStatus.SUCCESS:
return create_connector_report(results)

[False, False],
],
)
async def test_run(self, mocker, dagger_client, valid_spec, successful_upload, random_connector, context):
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a really well written test

def test_parse_spec_output_no_spec(self, context):
step = publish.UploadSpecToCache(context)
spec_output = '{"type": "OTHER"}'
with pytest.raises(publish.InvalidSpecOutputError):
Copy link
Contributor

Choose a reason for hiding this comment

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

👏

@alafanechere alafanechere merged commit be6dbae into master May 15, 2023
24 checks passed
@alafanechere alafanechere deleted the augustin/connectors-ci/integration-test-publish branch May 15, 2023 17:52
marcosmarxm pushed a commit to natalia-miinto/airbyte that referenced this pull request Jun 8, 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.

None yet

2 participants