feat(airbyte-ci): re-publish connector image if --pre-release (#55262)
This commit is contained in:
@@ -513,16 +513,20 @@ async def run_connector_publish_pipeline(context: PublishConnectorContext, semap
|
||||
if metadata_validation_results.status is not StepStatus.SUCCESS:
|
||||
return create_connector_report(results, context)
|
||||
|
||||
# Check if the connector image is already published to the registry.
|
||||
check_connector_image_results = await CheckConnectorImageDoesNotExist(context).run()
|
||||
results.append(check_connector_image_results)
|
||||
|
||||
python_registry_steps, terminate_early = await _run_python_registry_publish_pipeline(context)
|
||||
results.extend(python_registry_steps)
|
||||
|
||||
if terminate_early:
|
||||
return create_connector_report(results, context)
|
||||
|
||||
# If the connector image already exists, we don't need to build it, but we still need to upload the metadata file.
|
||||
# We also need to upload the spec to the spec cache bucket.
|
||||
if check_connector_image_results.status is StepStatus.SKIPPED:
|
||||
# For pre-releases, rebuild all the time.
|
||||
if check_connector_image_results.status is StepStatus.SKIPPED and not context.pre_release:
|
||||
context.logger.info(
|
||||
"The connector version is already published. Let's upload metadata.yaml and spec to GCS even if no version bump happened."
|
||||
)
|
||||
@@ -540,8 +544,8 @@ async def run_connector_publish_pipeline(context: PublishConnectorContext, semap
|
||||
metadata_upload_results = await metadata_upload_step.run()
|
||||
results.append(metadata_upload_results)
|
||||
|
||||
# Exit early if the connector image already exists or has failed to build
|
||||
if check_connector_image_results.status is not StepStatus.SUCCESS:
|
||||
# Exit early if the connector image already exists
|
||||
if check_connector_image_results.status is not StepStatus.SUCCESS and not context.pre_release:
|
||||
return create_connector_report(results, context)
|
||||
|
||||
build_connector_results = await steps.run_connector_build(context)
|
||||
|
||||
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.poetry]
|
||||
name = "pipelines"
|
||||
version = "5.2.2"
|
||||
version = "5.2.3"
|
||||
description = "Packaged maintained by the connector operations team to perform CI for connectors' pipelines"
|
||||
authors = ["Airbyte <contact@airbyte.io>"]
|
||||
|
||||
|
||||
@@ -205,16 +205,22 @@ async def test_run_connector_publish_pipeline_when_failed_validation(mocker, pre
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"check_image_exists_status",
|
||||
[StepStatus.SKIPPED, StepStatus.FAILURE],
|
||||
"check_image_exists_status, pre_release",
|
||||
[
|
||||
(StepStatus.SKIPPED, False),
|
||||
(StepStatus.SKIPPED, True),
|
||||
(StepStatus.FAILURE, False),
|
||||
],
|
||||
)
|
||||
async def test_run_connector_publish_pipeline_when_image_exists_or_failed(mocker, check_image_exists_status, publish_context):
|
||||
async def test_run_connector_publish_pipeline_when_image_exists_or_failed(mocker, check_image_exists_status, pre_release, publish_context):
|
||||
"""We validate that when the connector image exists or the check fails, we don't run the rest of the pipeline.
|
||||
We also validate that the metadata upload step is called when the image exists (Skipped status).
|
||||
We do this to ensure that the metadata is still updated in the case where the connector image already exists.
|
||||
It's the role of the metadata service upload command to actually upload the file if the metadata has changed.
|
||||
But we check that the metadata upload step does not happen if the image check fails (Failure status).
|
||||
"""
|
||||
publish_context.pre_release = pre_release
|
||||
|
||||
for module, to_mock in STEPS_TO_PATCH:
|
||||
mocker.patch.object(module, to_mock, return_value=mocker.AsyncMock())
|
||||
|
||||
@@ -242,7 +248,7 @@ async def test_run_connector_publish_pipeline_when_image_exists_or_failed(mocker
|
||||
if to_mock not in ["MetadataValidation", "MetadataUpload", "CheckConnectorImageDoesNotExist", "UploadSpecToCache", "UploadSbom"]:
|
||||
getattr(module, to_mock).return_value.run.assert_not_called()
|
||||
|
||||
if check_image_exists_status is StepStatus.SKIPPED:
|
||||
if check_image_exists_status is StepStatus.SKIPPED and not pre_release:
|
||||
run_metadata_upload.assert_called_once()
|
||||
assert (
|
||||
report.steps_results
|
||||
@@ -256,6 +262,9 @@ async def test_run_connector_publish_pipeline_when_image_exists_or_failed(mocker
|
||||
]
|
||||
)
|
||||
|
||||
if check_image_exists_status is StepStatus.SKIPPED and pre_release:
|
||||
run_metadata_upload.assert_not_called()
|
||||
|
||||
if check_image_exists_status is StepStatus.FAILURE:
|
||||
run_metadata_upload.assert_not_called()
|
||||
assert (
|
||||
|
||||
Reference in New Issue
Block a user