Swap CI client back to Azure DevOps

Fixes #944
This commit is contained in:
13xforever 2023-11-15 00:20:43 +05:00
parent bdacb51408
commit c1ccc8fb7a
No known key found for this signature in database
GPG Key ID: 2B2A36B482FE70C5
3 changed files with 34 additions and 31 deletions

View File

@ -3,13 +3,13 @@
"isRoot": true, "isRoot": true,
"tools": { "tools": {
"strawberryshake.tools": { "strawberryshake.tools": {
"version": "13.4.0", "version": "13.7.0",
"commands": [ "commands": [
"dotnet-graphql" "dotnet-graphql"
] ]
}, },
"dotnet-ef": { "dotnet-ef": {
"version": "7.0.9", "version": "8.0.0",
"commands": [ "commands": [
"dotnet-ef" "dotnet-ef"
] ]

View File

@ -2,7 +2,6 @@
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using CirrusCiClient;
using CompatApiClient.Utils; using CompatApiClient.Utils;
using CompatBot.Commands.Attributes; using CompatBot.Commands.Attributes;
using CompatBot.Utils; using CompatBot.Utils;
@ -12,7 +11,8 @@ using DSharpPlus;
using DSharpPlus.CommandsNext; using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes; using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities; using DSharpPlus.Entities;
using TaskStatus = CirrusCiClient.Generated.TaskStatus; using Microsoft.TeamFoundation.Build.WebApi;
using BuildStatus = Microsoft.TeamFoundation.Build.WebApi.BuildStatus;
namespace CompatBot.Commands; namespace CompatBot.Commands;
@ -134,13 +134,13 @@ internal sealed class Pr: BaseCommandModuleCustom
string? macDownloadText = null; string? macDownloadText = null;
string? buildTime = null; string? buildTime = null;
if (prInfo.Head?.Sha is string commit) if (azureClient != null && prInfo.Head?.Sha is string commit)
try try
{ {
windowsDownloadText = "⏳ Pending..."; windowsDownloadText = "⏳ Pending...";
linuxDownloadText = "⏳ Pending..."; linuxDownloadText = "⏳ Pending...";
macDownloadText = "⏳ Pending..."; macDownloadText = "⏳ Pending...";
var latestBuild = await CirrusCi.GetPrBuildInfoAsync(commit, prInfo.MergedAt?.DateTime, pr, Config.Cts.Token).ConfigureAwait(false); var latestBuild = await azureClient.GetPrBuildInfoAsync(commit, prInfo.MergedAt?.DateTime, pr, Config.Cts.Token).ConfigureAwait(false);
if (latestBuild == null) if (latestBuild == null)
{ {
if (state == "Open") if (state == "Open")
@ -155,20 +155,23 @@ internal sealed class Pr: BaseCommandModuleCustom
{ {
bool shouldHaveArtifacts = false; bool shouldHaveArtifacts = false;
if ((latestBuild.WindowsBuild?.Status is TaskStatus.Completed if (latestBuild is
|| latestBuild.LinuxBuild?.Status is TaskStatus.Completed {
|| latestBuild.MacBuild?.Status is TaskStatus.Completed) Status: BuildStatus.Completed,
&& latestBuild.FinishTime.HasValue) Result: BuildResult.Succeeded or BuildResult.PartiallySucceeded,
FinishTime: not null
})
{ {
buildTime = $"Built on {latestBuild.FinishTime:u} ({(DateTime.UtcNow - latestBuild.FinishTime.Value).AsTimeDeltaDescription()} ago)"; buildTime = $"Built on {latestBuild.FinishTime:u} ({(DateTime.UtcNow - latestBuild.FinishTime.Value).AsTimeDeltaDescription()} ago)";
shouldHaveArtifacts = true; shouldHaveArtifacts = true;
} }
// Check for subtask errors (win/lin/mac) // Check for subtask errors (win/lin/mac)
if (latestBuild.WindowsBuild?.Status is TaskStatus.Aborted or TaskStatus.Failed or TaskStatus.Skipped) if (latestBuild.Result is BuildResult.Failed or BuildResult.Canceled)
{ {
windowsDownloadText = $"❌ {latestBuild.WindowsBuild?.Status}"; windowsDownloadText = $"❌ {latestBuild.Result}";
} }
/*
if (latestBuild.LinuxBuild?.Status is TaskStatus.Aborted or TaskStatus.Failed or TaskStatus.Skipped) if (latestBuild.LinuxBuild?.Status is TaskStatus.Aborted or TaskStatus.Failed or TaskStatus.Skipped)
{ {
linuxDownloadText = $"❌ {latestBuild.LinuxBuild?.Status}"; linuxDownloadText = $"❌ {latestBuild.LinuxBuild?.Status}";
@ -177,17 +180,20 @@ internal sealed class Pr: BaseCommandModuleCustom
{ {
macDownloadText = $"❌ {latestBuild.MacBuild?.Status}"; macDownloadText = $"❌ {latestBuild.MacBuild?.Status}";
} }
*/
// Check estimated time for pending builds // Check estimated time for pending builds
if (latestBuild.WindowsBuild?.Status is TaskStatus.Executing if (latestBuild is { Status: BuildStatus.InProgress, StartTime: not null })
|| latestBuild.LinuxBuild?.Status is TaskStatus.Executing
|| latestBuild.MacBuild?.Status is TaskStatus.Executing)
{ {
var estimatedCompletionTime = latestBuild.StartTime + (await CirrusCi.GetPipelineDurationAsync(Config.Cts.Token).ConfigureAwait(false)).Mean; var estimatedCompletionTime = latestBuild.StartTime.Value + (await azureClient.GetPipelineDurationAsync(Config.Cts.Token).ConfigureAwait(false)).Mean;
var estimatedTime = TimeSpan.FromMinutes(1); var estimatedTime = TimeSpan.FromMinutes(1);
if (estimatedCompletionTime > DateTime.UtcNow) if (estimatedCompletionTime > DateTime.UtcNow)
estimatedTime = estimatedCompletionTime - DateTime.UtcNow; estimatedTime = estimatedCompletionTime - DateTime.UtcNow;
windowsDownloadText = $"⏳ Pending in {estimatedTime.AsTimeDeltaDescription()}...";
linuxDownloadText = windowsDownloadText;
macDownloadText = windowsDownloadText;
/*
if (latestBuild.WindowsBuild?.Status is TaskStatus.Executing) if (latestBuild.WindowsBuild?.Status is TaskStatus.Executing)
{ {
windowsDownloadText = $"⏳ Pending in {estimatedTime.AsTimeDeltaDescription()}..."; windowsDownloadText = $"⏳ Pending in {estimatedTime.AsTimeDeltaDescription()}...";
@ -200,13 +206,14 @@ internal sealed class Pr: BaseCommandModuleCustom
{ {
macDownloadText = $"⏳ Pending in {estimatedTime.AsTimeDeltaDescription()}..."; macDownloadText = $"⏳ Pending in {estimatedTime.AsTimeDeltaDescription()}...";
} }
*/
} }
// windows build // windows build
var name = latestBuild.WindowsBuild?.Filename ?? "Windows PR Build"; var name = latestBuild.WindowsFilename ?? "Windows PR Build";
name = name.Replace("rpcs3-", "").Replace("_win64", ""); name = name.Replace("rpcs3-", "").Replace("_win64", "");
if (!string.IsNullOrEmpty(latestBuild.WindowsBuild?.DownloadLink)) if (!string.IsNullOrEmpty(latestBuild.WindowsBuildDownloadLink))
windowsDownloadText = $"[⏬ {name}]({latestBuild.WindowsBuild?.DownloadLink})"; windowsDownloadText = $"[⏬ {name}]({latestBuild.WindowsBuildDownloadLink})";
else if (shouldHaveArtifacts) else if (shouldHaveArtifacts)
{ {
if (latestBuild.FinishTime.HasValue && (DateTime.UtcNow - latestBuild.FinishTime.Value).TotalDays > 30) if (latestBuild.FinishTime.HasValue && (DateTime.UtcNow - latestBuild.FinishTime.Value).TotalDays > 30)
@ -214,10 +221,10 @@ internal sealed class Pr: BaseCommandModuleCustom
} }
// linux build // linux build
name = latestBuild.LinuxBuild?.Filename ?? "Linux PR Build"; name = latestBuild.LinuxFilename ?? "Linux PR Build";
name = name.Replace("rpcs3-", "").Replace("_linux64", ""); name = name.Replace("rpcs3-", "").Replace("_linux64", "");
if (!string.IsNullOrEmpty(latestBuild.LinuxBuild?.DownloadLink)) if (!string.IsNullOrEmpty(latestBuild.LinuxBuildDownloadLink))
linuxDownloadText = $"[⏬ {name}]({latestBuild.LinuxBuild?.DownloadLink})"; linuxDownloadText = $"[⏬ {name}]({latestBuild.LinuxBuildDownloadLink})";
else if (shouldHaveArtifacts) else if (shouldHaveArtifacts)
{ {
if (latestBuild.FinishTime.HasValue && (DateTime.UtcNow - latestBuild.FinishTime.Value).TotalDays > 30) if (latestBuild.FinishTime.HasValue && (DateTime.UtcNow - latestBuild.FinishTime.Value).TotalDays > 30)
@ -225,10 +232,10 @@ internal sealed class Pr: BaseCommandModuleCustom
} }
// mac build // mac build
name = latestBuild.MacBuild?.Filename ?? "Mac PR Build"; name = latestBuild.MacFilename ?? "Mac PR Build";
name = name.Replace("rpcs3-", "").Replace("_macos", ""); name = name.Replace("rpcs3-", "").Replace("_macos", "");
if (!string.IsNullOrEmpty(latestBuild.MacBuild?.DownloadLink)) if (!string.IsNullOrEmpty(latestBuild.MacBuildDownloadLink))
macDownloadText = $"[⏬ {name}]({latestBuild.MacBuild?.DownloadLink})"; macDownloadText = $"[⏬ {name}]({latestBuild.MacBuildDownloadLink})";
else if (shouldHaveArtifacts) else if (shouldHaveArtifacts)
{ {
if (latestBuild.FinishTime.HasValue && (DateTime.UtcNow - latestBuild.FinishTime.Value).TotalDays > 30) if (latestBuild.FinishTime.HasValue && (DateTime.UtcNow - latestBuild.FinishTime.Value).TotalDays > 30)
@ -236,7 +243,7 @@ internal sealed class Pr: BaseCommandModuleCustom
} }
// Neatify PR's with missing builders // Neatify PR's with missing builders
if (latestBuild.WindowsBuild?.Status is null) /*if (latestBuild.WindowsBuild?.Status is null)
{ {
windowsDownloadText = null; windowsDownloadText = null;
} }
@ -247,9 +254,7 @@ internal sealed class Pr: BaseCommandModuleCustom
if (latestBuild.MacBuild?.Status is null) if (latestBuild.MacBuild?.Status is null)
{ {
macDownloadText = null; macDownloadText = null;
} }*/
} }
} }
catch (Exception e) catch (Exception e)

View File

@ -6,7 +6,6 @@ using System.Reflection;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using CirrusCiClient;
using CompatBot.Commands; using CompatBot.Commands;
using CompatBot.Commands.Converters; using CompatBot.Commands.Converters;
using CompatBot.Database; using CompatBot.Database;
@ -122,7 +121,6 @@ internal static class Program
CompatList.ImportCompatListAsync(), CompatList.ImportCompatListAsync(),
Config.GetAzureDevOpsClient().GetPipelineDurationAsync(Config.Cts.Token), Config.GetAzureDevOpsClient().GetPipelineDurationAsync(Config.Cts.Token),
Config.GetCurrentGitRevisionAsync(Config.Cts.Token), Config.GetCurrentGitRevisionAsync(Config.Cts.Token),
CirrusCi.GetPipelineDurationAsync(Config.Cts.Token),
Sudo.Bot.UpdateCheckScheduledAsync(Config.Cts.Token) Sudo.Bot.UpdateCheckScheduledAsync(Config.Cts.Token)
); );