-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
connectors-ci: sanitize the publish logic and write tests for it #26068
Conversation
@@ -10,32 +10,20 @@ | |||
import uuid | |||
from typing import TYPE_CHECKING, List, Optional, Tuple | |||
|
|||
from ci_connector_ops.pipelines.consts import ( |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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." | ||
) |
There was a problem hiding this comment.
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
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): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
What
We need tests to double check that our publish logic is working as expected.
How
run_connector_publish_pipeline
to make it 💯 explicit (at the expense of parallelization)