Merge branch 'vnext'

This commit is contained in:
13xforever
2026-01-14 06:20:23 +05:00
10 changed files with 230 additions and 226 deletions

View File

@@ -9,9 +9,9 @@
<ProjectReference Include="..\CompatApiClient\CompatApiClient.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.2" />
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.2" />
<PackageReference Include="StrawberryShake.Server" Version="15.1.11" />
</ItemGroup>
</Project>

View File

@@ -8,7 +8,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.2" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
<PackageReference Include="NLog" Version="6.0.7" />
</ItemGroup>

View File

@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.2" />
<PackageReference Include="Octokit" Version="14.0.0" />
<PackageReference Include="SharpCompress" Version="0.44.0" />
</ItemGroup>

View File

@@ -7,7 +7,7 @@
<ItemGroup>
<PackageReference Include="LTRData.DiscUtils.OpticalDisk" Version="1.0.73" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
<PackageReference Include="System.IO.Hashing" Version="10.0.1" />
<PackageReference Include="System.IO.Hashing" Version="10.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CompatApiClient\CompatApiClient.csproj" />

View File

@@ -12,7 +12,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.2" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
</ItemGroup>
<ItemGroup>

View File

@@ -2,9 +2,6 @@
using CompatBot.Database.Providers;
using CompatBot.Utils.Extensions;
using CompatBot.Utils.ResultFormatters;
using Microsoft.TeamFoundation.Build.WebApi;
using Octokit;
using BuildStatus = Microsoft.TeamFoundation.Build.WebApi.BuildStatus;
namespace CompatBot.Commands;
@@ -13,7 +10,6 @@ namespace CompatBot.Commands;
internal sealed class Pr
{
private static readonly GithubClient.Client GithubClient = new(Config.GithubToken);
private static readonly CompatApiClient.Client CompatApiClient = new();
[Command("search")]
[Description("Search for open pull requests")]
@@ -71,7 +67,7 @@ internal sealed class Pr
if (openPrList is [{}item])
{
var msg = await GetPrBuildMessageAsync(ctx.Client, item.Number).ConfigureAwait(false);
var msg = await PrUpdateInfoFormatter.GetPrBuildMessageAsync(ctx.Client, item.Number).ConfigureAwait(false);
await ctx.RespondAsync(new DiscordInteractionResponseBuilder(msg).AsEphemeral(ephemeral)).ConfigureAwait(false);
return;
}
@@ -93,7 +89,7 @@ internal sealed class Pr
{
var ephemeral = !ctx.Channel.IsSpamChannel() && !ModProvider.IsMod(ctx.User.Id);
await ctx.DeferResponseAsync(ephemeral).ConfigureAwait(false);
var response = await GetPrBuildMessageAsync(ctx.Client, pr).ConfigureAwait(false);
var response = await PrUpdateInfoFormatter.GetPrBuildMessageAsync(ctx.Client, pr).ConfigureAwait(false);
await ctx.RespondAsync(new DiscordInteractionResponseBuilder(response).AsEphemeral(ephemeral)).ConfigureAwait(false);
}
@@ -103,7 +99,7 @@ internal sealed class Pr
{
var ephemeral = !ctx.Channel.IsSpamChannel() && !ModProvider.IsMod(ctx.User.Id);
await ctx.DeferResponseAsync(ephemeral).ConfigureAwait(false);
var msg = await GetPrBuildMessageAsync(ctx.Client, pr, true).ConfigureAwait(false);
var msg = await PrUpdateInfoFormatter.GetPrBuildMessageAsync(ctx.Client, pr, true).ConfigureAwait(false);
await ctx.RespondAsync(new DiscordInteractionResponseBuilder(msg).AsEphemeral(ephemeral)).ConfigureAwait(false);
}
@@ -125,209 +121,6 @@ internal sealed class Pr
}
#endif
private static async ValueTask<DiscordMessageBuilder> GetPrBuildMessageAsync(DiscordClient client, int pr, bool linkOld = false)
{
var prInfo = await GithubClient.GetPrInfoAsync(pr, Config.Cts.Token).ConfigureAwait(false);
var result = new DiscordMessageBuilder();
if (prInfo is null or {Number: 0})
return result.WithContent($"{Config.Reactions.Failure} {prInfo?.Title ?? "PR not found"}");
var (state, _) = prInfo.GetState();
var embed = prInfo.AsEmbed();
if (state is "Open" or "Closed")
{
var windowsDownloadHeader = "Windows x64 PR Build";
var linuxDownloadHeader = "Linux x64 PR Build";
var macDownloadHeader = "Mac Intel PR Build";
var windowsArmDownloadHeader = "Windows ARM64 PR Build";
var linuxArmDownloadHeader = "Linux ARM64 PR Build";
var macArmDownloadHeader = "Mac Apple Silicon PR Build";
string? windowsDownloadText = null;
string? linuxDownloadText = null;
string? macDownloadText = null;
string? windowsArmDownloadText = null;
string? linuxArmDownloadText = null;
string? macArmDownloadText = null;
string? buildTime = null;
if (prInfo is {Head.Sha: {Length: >0} commit})
try
{
windowsDownloadText = "⏳ Pending…";
linuxDownloadText = "⏳ Pending…";
macDownloadText = "⏳ Pending…";
windowsArmDownloadText = "⏳ Pending…";
linuxArmDownloadText = "⏳ Pending…";
macArmDownloadText = "⏳ Pending…";
var ghBuild = await GithubClient.GetPrBuildInfoAsync(commit, prInfo.MergedAt?.DateTime, pr, Config.Cts.Token).ConfigureAwait(false);
if (ghBuild is null)
{
if (state is "Open")
{
embed.WithFooter($"Opened on {prInfo.CreatedAt:u} ({(DateTime.UtcNow - prInfo.CreatedAt).AsTimeDeltaDescription()} ago)");
}
windowsDownloadText = null;
linuxDownloadText = null;
macDownloadText = null;
windowsArmDownloadText = null;
linuxArmDownloadText = null;
macArmDownloadText = null;
}
if (ghBuild is not null)
{
var shouldHaveArtifacts = false;
if (ghBuild is
{
Status: WorkflowRunStatus.Completed,
Result: WorkflowRunConclusion.Success
})
{
buildTime = $"Built on {ghBuild.FinishTime:u} ({(DateTime.UtcNow - ghBuild.FinishTime).AsTimeDeltaDescription()} ago)";
shouldHaveArtifacts = true;
}
// Check for subtask errors (win/lin/mac)
if (ghBuild is { Result: WorkflowRunConclusion.Failure or WorkflowRunConclusion.Cancelled or WorkflowRunConclusion.TimedOut })
{
windowsDownloadText = $"❌ {ghBuild.Result}";
linuxDownloadText = $"❌ {ghBuild.Result}";
windowsArmDownloadText = $"❌ {ghBuild.Result}";
linuxArmDownloadText = $"❌ {ghBuild.Result}";
}
// Check estimated time for pending builds
if (ghBuild is { Status: WorkflowRunStatus.Waiting or WorkflowRunStatus.Pending or WorkflowRunStatus.InProgress })
{
var estimatedCompletionTime = ghBuild.StartTime + (await GithubClient.GetPipelineDurationAsync(Config.Cts.Token).ConfigureAwait(false)).Mean;
var estimatedTime = TimeSpan.FromMinutes(1);
if (estimatedCompletionTime > DateTime.UtcNow)
estimatedTime = estimatedCompletionTime - DateTime.UtcNow;
windowsDownloadText = $"⏳ Pending in {estimatedTime.AsTimeDeltaDescription()}…";
linuxDownloadText = windowsDownloadText;
//macDownloadText = windowsDownloadText;
windowsArmDownloadText = windowsDownloadText;
linuxArmDownloadText = windowsDownloadText;
//macArmDownloadText = windowsDownloadText;
}
// windows build
var name = ghBuild.WindowsFilename ?? "Windows PR Build";
name = name.Replace("rpcs3-", "").Replace("_win64", "").Replace("_msvc", "");
if (ghBuild.WindowsBuildDownloadLink is {Length: >0})
windowsDownloadText = $"[⏬ {name}]({ghBuild.WindowsBuildDownloadLink})";
else if (shouldHaveArtifacts)
{
if ((DateTime.UtcNow - ghBuild.FinishTime).TotalDays > 30)
windowsDownloadText = "No longer available";
}
// windows arm build
name = ghBuild.WindowsArmFilename ?? "Windows ARM64 PR Build";
name = name.Replace("rpcs3-", "").Replace("_aarch64", "").Replace("_clang", "");
if (ghBuild.WindowsArmBuildDownloadLink is {Length: >0})
windowsArmDownloadText = $"[⏬ {name}]({ghBuild.WindowsArmBuildDownloadLink})";
else if (shouldHaveArtifacts)
{
if ((DateTime.UtcNow - ghBuild.FinishTime).TotalDays > 30)
windowsArmDownloadText = "No longer available";
}
// linux build
name = ghBuild.LinuxFilename ?? "Linux PR Build";
name = name.Replace("rpcs3-", "").Replace("_linux64", "");
if (ghBuild.LinuxBuildDownloadLink is {Length: >0})
linuxDownloadText = $"[⏬ {name}]({ghBuild.LinuxBuildDownloadLink})";
else if (shouldHaveArtifacts)
{
if ((DateTime.UtcNow - ghBuild.FinishTime).TotalDays > 30)
linuxDownloadText = "No longer available";
}
// linux arm build
name = ghBuild.LinuxArmFilename ?? "Linux ARM64 PR Build";
name = name.Replace("rpcs3-", "").Replace("_linux_aarch64", "");
if (ghBuild.LinuxArmBuildDownloadLink is {Length: >0})
linuxArmDownloadText = $"[⏬ {name}]({ghBuild.LinuxArmBuildDownloadLink})";
else if (shouldHaveArtifacts)
{
if ((DateTime.UtcNow - ghBuild.FinishTime).TotalDays > 30)
linuxArmDownloadText = "No longer available";
}
// mac build
name = ghBuild.MacFilename ?? "Mac PR Build";
name = name.Replace("rpcs3-", "").Replace("_macos", "");
if (ghBuild.MacBuildDownloadLink is {Length: >0})
macDownloadText = $"[⏬ {name}]({ghBuild.MacBuildDownloadLink})";
else if (shouldHaveArtifacts)
{
if ((DateTime.UtcNow - ghBuild.FinishTime).TotalDays > 30)
macDownloadText = "No longer available";
}
// mac arm build
name = ghBuild.MacArmFilename ?? "Mac Apple Silicon PR Build";
name = name.Replace("rpcs3-", "").Replace("_macos", "").Replace("_arm64", "");
if (ghBuild.MacArmBuildDownloadLink is {Length: >0})
macArmDownloadText = $"[⏬ {name}]({ghBuild.MacArmBuildDownloadLink})";
else if (shouldHaveArtifacts)
{
if ((DateTime.UtcNow - ghBuild.FinishTime).TotalDays > 30)
macArmDownloadText = "No longer available";
}
}
}
catch (Exception e)
{
Config.Log.Error(e, "Failed to get CI build info");
windowsDownloadText = null; // probably due to expired access token
linuxDownloadText = null;
macDownloadText = null;
windowsArmDownloadText = null;
linuxArmDownloadText = null;
macArmDownloadText = null;
}
if (!string.IsNullOrEmpty(windowsDownloadText))
embed.AddField(windowsDownloadHeader, windowsDownloadText, true);
if (!string.IsNullOrEmpty(linuxDownloadText))
embed.AddField(linuxDownloadHeader, linuxDownloadText, true);
if (!string.IsNullOrEmpty (macDownloadText))
embed.AddField(macDownloadHeader, macDownloadText, true);
if (!string.IsNullOrEmpty(windowsArmDownloadText))
embed.AddField(windowsArmDownloadHeader, windowsArmDownloadText, true);
if (!string.IsNullOrEmpty(linuxArmDownloadText))
embed.AddField(linuxArmDownloadHeader, linuxArmDownloadText, true);
if (!string.IsNullOrEmpty (macArmDownloadText))
embed.AddField(macArmDownloadHeader, macArmDownloadText, true);
if (!string.IsNullOrEmpty(buildTime))
embed.WithFooter(buildTime);
}
else if (state is "Merged")
{
var mergeTime = prInfo.MergedAt.GetValueOrDefault();
var now = DateTime.UtcNow;
var updateInfo = await CompatApiClient.GetUpdateAsync(Config.Cts.Token, linkOld ? prInfo.MergeCommitSha : null).ConfigureAwait(false);
if (updateInfo.LatestDatetime is DateTime masterBuildTime && masterBuildTime.Ticks >= mergeTime.Ticks)
embed = await updateInfo.AsEmbedAsync(client, false, embed, prInfo, linkOld).ConfigureAwait(false);
else
{
var waitTime = TimeSpan.FromMinutes(5);
var avgBuildTime = (await GithubClient.GetPipelineDurationAsync(Config.Cts.Token).ConfigureAwait(false)).Mean;
if (now < mergeTime + avgBuildTime)
waitTime = mergeTime + avgBuildTime - now;
embed.AddField(
"Latest master build",
$"""
This pull request has been merged, and will be part of `master` very soon.
Please check again in {waitTime.AsTimeDeltaDescription()}.
"""
);
}
}
return result.AddEmbed(embed);
}
public static async ValueTask<DiscordMessageBuilder?> GetIssueLinkMessageAsync(DiscordClient client, int issue)
{
var issueInfo = await GithubClient.GetIssueInfoAsync(issue, Config.Cts.Token).ConfigureAwait(false);
@@ -335,7 +128,7 @@ internal sealed class Pr
return null;
if (issueInfo.PullRequest is not null)
return await GetPrBuildMessageAsync(client, issue).ConfigureAwait(false);
return await PrUpdateInfoFormatter.GetPrBuildMessageAsync(client, issue).ConfigureAwait(false);
return new DiscordMessageBuilder().AddEmbed(issueInfo.AsEmbed());
}

