Skip to content

change aritfact link file name #35504

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function copyToClipBoard(htmlElement) {
<h3>Artifacts</h3>
<ul>
{% for artifact in step_result_to_artifact_links[step_result.step.title] %}
<li><a href="{{ artifact.url }}">{{ artifact.name }}</a></li>
<li><a href="{{ artifact.url }}" download>{{ artifact.name }}</a></li>
{% endfor %}
</ul>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
from abc import ABC
from typing import Any, ClassVar, List, Optional, Tuple
from datetime import datetime
from typing import Any, ClassVar, List, Optional, Tuple, cast

import pipelines.dagger.actions.system.docker
from dagger import CacheSharingMode, CacheVolume, Container, ExecError
Expand Down Expand Up @@ -220,20 +221,26 @@ async def _collect_test_logs(self, gradle_container: Container) -> Optional[Arti
The docs in the container are expected to be in build/test-logs, and will end up test-artifact directory by default
One can change the destination directory by setting the outputs
"""
test_logs_dir_name = "test-logs"
if test_logs_dir_name not in await gradle_container.directory(f"{self.context.connector.code_directory}/build").entries():
self.context.logger.warn(f"No {test_logs_dir_name} found directory in the build folder")
test_logs_dir_name_in_container = "test-logs"
test_logs_dir_name_in_zip = f"test-logs-{datetime.fromtimestamp(cast(float, self.context.pipeline_start_timestamp)).isoformat()}-{self.context.git_branch}-{self.gradle_task_name}".replace(
"/", "_"
)
if (
test_logs_dir_name_in_container
not in await gradle_container.directory(f"{self.context.connector.code_directory}/build").entries()
):
self.context.logger.warn(f"No {test_logs_dir_name_in_container} found directory in the build folder")
return None
try:
zip_file = await (
dagger_directory_as_zip_file(
self.dagger_client,
await gradle_container.directory(f"{self.context.connector.code_directory}/build/{test_logs_dir_name}"),
test_logs_dir_name,
await gradle_container.directory(f"{self.context.connector.code_directory}/build/{test_logs_dir_name_in_container}"),
test_logs_dir_name_in_zip,
)
)
return Artifact(
name="test-logs.zip",
name=f"{test_logs_dir_name_in_zip}.zip",
content=zip_file,
content_type="application/zip",
to_upload=True,
Expand All @@ -249,20 +256,26 @@ async def _collect_test_results(self, gradle_container: Container) -> Optional[A
Only the XML files generated by junit are downloaded into the host filesystem
One can change the destination directory by setting the outputs
"""
test_results_dir_name = "test-results"
if test_results_dir_name not in await gradle_container.directory(f"{self.context.connector.code_directory}/build").entries():
self.context.logger.warn(f"No {test_results_dir_name} found directory in the build folder")
test_results_dir_name_in_container = "test-results"
test_results_dir_name_in_zip = f"test-results-{datetime.fromtimestamp(cast(float, self.context.pipeline_start_timestamp)).isoformat()}-{self.context.git_branch}-{self.gradle_task_name}".replace(
"/", "_"
)
if (
test_results_dir_name_in_container
not in await gradle_container.directory(f"{self.context.connector.code_directory}/build").entries()
):
self.context.logger.warn(f"No {test_results_dir_name_in_container} found directory in the build folder")
return None
try:
zip_file = await (
dagger_directory_as_zip_file(
self.dagger_client,
await gradle_container.directory(f"{self.context.connector.code_directory}/build/{test_results_dir_name}"),
test_results_dir_name,
await gradle_container.directory(f"{self.context.connector.code_directory}/build/{test_results_dir_name_in_container}"),
test_results_dir_name_in_zip,
)
)
return Artifact(
name="test-results.zip",
name=f"{test_results_dir_name_in_zip}.zip",
content=zip_file,
content_type="application/zip",
to_upload=True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ async def save_to_local_path(self, path: Path) -> Path:
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}"]
gcs_cp_flags = [f"--content-disposition=filename=\"{self.name}\""]
if self.content_type is not None:
gcs_cp_flags = gcs_cp_flags + [f"--content-type={self.content_type}"]

report_upload_exit_code, _, _ = await remote_storage.upload_to_gcs(
dagger_client=dagger_client,
Expand Down