@@ -84,10 +84,6 @@ def lead_duration(self) -> timedelta:
84
84
assert self .pipeline_context .stopped_at is not None , "The pipeline stopped_at timestamp must be set to save reports."
85
85
return self .pipeline_context .stopped_at - self .pipeline_context .created_at
86
86
87
- @property
88
- def remote_storage_enabled (self ) -> bool :
89
- return self .pipeline_context .is_ci
90
-
91
87
async def save (self ) -> None :
92
88
self .report_dir_path .mkdir (parents = True , exist_ok = True )
93
89
await self .save_json_report ()
@@ -103,14 +99,16 @@ async def save_json_report(self) -> None:
103
99
await json_report_artifact .save_to_local_path (json_report_path )
104
100
absolute_path = json_report_path .absolute ()
105
101
self .pipeline_context .logger .info (f"Report saved locally at { absolute_path } " )
106
- if self .remote_storage_enabled and self . pipeline_context .ci_report_bucket and self . pipeline_context . ci_gcs_credentials_secret :
102
+ if self .pipeline_context .remote_storage_enabled :
107
103
gcs_url = await json_report_artifact .upload_to_gcs (
108
104
dagger_client = self .pipeline_context .dagger_client ,
109
- bucket = self .pipeline_context .ci_report_bucket ,
105
+ bucket = self .pipeline_context .ci_report_bucket , # type: ignore
110
106
key = self .json_report_remote_storage_key ,
111
- gcs_credentials = self .pipeline_context .ci_gcs_credentials_secret ,
107
+ gcs_credentials = self .pipeline_context .ci_gcs_credentials_secret , # type: ignore
112
108
)
113
109
self .pipeline_context .logger .info (f"JSON Report uploaded to { gcs_url } " )
110
+ else :
111
+ self .pipeline_context .logger .info ("JSON Report not uploaded to GCS because remote storage is disabled." )
114
112
115
113
async def save_step_result_artifacts (self ) -> None :
116
114
local_artifacts_dir = self .report_dir_path / "artifacts"
@@ -121,19 +119,19 @@ async def save_step_result_artifacts(self) -> None:
121
119
step_artifacts_dir = local_artifacts_dir / slugify (step_result .step .title )
122
120
step_artifacts_dir .mkdir (parents = True , exist_ok = True )
123
121
await artifact .save_to_local_path (step_artifacts_dir / artifact .name )
124
- if (
125
- self .remote_storage_enabled
126
- and self .pipeline_context .ci_report_bucket
127
- and self .pipeline_context .ci_gcs_credentials_secret
128
- ):
122
+ if self .pipeline_context .remote_storage_enabled :
129
123
upload_time = int (time .time ())
130
124
gcs_url = await artifact .upload_to_gcs (
131
125
dagger_client = self .pipeline_context .dagger_client ,
132
- bucket = self .pipeline_context .ci_report_bucket ,
126
+ bucket = self .pipeline_context .ci_report_bucket , # type: ignore
133
127
key = f"{ self .report_output_prefix } /artifacts/{ slugify (step_result .step .title )} /{ upload_time } _{ artifact .name } " ,
134
- gcs_credentials = self .pipeline_context .ci_gcs_credentials_secret ,
128
+ gcs_credentials = self .pipeline_context .ci_gcs_credentials_secret , # type: ignore
135
129
)
136
130
self .pipeline_context .logger .info (f"Artifact { artifact .name } for { step_result .step .title } uploaded to { gcs_url } " )
131
+ else :
132
+ self .pipeline_context .logger .info (
133
+ f"Artifact { artifact .name } for { step_result .step .title } not uploaded to GCS because remote storage is disabled."
134
+ )
137
135
138
136
def to_json (self ) -> str :
139
137
"""Create a JSON representation of the report.
0 commit comments