mirror of
https://github.com/RPCS3/discord-bot.git
synced 2026-01-31 01:25:22 +01:00
remove azure devops usage and try to fix pr build linking
This commit is contained in:
@@ -127,7 +127,7 @@ public partial class Client
|
||||
// https://api.github.com/repos/RPCS3/rpcs3/actions/artifacts/2802751674 /zip
|
||||
// we need public web links like this:
|
||||
// https://github.com/RPCS3/rpcs3/actions/runs/14017059654/artifacts/2802751674
|
||||
var windowsBuildArtifact = artifacts.FirstOrDefault(a => a.Name.Contains("Windows"));
|
||||
var windowsBuildArtifact = artifacts.FirstOrDefault(a => a.Name.Contains("Windows") && !a.Name.Contains("Clang") && !a.Name.Contains("ARM"));
|
||||
if (windowsBuildArtifact is { ArchiveDownloadUrl.Length: > 0, Expired: false })
|
||||
{
|
||||
var winZipUrl = $"https://github.com/RPCS3/rpcs3/actions/runs/{run.Id}/artifacts/{windowsBuildArtifact.Id}";
|
||||
@@ -151,6 +151,31 @@ public partial class Client
|
||||
}
|
||||
}
|
||||
|
||||
// windows arm build
|
||||
var windowsArmBuildArtifact = artifacts.FirstOrDefault(a => a.Name.Contains("Windows") && a.Name.Contains("ARM"));
|
||||
if (windowsArmBuildArtifact is { ArchiveDownloadUrl.Length: > 0, Expired: false })
|
||||
{
|
||||
var winZipUrl = $"https://github.com/RPCS3/rpcs3/actions/runs/{run.Id}/artifacts/{windowsArmBuildArtifact.Id}";
|
||||
result = result with { WindowsArmBuildDownloadLink = winZipUrl };
|
||||
try
|
||||
{
|
||||
await using var stream = await client.Actions.Artifacts.DownloadArtifact(OwnerId, RepoId, windowsArmBuildArtifact.Id, "zip").ConfigureAwait(false);
|
||||
using var zipStream = ReaderFactory.Open(stream);
|
||||
while (zipStream.MoveToNextEntry() && !cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
if (zipStream.Entry.Key?.EndsWith(".7z", StringComparison.OrdinalIgnoreCase) is true)
|
||||
{
|
||||
result = result with { WindowsArmFilename = Path.GetFileName(zipStream.Entry.Key) };
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e2)
|
||||
{
|
||||
ApiConfig.Log.Error(e2, "Failed to get windows arm build filename");
|
||||
}
|
||||
}
|
||||
|
||||
// linux build
|
||||
var linuxBuildArtifact = artifacts
|
||||
.Where(a => a.Name.Contains("Linux") && a.Name.Contains("x64", StringComparison.OrdinalIgnoreCase))
|
||||
|
||||
@@ -134,7 +134,6 @@ internal sealed class Pr
|
||||
|
||||
var (state, _) = prInfo.GetState();
|
||||
var embed = prInfo.AsEmbed();
|
||||
var azureClient = Config.GetAzureDevOpsClient();
|
||||
if (state is "Open" or "Closed")
|
||||
{
|
||||
var windowsDownloadHeader = "Windows x64 PR Build";
|
||||
@@ -151,7 +150,7 @@ internal sealed class Pr
|
||||
string? macArmDownloadText = null;
|
||||
string? buildTime = null;
|
||||
|
||||
if (azureClient is not null && prInfo is {Head.Sha: {Length: >0} commit})
|
||||
if (prInfo is {Head.Sha: {Length: >0} commit})
|
||||
try
|
||||
{
|
||||
windowsDownloadText = "⏳ Pending…";
|
||||
@@ -160,9 +159,8 @@ internal sealed class Pr
|
||||
windowsArmDownloadText = "⏳ Pending…";
|
||||
linuxArmDownloadText = "⏳ Pending…";
|
||||
macArmDownloadText = "⏳ Pending…";
|
||||
var latestBuild = await azureClient.GetPrBuildInfoAsync(commit, prInfo.MergedAt?.DateTime, pr, Config.Cts.Token).ConfigureAwait(false);
|
||||
var ghBuild = await GithubClient.GetPrBuildInfoAsync(commit, prInfo.MergedAt?.DateTime, pr, Config.Cts.Token).ConfigureAwait(false);
|
||||
if (latestBuild is null && ghBuild is null)
|
||||
if (ghBuild is null)
|
||||
{
|
||||
if (state is "Open")
|
||||
{
|
||||
@@ -175,60 +173,6 @@ internal sealed class Pr
|
||||
linuxArmDownloadText = null;
|
||||
macArmDownloadText = null;
|
||||
}
|
||||
if (latestBuild is not null)
|
||||
{
|
||||
var shouldHaveArtifacts = false;
|
||||
if (latestBuild is
|
||||
{
|
||||
Status: BuildStatus.Completed,
|
||||
Result: BuildResult.Succeeded or BuildResult.PartiallySucceeded,
|
||||
FinishTime: not null
|
||||
})
|
||||
{
|
||||
buildTime = $"Built on {latestBuild.FinishTime:u} ({(DateTime.UtcNow - latestBuild.FinishTime.Value).AsTimeDeltaDescription()} ago)";
|
||||
shouldHaveArtifacts = true;
|
||||
}
|
||||
|
||||
// Check for subtask errors (win/lin/mac)
|
||||
if (latestBuild is { Result: BuildResult.Failed or BuildResult.Canceled })
|
||||
{
|
||||
macDownloadText = $"❌ {latestBuild.Result}";
|
||||
macArmDownloadText = $"❌ {latestBuild.Result}";
|
||||
}
|
||||
|
||||
// Check estimated time for pending builds
|
||||
if (latestBuild is { Status: BuildStatus.InProgress, StartTime: not null })
|
||||
{
|
||||
var estimatedCompletionTime = latestBuild.StartTime.Value + (await azureClient.GetPipelineDurationAsync(Config.Cts.Token).ConfigureAwait(false)).Mean;
|
||||
var estimatedTime = TimeSpan.FromMinutes(1);
|
||||
if (estimatedCompletionTime > DateTime.UtcNow)
|
||||
estimatedTime = estimatedCompletionTime - DateTime.UtcNow;
|
||||
macDownloadText = $"⏳ Pending in {estimatedTime.AsTimeDeltaDescription()}…";
|
||||
macArmDownloadText = $"⏳ Pending in {estimatedTime.AsTimeDeltaDescription()}…";
|
||||
}
|
||||
|
||||
// mac build
|
||||
var name = latestBuild.MacFilename ?? "Mac PR Build";
|
||||
name = name.Replace("rpcs3-", "").Replace("_macos", "");
|
||||
if (!string.IsNullOrEmpty(latestBuild.MacBuildDownloadLink))
|
||||
macDownloadText = $"[⏬ {name}]({latestBuild.MacBuildDownloadLink})";
|
||||
else if (shouldHaveArtifacts)
|
||||
{
|
||||
if (latestBuild.FinishTime.HasValue && (DateTime.UtcNow - latestBuild.FinishTime.Value).TotalDays > 30)
|
||||
macDownloadText = "No longer available";
|
||||
}
|
||||
|
||||
// mac arm build
|
||||
name = latestBuild.MacArmFilename ?? "Mac Apple Silicon PR Build";
|
||||
name = name.Replace("rpcs3-", "").Replace("_macos_arm64", "");
|
||||
if (!string.IsNullOrEmpty(latestBuild.MacArmBuildDownloadLink))
|
||||
macArmDownloadText = $"[⏬ {name}]({latestBuild.MacArmBuildDownloadLink})";
|
||||
else if (shouldHaveArtifacts)
|
||||
{
|
||||
if (latestBuild.FinishTime.HasValue && (DateTime.UtcNow - latestBuild.FinishTime.Value).TotalDays > 30)
|
||||
macArmDownloadText = "No longer available";
|
||||
}
|
||||
}
|
||||
if (ghBuild is not null)
|
||||
{
|
||||
var shouldHaveArtifacts = false;
|
||||
@@ -360,7 +304,7 @@ internal sealed class Pr
|
||||
if (!string.IsNullOrEmpty(buildTime))
|
||||
embed.WithFooter(buildTime);
|
||||
}
|
||||
else if (state is "Merged" && azureClient is not null)
|
||||
else if (state is "Merged")
|
||||
{
|
||||
var mergeTime = prInfo.MergedAt.GetValueOrDefault();
|
||||
var now = DateTime.UtcNow;
|
||||
|
||||
Reference in New Issue
Block a user