Skip to content

Commit 038cc73

Browse files
change link file name
1 parent 2a47e7d commit 038cc73

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/test/steps/templates/test_report.html.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ function copyToClipBoard(htmlElement) {
171171
<h3>Artifacts</h3>
172172
<ul>
173173
{% for artifact in step_result_to_artifact_links[step_result.step.title] %}
174-
<li><a href="{{ artifact.url }}">{{ artifact.name }}</a></li>
174+
<li><a href="{{ artifact.url }}" download="{{ artifact.name }}">{{ artifact.name }}</a></li>
175175
{% endfor %}
176176
</ul>
177177
{% endif %}

airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/steps/gradle.py

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
33
#
44
from abc import ABC
5-
from typing import Any, ClassVar, List, Optional, Tuple
5+
from datetime import datetime
6+
from typing import Any, ClassVar, List, Optional, Tuple, cast
67

78
import pipelines.dagger.actions.system.docker
89
from dagger import CacheSharingMode, CacheVolume, Container, ExecError
@@ -220,20 +221,26 @@ async def _collect_test_logs(self, gradle_container: Container) -> Optional[Arti
220221
The docs in the container are expected to be in build/test-logs, and will end up test-artifact directory by default
221222
One can change the destination directory by setting the outputs
222223
"""
223-
test_logs_dir_name = "test-logs"
224-
if test_logs_dir_name not in await gradle_container.directory(f"{self.context.connector.code_directory}/build").entries():
225-
self.context.logger.warn(f"No {test_logs_dir_name} found directory in the build folder")
224+
test_logs_dir_name_in_container = "test-logs"
225+
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(
226+
"/", "_"
227+
)
228+
if (
229+
test_logs_dir_name_in_container
230+
not in await gradle_container.directory(f"{self.context.connector.code_directory}/build").entries()
231+
):
232+
self.context.logger.warn(f"No {test_logs_dir_name_in_container} found directory in the build folder")
226233
return None
227234
try:
228235
zip_file = await (
229236
dagger_directory_as_zip_file(
230237
self.dagger_client,
231-
await gradle_container.directory(f"{self.context.connector.code_directory}/build/{test_logs_dir_name}"),
232-
test_logs_dir_name,
238+
await gradle_container.directory(f"{self.context.connector.code_directory}/build/{test_logs_dir_name_in_container}"),
239+
test_logs_dir_name_in_zip,
233240
)
234241
)
235242
return Artifact(
236-
name="test-logs.zip",
243+
name=f"{test_logs_dir_name_in_zip}.zip",
237244
content=zip_file,
238245
content_type="application/zip",
239246
to_upload=True,
@@ -249,20 +256,26 @@ async def _collect_test_results(self, gradle_container: Container) -> Optional[A
249256
Only the XML files generated by junit are downloaded into the host filesystem
250257
One can change the destination directory by setting the outputs
251258
"""
252-
test_results_dir_name = "test-results"
253-
if test_results_dir_name not in await gradle_container.directory(f"{self.context.connector.code_directory}/build").entries():
254-
self.context.logger.warn(f"No {test_results_dir_name} found directory in the build folder")
259+
test_results_dir_name_in_container = "test-results"
260+
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(
261+
"/", "_"
262+
)
263+
if (
264+
test_results_dir_name_in_container
265+
not in await gradle_container.directory(f"{self.context.connector.code_directory}/build").entries()
266+
):
267+
self.context.logger.warn(f"No {test_results_dir_name_in_container} found directory in the build folder")
255268
return None
256269
try:
257270
zip_file = await (
258271
dagger_directory_as_zip_file(
259272
self.dagger_client,
260-
await gradle_container.directory(f"{self.context.connector.code_directory}/build/{test_results_dir_name}"),
261-
test_results_dir_name,
273+
await gradle_container.directory(f"{self.context.connector.code_directory}/build/{test_results_dir_name_in_container}"),
274+
test_results_dir_name_in_zip,
262275
)
263276
)
264277
return Artifact(
265-
name="test-results.zip",
278+
name=f"{test_results_dir_name_in_zip}.zip",
266279
content=zip_file,
267280
content_type="application/zip",
268281
to_upload=True,

airbyte-ci/connectors/pipelines/pipelines/models/artifacts.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ async def save_to_local_path(self, path: Path) -> Path:
2929
raise Exception(f"Failed to save artifact {self.name} to local path {path}")
3030

3131
async def upload_to_gcs(self, dagger_client: dagger.Client, bucket: str, key: str, gcs_credentials: dagger.Secret) -> str:
32-
gcs_cp_flags = None if self.content_type is None else [f"--content-type={self.content_type}"]
32+
gcs_cp_flags = [f"--content-disposition=attachment;filename='{self.name}'"]
33+
if self.content_type is not None:
34+
gcs_cp_flags = gcs_cp_flags + [f"--content-type={self.content_type}"]
3335

3436
report_upload_exit_code, _, _ = await remote_storage.upload_to_gcs(
3537
dagger_client=dagger_client,

0 commit comments

Comments
 (0)