@@ -167,17 +167,6 @@ class SDKArtifactFormat:
167
167
raise NotImplementedError ()
168
168
169
169
170
- class SDKArtifactFormatV2 (SDKArtifactFormat ):
171
- def __init__ (self , platform_suffix : str ):
172
- self .platform_suffix = platform_suffix
173
-
174
- def swift_sdk_artifact_id (self , tag_name : str ):
175
- return tag_name .removeprefix ("swift-wasm-" ) + "-wasm"
176
-
177
- def swift_sdk_artifact_filename (self , tag_name : str ):
178
- return f"{ tag_name } -{ self .platform_suffix } .artifactbundle"
179
-
180
-
181
170
class SDKArtifactFormatV3 (SDKArtifactFormat ):
182
171
def __init__ (self , target_triple : str ):
183
172
self .target_triple = target_triple
@@ -210,11 +199,15 @@ class Distribution:
210
199
for artifact in self .toolchain_artifacts (options ):
211
200
if not artifact ["name" ].endswith ("-artifactbundle" ):
212
201
print (f"Skipping { artifact ['name' ]} because it's not an"
213
- " artifactbundle for --only-swift-sdk " )
202
+ " artifactbundle" )
214
203
continue
215
204
216
- _ , scheme , _ = derive_platform_suffix_and_scheme (
217
- artifact ["name" ], options .scheme )
205
+ try :
206
+ scheme , _ = derive_platform_suffix_and_scheme (
207
+ artifact ["name" ], options .scheme )
208
+ except Exception :
209
+ print (f"Skipping { artifact ['name' ]} because it's not a valid artifactbundle for { options .scheme } " )
210
+ continue
218
211
219
212
if options .scheme != scheme :
220
213
print (f"Skipping { artifact ['name' ]} because it's not scheme { options .scheme } " )
@@ -251,7 +244,7 @@ class Distribution:
251
244
for artifact , artifact_path in downloaded_paths :
252
245
if not artifact ["name" ].endswith ("-artifactbundle" ):
253
246
continue
254
- platform_suffix , _ , target_triple = derive_platform_suffix_and_scheme (
247
+ _ , target_triple = derive_platform_suffix_and_scheme (
255
248
artifact ["name" ], options .scheme )
256
249
bundle_path = await self .unpack_artifactbundle (artifact_path )
257
250
dirents = os .listdir (bundle_path )
@@ -278,7 +271,7 @@ class Distribution:
278
271
279
272
async def package_sdk_work (downloaded ):
280
273
artifact , artifact_path = downloaded
281
- platform_suffix , scheme , target_triple = derive_platform_suffix_and_scheme (
274
+ scheme , target_triple = derive_platform_suffix_and_scheme (
282
275
artifact ["name" ], options .scheme )
283
276
artifact_format = SDKArtifactFormatV3 (target_triple )
284
277
bundle_path = await self .unpack_artifactbundle (artifact_path )
@@ -584,13 +577,13 @@ You can install Swift SDKs for WebAssembly using the following commands:
584
577
585
578
def derive_platform_suffix_and_scheme (
586
579
artifact_name : str , target_scheme : str
587
- ) -> Tuple [ Optional [str ] , str , str ]:
580
+ ) -> Optional [Tuple [ str , str ] ]:
588
581
"""
589
582
Returns platform suffix, scheme, and target triple derived from the
590
583
artifact name.
591
584
e.g.
592
585
"main-wasm32-unknown-wasi-artifactbundle", scheme="main"
593
- -> [None, "main", "wasm32-unknown-wasi"]
586
+ -> ["main", "wasm32-unknown-wasi"]
594
587
"""
595
588
596
589
# v3 artifact name: <scheme>-<target-triple>-artifactbundle
@@ -610,7 +603,8 @@ def derive_platform_suffix_and_scheme(
610
603
f"Unexpected artifact name { name } with format v3 should"
611
604
" end with -artifactbundle" )
612
605
target_triple = rest [:- len ("-artifactbundle" )]
613
- return [None , target_scheme , target_triple ]
606
+ return [target_scheme , target_triple ]
607
+ raise Exception (f"Unexpected artifact name { name } " )
614
608
615
609
616
610
def latest_success_run_id (gh : GitHub , workflow_name : str , branch : str , scheme : str ):
@@ -626,11 +620,13 @@ def latest_success_run_id(gh: GitHub, workflow_name: str, branch: str, scheme: s
626
620
artifacts = gh .list_artifacts (run ["id" ])
627
621
for artifact in artifacts :
628
622
artifact_name = artifact ["name" ]
629
- if not artifact_name .endswith ("-artifactbundle" ):
623
+ try :
624
+ artifact_scheme , _ = derive_platform_suffix_and_scheme (
625
+ artifact_name , scheme )
626
+ if artifact_scheme == scheme :
627
+ return run ["id" ]
628
+ except Exception :
630
629
continue
631
- _ , artifact_scheme , _ = derive_platform_suffix_and_scheme (artifact_name , scheme )
632
- if artifact_scheme == scheme :
633
- return run ["id" ]
634
630
print (f"Could not find a successful run for { workflow_name } on { branch } branch with scheme { scheme } " )
635
631
return None
636
632
0 commit comments