Skip to content

Commit be8ccb4

Browse files
authored
[Testing] Fixed download temporal-test-server(arm64) (#629)
1 parent 9a5919a commit be8ccb4

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed
File renamed without changes.

testing/src/Downloader.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(
3131

3232
public function download(SystemInfo $systemInfo): void
3333
{
34-
$asset = $this->getAsset($systemInfo->platform, $systemInfo->arch);
34+
$asset = $this->getAsset($systemInfo);
3535
$assetUrl = $asset['browser_download_url'];
3636
$pathToExtractedAsset = $this->downloadAsset($assetUrl);
3737

@@ -46,19 +46,33 @@ public function check(string $filename): bool
4646
return $this->filesystem->exists($filename);
4747
}
4848

49-
private function findAsset(array $assets, string $systemPlatform, string $systemArch): array
49+
private function findAsset(array $assets, SystemInfo $systemInfo): array
5050
{
51+
$assetsMacOs = null;
52+
5153
foreach ($assets as $asset) {
5254
\preg_match('/^temporal-test-server_[^_]+_([^_]+)_([^.]+)\.(?:zip|tar.gz)$/', $asset['name'], $match);
5355
[, $assetPlatform, $assetArch] = $match;
5456

55-
if ($assetPlatform === $systemPlatform) {
56-
// TODO: assetArch === systemArch (no arm builds for test server yet)
57+
58+
// save compatibility
59+
if ($assetPlatform == 'macOS') {
60+
$assetsMacOs = $asset;
61+
}
62+
63+
64+
if ($assetPlatform == $systemInfo->platform && $systemInfo->os == $assetArch) {
5765
return $asset;
5866
}
5967
}
6068

61-
throw new \RuntimeException("Asset for $systemPlatform not found");
69+
// save compatibility
70+
if ($systemInfo->platform == 'macOS' && $assetsMacOs != null) {
71+
return $assetsMacOs;
72+
}
73+
74+
75+
throw new \RuntimeException("Asset for $systemInfo->platform not found");
6276
}
6377

6478
private function downloadAsset(string $assetUrl): string
@@ -82,11 +96,11 @@ private function downloadAsset(string $assetUrl): string
8296
return $extractedPath;
8397
}
8498

85-
private function getAsset(string $systemPlatform, string $systemArch): array
99+
private function getAsset(SystemInfo $systemInfo): array
86100
{
87101
$response = $this->httpClient->request('GET', $this->javaSdkUrl);
88102
$assets = $response->toArray()['assets'];
89103

90-
return $this->findAsset($assets, $systemPlatform, $systemArch);
104+
return $this->findAsset($assets, $systemInfo);
91105
}
92106
}

testing/src/SystemInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ final class SystemInfo
1717
private const ARCHITECTURE_MAPPINGS = [
1818
'x64' => 'amd64',
1919
'amd64' => 'amd64',
20-
'arm64' => 'aarch64',
20+
'arm64' => 'arm64',
2121
];
2222
private const TEMPORAL_EXECUTABLE_MAP = [
2323
'darwin' => './temporal-test-server',

0 commit comments

Comments
 (0)