Skip to content

Commit

Permalink
Build: Start caching Linux arm64 builds
Browse files Browse the repository at this point in the history
  • Loading branch information
AniLeo committed Oct 2, 2024
1 parent d1bafc4 commit 4b14f07
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 8 deletions.
43 changes: 35 additions & 8 deletions cachers.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ function parse_build_properties(object $info) : ?array
if (str_contains($asset->name, ".sha256"))
continue;

if (str_contains($asset->name, "win64.7z"))
$ret["filename"] = $asset->name;
else if (str_contains($asset->name, "linux64.AppImage"))
$ret["filename"] = $asset->name;
else if (str_contains($asset->name, "macos.7z"))
$ret["filename"] = $asset->name;
else if (str_contains($asset->name, "macos_arm64.7z"))
if (str_contains($asset->name, "win64.7z") ||
str_contains($asset->name, "linux64.AppImage") ||
str_contains($asset->name, "linux_aarch64.AppImage") ||
str_contains($asset->name, "macos.7z") ||
str_contains($asset->name, "macos_arm64.7z"))
{
$ret["filename"] = $asset->name;
}
}

// API Sanity Check
Expand Down Expand Up @@ -322,13 +322,19 @@ function cache_build(int $pr) : void
if (is_null($info_release_mac))
return;

// Linux arm64 build metadata
$info_release_linux_arm64 = curl_json("https://api.github.com/repos/rpcs3/rpcs3-binaries-linux-arm64/releases/tags/build-{$commit}", $cr);
if (is_null($info_release_linux_arm64))
return;

// macOS arm64 build metadata
$info_release_mac_arm64 = curl_json("https://api.github.com/repos/rpcs3/rpcs3-binaries-mac-arm64/releases/tags/build-{$commit}", $cr);
if (is_null($info_release_mac_arm64))
return;

$is_missing = isset($info_release_win->message) ||
isset($info_release_linux->message) ||
isset($info_release_linux_arm64->message) ||
isset($info_release_mac->message) ||
isset($info_release_mac_arm64->message);

Expand All @@ -347,6 +353,7 @@ function cache_build(int $pr) : void
$info_win = parse_build_properties($info_release_win);
$info_linux = parse_build_properties($info_release_linux);
$info_mac = parse_build_properties($info_release_mac);
$info_linux_arm64 = parse_build_properties($info_release_linux_arm64);
$info_mac_arm64 = parse_build_properties($info_release_mac_arm64);

// Fail if one of the builds is not available until a grace period has passed
Expand Down Expand Up @@ -380,6 +387,16 @@ function cache_build(int $pr) : void
return;
}

if (!isset($version) && !is_null($info_linux_arm64))
{
$version = $info_linux_arm64["version"];
}
else if (!isset($version) && !$is_broken)
{
curl_close($cr);
return;
}

