-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
airbyte-ci: upload test artifacts along with reports
- Loading branch information
1 parent
81d706f
commit 823b5c4
Showing
8 changed files
with
223 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
airbyte-ci/connectors/pipelines/pipelines/models/artifacts.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
|
||
from dataclasses import dataclass | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
import dagger | ||
from pipelines.consts import GCS_PUBLIC_DOMAIN | ||
from pipelines.dagger.actions import remote_storage | ||
|
||
|
||
@dataclass(kw_only=True) | ||
class Artifact: | ||
"""A dataclass to represent an artifact produced by a pipeline execution.""" | ||
|
||
name: str | ||
content_type: str | ||
content: dagger.File | ||
to_upload: bool = True | ||
local_path: Optional[Path] = None | ||
gcs_url: Optional[str] = None | ||
|
||
async def save_to_local_path(self, path: Path) -> Path: | ||
exported = await self.content.export(str(path)) | ||
if exported: | ||
self.local_path = path | ||
return path | ||
else: | ||
raise Exception(f"Failed to save artifact {self.name} to local path {path}") | ||
|
||
async def upload_to_gcs(self, dagger_client: dagger.Client, bucket: str, key: str, gcs_credentials: dagger.Secret) -> str: | ||
gcs_cp_flags = None if self.content_type is None else [f"--content-type={self.content_type}"] | ||
|
||
report_upload_exit_code, _, _ = await remote_storage.upload_to_gcs( | ||
dagger_client=dagger_client, | ||
file_to_upload=self.content, | ||
key=key, | ||
bucket=bucket, | ||
gcs_credentials=gcs_credentials, | ||
flags=gcs_cp_flags, | ||
) | ||
if report_upload_exit_code != 0: | ||
raise Exception(f"Failed to upload artifact {self.name} to GCS. Exit code: {report_upload_exit_code}.") | ||
self.gcs_url = f"{GCS_PUBLIC_DOMAIN}/{bucket}/{key}" | ||
return f"{GCS_PUBLIC_DOMAIN}/{bucket}/{key}" |
Oops, something went wrong.