View File

@@ -54,15 +54,15 @@
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.23.0" />
<PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" Version="2.23.0" />
<PackageReference Include="Microsoft.Azure.CognitiveServices.Vision.ComputerVision" Version="7.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.1">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.2" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
<PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="19.225.2" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.22.1" />

View File

@@ -0,0 +1,212 @@
using Octokit;
namespace CompatBot.Utils.ResultFormatters;
internal class PrUpdateInfoFormatter
{
private static readonly GithubClient.Client GithubClient = new(Config.GithubToken);
private static readonly CompatApiClient.Client CompatApiClient = new();
public static async ValueTask<DiscordMessageBuilder> GetPrBuildMessageAsync(DiscordClient client, int pr, bool linkOld = false)
{
var prInfo = await GithubClient.GetPrInfoAsync(pr, Config.Cts.Token).ConfigureAwait(false);
var result = new DiscordMessageBuilder();
if (prInfo is null or { Number: 0 })
return result.WithContent($"{Config.Reactions.Failure} {prInfo?.Title ?? "PR not found"}");
var (state, _) = prInfo.GetState();
var embed = prInfo.AsEmbed();
if (state is "Open" or "Closed")
{
var windowsDownloadHeader = "Windows x64 PR Build";
var linuxDownloadHeader = "Linux x64 PR Build";
var macDownloadHeader = "Mac Intel PR Build";
var windowsArmDownloadHeader = "Windows ARM64 PR Build";
var linuxArmDownloadHeader = "Linux ARM64 PR Build";
var macArmDownloadHeader = "Mac Apple Silicon PR Build";
string? windowsDownloadText = null;
string? linuxDownloadText = null;
string? macDownloadText = null;
string? windowsArmDownloadText = null;
string? linuxArmDownloadText = null;
string? macArmDownloadText = null;
string? buildTime = null;
if (prInfo is { Head.Sha: { Length: > 0 } commit })
try
{
windowsDownloadText = "⏳ Pending…";
linuxDownloadText = "⏳ Pending…";
macDownloadText = "⏳ Pending…";
windowsArmDownloadText = "⏳ Pending…";
linuxArmDownloadText = "⏳ Pending…";
macArmDownloadText = "⏳ Pending…";
var ghBuild = await GithubClient.GetPrBuildInfoAsync(commit, prInfo.MergedAt?.DateTime, pr, Config.Cts.Token).ConfigureAwait(false);
if (ghBuild is null)
{
if (state is "Open")
{
embed.WithFooter($"Opened on {prInfo.CreatedAt:u} ({(DateTime.UtcNow - prInfo.CreatedAt).AsTimeDeltaDescription()} ago)");
}
windowsDownloadText = null;
linuxDownloadText = null;
macDownloadText = null;
windowsArmDownloadText = null;
linuxArmDownloadText = null;
macArmDownloadText = null;
}
if (ghBuild is not null)
{
var shouldHaveArtifacts = false;
if (ghBuild is
{
Status: WorkflowRunStatus.Completed,
Result: WorkflowRunConclusion.Success
})
{
buildTime = $"Built on {ghBuild.FinishTime:u} ({(DateTime.UtcNow - ghBuild.FinishTime).AsTimeDeltaDescription()} ago)";
shouldHaveArtifacts = true;
}
// Check for subtask errors (win/lin/mac)
if (ghBuild is { Result: WorkflowRunConclusion.Failure or WorkflowRunConclusion.Cancelled or WorkflowRunConclusion.TimedOut })
{
windowsDownloadText = $"❌ {ghBuild.Result}";
linuxDownloadText = $"❌ {ghBuild.Result}";
windowsArmDownloadText = $"❌ {ghBuild.Result}";
linuxArmDownloadText = $"❌ {ghBuild.Result}";
}
// Check estimated time for pending builds
if (ghBuild is { Status: WorkflowRunStatus.Waiting or WorkflowRunStatus.Pending or WorkflowRunStatus.InProgress })
{
var estimatedCompletionTime = ghBuild.StartTime + (await GithubClient.GetPipelineDurationAsync(Config.Cts.Token).ConfigureAwait(false)).Mean;
var estimatedTime = TimeSpan.FromMinutes(1);
if (estimatedCompletionTime > DateTime.UtcNow)
estimatedTime = estimatedCompletionTime - DateTime.UtcNow;
windowsDownloadText = $"⏳ Pending in {estimatedTime.AsTimeDeltaDescription()}…";
linuxDownloadText = windowsDownloadText;
//macDownloadText = windowsDownloadText;
windowsArmDownloadText = windowsDownloadText;
linuxArmDownloadText = windowsDownloadText;
//macArmDownloadText = windowsDownloadText;
}
// windows build
var name = ghBuild.WindowsFilename ?? "Windows PR Build";
name = name.Replace("rpcs3-", "").Replace("_win64", "").Replace("_msvc", "");
if (ghBuild.WindowsBuildDownloadLink is { Length: > 0 })
windowsDownloadText = $"[⏬ {name}]({ghBuild.WindowsBuildDownloadLink})";
else if (shouldHaveArtifacts)
{
if ((DateTime.UtcNow - ghBuild.FinishTime).TotalDays > 30)
windowsDownloadText = "No longer available";
}
// windows arm build
name = ghBuild.WindowsArmFilename ?? "Windows ARM64 PR Build";
name = name.Replace("rpcs3-", "").Replace("_win64", "").Replace("_aarch64", "").Replace("_clang", "");
if (ghBuild.WindowsArmBuildDownloadLink is { Length: > 0 })
windowsArmDownloadText = $"[⏬ {name}]({ghBuild.WindowsArmBuildDownloadLink})";
else if (shouldHaveArtifacts)
{
if ((DateTime.UtcNow - ghBuild.FinishTime).TotalDays > 30)
windowsArmDownloadText = "No longer available";
}
// linux build
name = ghBuild.LinuxFilename ?? "Linux PR Build";
name = name.Replace("rpcs3-", "").Replace("_linux64", "");
if (ghBuild.LinuxBuildDownloadLink is { Length: > 0 })
linuxDownloadText = $"[⏬ {name}]({ghBuild.LinuxBuildDownloadLink})";
else if (shouldHaveArtifacts)
{
if ((DateTime.UtcNow - ghBuild.FinishTime).TotalDays > 30)
linuxDownloadText = "No longer available";
}
// linux arm build
name = ghBuild.LinuxArmFilename ?? "Linux ARM64 PR Build";
name = name.Replace("rpcs3-", "").Replace("_linux_aarch64", "");
if (ghBuild.LinuxArmBuildDownloadLink is { Length: > 0 })
linuxArmDownloadText = $"[⏬ {name}]({ghBuild.LinuxArmBuildDownloadLink})";
else if (shouldHaveArtifacts)
{
if ((DateTime.UtcNow - ghBuild.FinishTime).TotalDays > 30)
linuxArmDownloadText = "No longer available";
}
// mac build
name = ghBuild.MacFilename ?? "Mac PR Build";
name = name.Replace("rpcs3-", "").Replace("_macos", "");
if (ghBuild.MacBuildDownloadLink is { Length: > 0 })
macDownloadText = $"[⏬ {name}]({ghBuild.MacBuildDownloadLink})";
else if (shouldHaveArtifacts)
{
if ((DateTime.UtcNow - ghBuild.FinishTime).TotalDays > 30)
macDownloadText = "No longer available";
}
// mac arm build
name = ghBuild.MacArmFilename ?? "Mac Apple Silicon PR Build";
name = name.Replace("rpcs3-", "").Replace("_macos", "").Replace("_arm64", "");
if (ghBuild.MacArmBuildDownloadLink is { Length: > 0 })
macArmDownloadText = $"[⏬ {name}]({ghBuild.MacArmBuildDownloadLink})";
else if (shouldHaveArtifacts)
{
if ((DateTime.UtcNow - ghBuild.FinishTime).TotalDays > 30)
macArmDownloadText = "No longer available";
}
}
}
catch (Exception e)
{
Config.Log.Error(e, "Failed to get CI build info");
windowsDownloadText = null; // probably due to expired access token
linuxDownloadText = null;
macDownloadText = null;
windowsArmDownloadText = null;
linuxArmDownloadText = null;
macArmDownloadText = null;
}
if (!string.IsNullOrEmpty(windowsDownloadText))
embed.AddField(windowsDownloadHeader, windowsDownloadText, true);
if (!string.IsNullOrEmpty(linuxDownloadText))
embed.AddField(linuxDownloadHeader, linuxDownloadText, true);
if (!string.IsNullOrEmpty(macDownloadText))
embed.AddField(macDownloadHeader, macDownloadText, true);
if (!string.IsNullOrEmpty(windowsArmDownloadText))
embed.AddField(windowsArmDownloadHeader, windowsArmDownloadText, true);
if (!string.IsNullOrEmpty(linuxArmDownloadText))
embed.AddField(linuxArmDownloadHeader, linuxArmDownloadText, true);
if (!string.IsNullOrEmpty(macArmDownloadText))
embed.AddField(macArmDownloadHeader, macArmDownloadText, true);
if (!string.IsNullOrEmpty(buildTime))
embed.WithFooter(buildTime);
}
else if (state is "Merged")
{
var mergeTime = prInfo.MergedAt.GetValueOrDefault();
var now = DateTime.UtcNow;
var updateInfo = await CompatApiClient.GetUpdateAsync(Config.Cts.Token, linkOld ? prInfo.MergeCommitSha : null).ConfigureAwait(false);
if (updateInfo.LatestDatetime is DateTime masterBuildTime && masterBuildTime.Ticks >= mergeTime.Ticks)
embed = await updateInfo.AsEmbedAsync(client, false, embed, prInfo, linkOld).ConfigureAwait(false);
else
{
var waitTime = TimeSpan.FromMinutes(5);
var avgBuildTime = (await GithubClient.GetPipelineDurationAsync(Config.Cts.Token).ConfigureAwait(false)).Mean;
if (now < mergeTime + avgBuildTime)
waitTime = mergeTime + avgBuildTime - now;
embed.AddField(
"Latest master build",
$"""
This pull request has been merged, and will be part of `master` very soon.
Please check again in {waitTime.AsTimeDeltaDescription()}.
"""
);
}
}
return result.AddEmbed(embed);
}
}

View File

@@ -4,7 +4,6 @@ using CompatApiClient;
using CompatApiClient.POCOs;
using CompatApiClient.Utils;
using CompatBot.EventHandlers;
using CompatBot.Utils.Extensions;
namespace CompatBot.Utils.ResultFormatters;

View File

@@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DuoVia.FuzzyStrings" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="NUnit" Version="4.4.0" />
<PackageReference Include="NUnit3TestAdapter" Version="6.1.0">