if (!isset($version) && !is_null($info_mac_arm64))
{
$version = $info_mac_arm64["version"];
Expand All @@ -401,10 +418,11 @@ function cache_build(int $pr) : void
if ($is_broken)
{
echo "A build is broken for Pull Request #{$pr}".PHP_EOL;
printf("Build status: Windows: %s, Linux: %s, macOS: %s, macOS arm64: %s",
printf("Build status: Windows: %s, Linux: %s, macOS: %s, Linux arm64: %s, macOS arm64: %s",
isset($info_release_win->message) ? $info_release_win->message : "OK",
isset($info_release_linux->message) ? $info_release_linux->message : "OK",
isset($info_release_mac->message) ? $info_release_mac->message : "OK",
isset($info_release_linux_arm64->message) ? $info_release_linux_arm64->message : "OK",
isset($info_release_mac_arm64->message) ? $info_release_mac_arm64->message : "OK");
}

Expand Down Expand Up @@ -439,6 +457,9 @@ function cache_build(int $pr) : void
`size_mac` = ".(isset($info_mac) ? "'".mysqli_real_escape_string($db, (string) $info_mac["size"])."'" : "NULL").",
`checksum_mac` = ".(isset($info_mac) ? "'".mysqli_real_escape_string($db, (string) $info_mac["checksum"])."'" : "NULL").",
`filename_mac` = ".(isset($info_mac) ? "'".mysqli_real_escape_string($db, (string) $info_mac["filename"])."'" : "NULL").",
`size_linux_arm64` = ".(isset($info_linux_arm64) ? "'".mysqli_real_escape_string($db, (string) $info_linux_arm64["size"])."'" : "NULL").",
`checksum_linux_arm64` = ".(isset($info_linux_arm64) ? "'".mysqli_real_escape_string($db, (string) $info_linux_arm64["checksum"])."'" : "NULL").",
`filename_linux_arm64` = ".(isset($info_linux_arm64) ? "'".mysqli_real_escape_string($db, (string) $info_linux_arm64["filename"])."'" : "NULL").",
`size_mac_arm64` = ".(isset($info_mac_arm64) ? "'".mysqli_real_escape_string($db, (string) $info_mac_arm64["size"])."'" : "NULL").",
`checksum_mac_arm64` = ".(isset($info_mac_arm64) ? "'".mysqli_real_escape_string($db, (string) $info_mac_arm64["checksum"])."'" : "NULL").",
`filename_mac_arm64` = ".(isset($info_mac_arm64) ? "'".mysqli_real_escape_string($db, (string) $info_mac_arm64["filename"])."'" : "NULL").",
Expand Down Expand Up @@ -470,6 +491,9 @@ function cache_build(int $pr) : void
`size_mac`,
`checksum_mac`,
`filename_mac`,
`size_linux_arm64`,
`checksum_linux_arm64`,
`filename_linux_arm64`,
`size_mac_arm64`,
`checksum_mac_arm64`,
`filename_mac_arm64`,
Expand All @@ -495,6 +519,9 @@ function cache_build(int $pr) : void
".(isset($info_mac) ? "'".mysqli_real_escape_string($db, (string) $info_mac["size"])."'" : "NULL").",
".(isset($info_mac) ? "'".mysqli_real_escape_string($db, (string) $info_mac["checksum"])."'" : "NULL").",
".(isset($info_mac) ? "'".mysqli_real_escape_string($db, (string) $info_mac["filename"])."'" : "NULL").",
".(isset($info_linux_arm64) ? "'".mysqli_real_escape_string($db, (string) $info_linux_arm64["size"])."'" : "NULL").",
".(isset($info_linux_arm64) ? "'".mysqli_real_escape_string($db, (string) $info_linux_arm64["checksum"])."'" : "NULL").",
".(isset($info_linux_arm64) ? "'".mysqli_real_escape_string($db, (string) $info_linux_arm64["filename"])."'" : "NULL").",
".(isset($info_mac_arm64) ? "'".mysqli_real_escape_string($db, (string) $info_mac_arm64["size"])."'" : "NULL").",
".(isset($info_mac_arm64) ? "'".mysqli_real_escape_string($db, (string) $info_mac_arm64["checksum"])."'" : "NULL").",
".(isset($info_mac_arm64) ? "'".mysqli_real_escape_string($db, (string) $info_mac_arm64["filename"])."'" : "NULL").",
Expand Down
3 changes: 3 additions & 0 deletions database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ CREATE TABLE `builds` (
`filename_mac` varchar(128) DEFAULT NULL,
`checksum_mac` varchar(64) DEFAULT NULL COMMENT 'sha256',
`size_mac` int(11) DEFAULT NULL,
`filename_linux_arm64` varchar(128) DEFAULT NULL,
`checksum_linux_arm64` varchar(64) DEFAULT NULL COMMENT 'sha256',
`size_linux_arm64` int(11) DEFAULT NULL,
`filename_mac_arm64` varchar(128) DEFAULT NULL,
`checksum_mac_arm64` varchar(64) DEFAULT NULL COMMENT 'sha256',
`size_mac_arm64` int(11) DEFAULT NULL,
Expand Down
31 changes: 31 additions & 0 deletions objects/Build.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class Build
public ?int $size_mac;
public ?string $filename_mac;

public ?string $checksum_linux_arm64;
public ?int $size_linux_arm64;
public ?string $filename_linux_arm64;

public ?string $checksum_mac_arm64;
public ?int $size_mac_arm64;
public ?string $filename_mac_arm64;
Expand Down Expand Up @@ -73,6 +77,9 @@ function __construct( int $pr,
?string $checksum_mac,
?int $size_mac,
?string $filename_mac,
?string $checksum_linux_arm64,
?int $size_linux_arm64,
?string $filename_linux_arm64,
?string $checksum_mac_arm64,
?int $size_mac_arm64,
?string $filename_mac_arm64,
Expand All @@ -93,6 +100,9 @@ function __construct( int $pr,
$this->checksum_mac = $checksum_mac;
$this->size_mac = $size_mac;
$this->filename_mac = $filename_mac;
$this->checksum_linux_arm64 = $checksum_linux_arm64;
$this->size_linux_arm64 = $size_linux_arm64;
$this->filename_linux_arm64 = $filename_linux_arm64;
$this->checksum_mac_arm64 = $checksum_mac_arm64;
$this->size_mac_arm64 = $size_mac_arm64;
$this->filename_mac_arm64 = $filename_mac_arm64;
Expand Down Expand Up @@ -166,6 +176,15 @@ public function get_url_mac() : ?string
return null;
}

public function get_url_linux_arm64() : ?string
{
if (!is_null($this->filename_linux_arm64))
{
return "https://github.com/RPCS3/rpcs3-binaries-linux-arm64/releases/download/build-{$this->commit}/{$this->filename_linux_arm64}";
}
return null;
}

public function get_url_mac_arm64() : ?string
{
if (!is_null($this->filename_mac_arm64))
Expand Down Expand Up @@ -212,6 +231,15 @@ public function get_size_mb_mac() : ?float
return null;
}

public function get_size_mb_linux_arm64() : ?float
{
if (!is_null($this->size_linux_arm64))
{
return round($this->size_linux_arm64 / 1024 / 1024, 1);
}
return null;
}

public function get_size_mb_mac_arm64() : ?float
{
if (!is_null($this->size_mac_arm64))
Expand Down Expand Up @@ -315,6 +343,9 @@ public static function query_to_builds(mysqli_result $query) : array
$row->checksum_mac,
$row->size_mac,
$row->filename_mac,
$row->checksum_linux_arm64,
$row->size_linux_arm64,
$row->filename_linux_arm64,
$row->checksum_mac_arm64,
$row->size_mac_arm64,
$row->filename_mac_arm64,
Expand Down

0 comments on commit 4b14f07

Please sign in to comment.