From de39cd2a8088c4f2611d97ae9ca49b634780d35d Mon Sep 17 00:00:00 2001 From: Dominion Date: Sat, 25 Mar 2023 15:15:13 -0400 Subject: [PATCH] Update Nuget Packages. Fix Test projects. Etc... --- .../Models/Internal/ChatBotApiBase.cs | 2 + .../Tgstation.Server.Api.csproj | 2 +- src/Tgstation.Server.Host.Console/Program.cs | 6 +- .../Tgstation.Server.Host.Console.csproj | 2 +- src/Tgstation.Server.Host.Service/Program.cs | 123 +++++++++++------- .../ServerService.cs | 38 ++++-- .../Tgstation.Server.Host.Service.csproj | 6 +- .../.config/dotnet-tools.json | 2 +- .../Extensions/ServiceCollectionExtensions.cs | 7 +- .../Tgstation.Server.Host.csproj | 32 ++--- .../Tgstation.Server.Api.Tests.csproj | 8 +- .../Tgstation.Server.Client.Tests.csproj | 10 +- ...Tgstation.Server.Host.Console.Tests.csproj | 10 +- .../TestServerService.cs | 20 ++- ...Tgstation.Server.Host.Service.Tests.csproj | 9 +- ...Tgstation.Server.Host.Tests.Signals.csproj | 4 +- .../Tgstation.Server.Host.Tests.csproj | 10 +- ...gstation.Server.Host.Watchdog.Tests.csproj | 10 +- .../Tgstation.Server.Tests/IntegrationTest.cs | 14 +- .../Tgstation.Server.Tests.csproj | 12 +- tools/ReleaseNotes/Program.cs | 42 +----- tools/ReleaseNotes/ReleaseNotes.csproj | 2 +- 22 files changed, 189 insertions(+), 182 deletions(-) diff --git a/src/Tgstation.Server.Api/Models/Internal/ChatBotApiBase.cs b/src/Tgstation.Server.Api/Models/Internal/ChatBotApiBase.cs index 2c4dcd8875..231a94ffbe 100644 --- a/src/Tgstation.Server.Api/Models/Internal/ChatBotApiBase.cs +++ b/src/Tgstation.Server.Api/Models/Internal/ChatBotApiBase.cs @@ -22,8 +22,10 @@ namespace Tgstation.Server.Api.Models.Internal return true; return Provider.Value switch { +#pragma warning disable CS0618 ChatProvider.Discord => Channels?.Select(x => (x.DiscordChannelId.HasValue || ulong.TryParse(x.ChannelData, out _)) && x.IrcChannel == null).All(x => x) ?? true, ChatProvider.Irc => Channels?.Select(x => !x.DiscordChannelId.HasValue && (x.IrcChannel != null || x.ChannelData != null)).All(x => x) ?? true, +#pragma warning restore CS0618 _ => throw new InvalidOperationException("Invalid provider type!"), }; } diff --git a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj index ceddbf5fc8..f079f488db 100644 --- a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj +++ b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj @@ -47,7 +47,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Tgstation.Server.Host.Console/Program.cs b/src/Tgstation.Server.Host.Console/Program.cs index 6155a68460..f88188d7b4 100644 --- a/src/Tgstation.Server.Host.Console/Program.cs +++ b/src/Tgstation.Server.Host.Console/Program.cs @@ -26,15 +26,11 @@ namespace Tgstation.Server.Host.Console /// A representing the running operation. internal static async Task Main(string[] args) { - using var loggerFactory = new LoggerFactory(); + using var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); var arguments = new List(args); var trace = arguments.Remove("--trace-host-watchdog"); var debug = arguments.Remove("--debug-host-watchdog"); -#pragma warning disable CS0618 // Type or member is obsolete - loggerFactory.AddConsole(); -#pragma warning restore CS0618 // Type or member is obsolete - if (trace && debug) { loggerFactory.CreateLogger(nameof(Program)).LogCritical("Please specify only 1 of --trace-host-watchdog or --debug-host-watchdog!"); diff --git a/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj b/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj index b76c2bcc1c..9ab96c2f7b 100644 --- a/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj +++ b/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj @@ -25,7 +25,7 @@ - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Tgstation.Server.Host.Service/Program.cs b/src/Tgstation.Server.Host.Service/Program.cs index ca5facbfd4..47eb8647dd 100644 --- a/src/Tgstation.Server.Host.Service/Program.cs +++ b/src/Tgstation.Server.Host.Service/Program.cs @@ -77,6 +77,54 @@ namespace Tgstation.Server.Host.Service /// A resulting in the 's exit code. static Task Main(string[] args) => CommandLineApplication.ExecuteAsync(args); + /// + /// Attempt to install the TGS Service. + /// + static void RunServiceInstall() + { + // First check if the service already exists + if (Environment.UserInteractive) + foreach (ServiceController sc in ServiceController.GetServices()) + if (sc.ServiceName == "tgstation-server" || sc.ServiceName == "tgstation-server-4") + { + DialogResult result = MessageBox.Show($"You already have another TGS service installed ({sc.ServiceName}). Would you like to uninstall it now? Pressing \"No\" will cancel this install.", "TGS Service", MessageBoxButtons.YesNo); + if (result != DialogResult.Yes) + return; // is this needed after exit? + + // Stop it first to give it some cleanup time + if (sc.Status == ServiceControllerStatus.Running) + { + sc.Stop(); + sc.WaitForStatus(ServiceControllerStatus.Stopped); + } + + // And remove it + using (ServiceInstaller si = new ServiceInstaller()) + { + si.Context = new InstallContext($"old-{sc.ServiceName}-uninstall.log", null); + si.ServiceName = sc.ServiceName; + si.Uninstall(null); + } + } + + using (var processInstaller = new ServiceProcessInstaller()) + using (var installer = new ServiceInstaller()) + { + processInstaller.Account = ServiceAccount.LocalSystem; + + installer.Context = new InstallContext("tgs-install.log", new string[] { String.Format(CultureInfo.InvariantCulture, "/assemblypath={0}", Assembly.GetEntryAssembly().Location) }); + installer.Description = "/tg/station 13 server running as a windows service"; + installer.DisplayName = "/tg/station server"; + installer.StartType = ServiceStartMode.Automatic; + installer.ServicesDependedOn = new string[] { "Tcpip", "Dhcp", "Dnscache" }; + installer.ServiceName = ServerService.Name; + installer.Parent = processInstaller; + + var state = new ListDictionary(); + installer.Install(state); + } + } + /// /// Command line handler, always runs. /// @@ -112,54 +160,35 @@ namespace Tgstation.Server.Host.Service } } - using (var loggerFactory = new LoggerFactory()) + ServerService service = null; + ILoggerFactory loggerFactory; + try + { + loggerFactory = LoggerFactory.Create(builder => + { + if (Configure) + { + builder.AddConsole(); + } + + service = new ServerService(builder, Trace ? LogLevel.Trace : Debug ? LogLevel.Debug : LogLevel.Information); + }); + } + catch + { + service?.Dispose(); + throw; + } + + using (loggerFactory) + using (service) { if (Install) { if (Uninstall) return; // oh no, it's retarded... - // First check if the service already exists - if (Environment.UserInteractive) - foreach (ServiceController sc in ServiceController.GetServices()) - if (sc.ServiceName == "tgstation-server" || sc.ServiceName == "tgstation-server-4") - { - DialogResult result = MessageBox.Show($"You already have another TGS service installed ({sc.ServiceName}). Would you like to uninstall it now? Pressing \"No\" will cancel this install.", "TGS Service", MessageBoxButtons.YesNo); - if (result != DialogResult.Yes) - return; // is this needed after exit? - - // Stop it first to give it some cleanup time - if (sc.Status == ServiceControllerStatus.Running) - { - sc.Stop(); - sc.WaitForStatus(ServiceControllerStatus.Stopped); - } - - // And remove it - using (ServiceInstaller si = new ServiceInstaller()) - { - si.Context = new InstallContext($"old-{sc.ServiceName}-uninstall.log", null); - si.ServiceName = sc.ServiceName; - si.Uninstall(null); - } - } - - using (var processInstaller = new ServiceProcessInstaller()) - using (var installer = new ServiceInstaller()) - { - processInstaller.Account = ServiceAccount.LocalSystem; - - installer.Context = new InstallContext("tgs-install.log", new string[] { String.Format(CultureInfo.InvariantCulture, "/assemblypath={0}", Assembly.GetEntryAssembly().Location) }); - installer.Description = "/tg/station 13 server running as a windows service"; - installer.DisplayName = "/tg/station server"; - installer.StartType = ServiceStartMode.Automatic; - installer.ServicesDependedOn = new string[] { "Tcpip", "Dhcp", "Dnscache" }; - installer.ServiceName = ServerService.Name; - installer.Parent = processInstaller; - - var state = new ListDictionary(); - installer.Install(state); - } + RunServiceInstall(); if (Configure) { @@ -175,15 +204,13 @@ namespace Tgstation.Server.Host.Service installer.Uninstall(null); } else if (!Configure) - using (var service = new ServerService(WatchdogFactory, loggerFactory, Trace ? LogLevel.Trace : Debug ? LogLevel.Debug : LogLevel.Information)) - ServiceBase.Run(service); + { + service.SetupWatchdog(WatchdogFactory.CreateWatchdog(loggerFactory)); + ServiceBase.Run(service); + } if (Configure) { -#pragma warning disable CS0618 // Type or member is obsolete - loggerFactory.AddConsole(); -#pragma warning restore CS0618 // Type or member is obsolete - // DCT: None available await WatchdogFactory.CreateWatchdog(loggerFactory).RunAsync(true, Array.Empty(), default); } diff --git a/src/Tgstation.Server.Host.Service/ServerService.cs b/src/Tgstation.Server.Host.Service/ServerService.cs index a583c707ae..a2696d02df 100644 --- a/src/Tgstation.Server.Host.Service/ServerService.cs +++ b/src/Tgstation.Server.Host.Service/ServerService.cs @@ -25,7 +25,7 @@ namespace Tgstation.Server.Host.Service /// /// The for the . /// - readonly IWatchdog watchdog; + IWatchdog watchdog; /// /// The recieved from of . @@ -40,28 +40,39 @@ namespace Tgstation.Server.Host.Service /// /// Initializes a new instance of the class. /// - /// The to create with. - /// The for . + /// The to configure. /// The minimum to record in the event log. - public ServerService(IWatchdogFactory watchdogFactory, ILoggerFactory loggerFactory, LogLevel minumumLogLevel) + public ServerService(ILoggingBuilder loggingBuilder, LogLevel minumumLogLevel) { - if (watchdogFactory == null) - throw new ArgumentNullException(nameof(watchdogFactory)); - if (loggerFactory == null) - throw new ArgumentNullException(nameof(loggerFactory)); + if (loggingBuilder == null) + throw new ArgumentNullException(nameof(loggingBuilder)); -#pragma warning disable CS0618 // Type or member is obsolete - loggerFactory.AddEventLog(new EventLogSettings + loggingBuilder.AddEventLog(new EventLogSettings { LogName = EventLog.Log, MachineName = EventLog.MachineName, SourceName = EventLog.Source, Filter = (message, logLevel) => logLevel >= minumumLogLevel, }); -#pragma warning restore CS0618 // Type or member is obsolete ServiceName = Name; - watchdog = watchdogFactory.CreateWatchdog(loggerFactory); + } + + /// + /// Setup the for the service. + /// + /// The value of . + public void SetupWatchdog(IWatchdog watchdog) + { + if (watchdog == null) +#pragma warning disable IDE0016 // Use 'throw' expression + throw new ArgumentNullException(nameof(watchdog)); +#pragma warning restore IDE0016 // Use 'throw' expression + + if (this.watchdog != null) + throw new InvalidOperationException("SetupWatchdog called twice!"); + + this.watchdog = watchdog; } /// @@ -74,6 +85,9 @@ namespace Tgstation.Server.Host.Service /// protected override void OnStart(string[] args) { + if (watchdog == null) + throw new InvalidOperationException("Cannot start without watchdog!"); + cancellationTokenSource?.Dispose(); cancellationTokenSource = new CancellationTokenSource(); watchdogTask = RunWatchdog(args, cancellationTokenSource.Token); diff --git a/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj b/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj index 79d5554a33..23ad2e5d76 100644 --- a/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj +++ b/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj @@ -23,13 +23,13 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Tgstation.Server.Host/.config/dotnet-tools.json b/src/Tgstation.Server.Host/.config/dotnet-tools.json index 9504514167..b8b93fc6c0 100644 --- a/src/Tgstation.Server.Host/.config/dotnet-tools.json +++ b/src/Tgstation.Server.Host/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "dotnet-ef": { - "version": "6.0.8", + "version": "6.0.15", "commands": [ "dotnet-ef" ] diff --git a/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs b/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs index 1ae2809a75..04c168dd7a 100644 --- a/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs @@ -6,6 +6,7 @@ using Elastic.CommonSchema.Serilog; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; + using Serilog; using Serilog.Configuration; using Serilog.Sinks.Elasticsearch; @@ -82,10 +83,10 @@ namespace Tgstation.Server.Host.Extensions .WriteTo .Async(sinkConfiguration => { - sinkConfiguration.Console( - outputTemplate: "[{Timestamp:HH:mm:ss}] {Level:w3}: {SourceContext:l} " + var template = "[{Timestamp:HH:mm:ss}] {Level:w3}: {SourceContext:l} " + SerilogContextTemplate - + "|IR:{InstanceReference}){NewLine} {Message:lj}{NewLine}{Exception}"); + + "|IR:{InstanceReference}){NewLine} {Message:lj}{NewLine}{Exception}"; + sinkConfiguration.Console(outputTemplate: template, formatProvider: CultureInfo.InvariantCulture); sinkConfigurationAction?.Invoke(sinkConfiguration); }); diff --git a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj index 0b38eb0c60..f10673f97a 100644 --- a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj +++ b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj @@ -68,39 +68,39 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - + - - - + + + - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - + - + diff --git a/tests/Tgstation.Server.Api.Tests/Tgstation.Server.Api.Tests.csproj b/tests/Tgstation.Server.Api.Tests/Tgstation.Server.Api.Tests.csproj index 1261f90b16..101deff1ef 100644 --- a/tests/Tgstation.Server.Api.Tests/Tgstation.Server.Api.Tests.csproj +++ b/tests/Tgstation.Server.Api.Tests/Tgstation.Server.Api.Tests.csproj @@ -8,14 +8,14 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + diff --git a/tests/Tgstation.Server.Client.Tests/Tgstation.Server.Client.Tests.csproj b/tests/Tgstation.Server.Client.Tests/Tgstation.Server.Client.Tests.csproj index 199af48d0d..ce4a0b2d71 100644 --- a/tests/Tgstation.Server.Client.Tests/Tgstation.Server.Client.Tests.csproj +++ b/tests/Tgstation.Server.Client.Tests/Tgstation.Server.Client.Tests.csproj @@ -8,14 +8,14 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + diff --git a/tests/Tgstation.Server.Host.Console.Tests/Tgstation.Server.Host.Console.Tests.csproj b/tests/Tgstation.Server.Host.Console.Tests/Tgstation.Server.Host.Console.Tests.csproj index 824e107ec6..af8cc25ccb 100644 --- a/tests/Tgstation.Server.Host.Console.Tests/Tgstation.Server.Host.Console.Tests.csproj +++ b/tests/Tgstation.Server.Host.Console.Tests/Tgstation.Server.Host.Console.Tests.csproj @@ -8,14 +8,14 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + diff --git a/tests/Tgstation.Server.Host.Service.Tests/TestServerService.cs b/tests/Tgstation.Server.Host.Service.Tests/TestServerService.cs index 7c16af5646..a01c4b5181 100644 --- a/tests/Tgstation.Server.Host.Service.Tests/TestServerService.cs +++ b/tests/Tgstation.Server.Host.Service.Tests/TestServerService.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using System; @@ -19,11 +19,9 @@ namespace Tgstation.Server.Host.Service.Tests [TestMethod] public void TestConstructionAndDisposal() { - Assert.ThrowsException(() => new ServerService(null, null, default)); - var mockWatchdogFactory = new Mock(); - Assert.ThrowsException(() => new ServerService(mockWatchdogFactory.Object, null, default)); - var mockLoggerFactory = new LoggerFactory(); - new ServerService(mockWatchdogFactory.Object, mockLoggerFactory, default).Dispose(); + Assert.ThrowsException(() => new ServerService(null, default)); + var mockLoggingBuilder = Mock.Of(); + new ServerService(mockLoggingBuilder, default).Dispose(); } [TestMethod] @@ -37,18 +35,16 @@ namespace Tgstation.Server.Host.Service.Tests var args = Array.Empty(); CancellationToken cancellationToken; mockWatchdog.Setup(x => x.RunAsync(false, args, It.IsAny())).Callback((bool x, string[] _, CancellationToken token) => cancellationToken = token).Returns(Task.CompletedTask).Verifiable(); - var mockWatchdogFactory = new Mock(); - var mockLoggerFactory = new LoggerFactory(); - mockWatchdogFactory.Setup(x => x.CreateWatchdog(mockLoggerFactory)).Returns(mockWatchdog.Object).Verifiable(); + var mockLoggerFactory = Mock.Of(); - using (var service = new ServerService(mockWatchdogFactory.Object, mockLoggerFactory, default)) + using (var service = new ServerService(mockLoggerFactory, default)) { + Assert.ThrowsException(() => onStart.Invoke(service, new object[] { args })); + service.SetupWatchdog(mockWatchdog.Object); onStart.Invoke(service, new object[] { args }); onStop.Invoke(service, Array.Empty()); mockWatchdog.VerifyAll(); } - - mockWatchdogFactory.VerifyAll(); } } } diff --git a/tests/Tgstation.Server.Host.Service.Tests/Tgstation.Server.Host.Service.Tests.csproj b/tests/Tgstation.Server.Host.Service.Tests/Tgstation.Server.Host.Service.Tests.csproj index e167d80c15..6f7e285f04 100644 --- a/tests/Tgstation.Server.Host.Service.Tests/Tgstation.Server.Host.Service.Tests.csproj +++ b/tests/Tgstation.Server.Host.Service.Tests/Tgstation.Server.Host.Service.Tests.csproj @@ -13,13 +13,14 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + + diff --git a/tests/Tgstation.Server.Host.Tests.Signals/Tgstation.Server.Host.Tests.Signals.csproj b/tests/Tgstation.Server.Host.Tests.Signals/Tgstation.Server.Host.Tests.Signals.csproj index 5443e844ce..3264033b5e 100644 --- a/tests/Tgstation.Server.Host.Tests.Signals/Tgstation.Server.Host.Tests.Signals.csproj +++ b/tests/Tgstation.Server.Host.Tests.Signals/Tgstation.Server.Host.Tests.Signals.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/tests/Tgstation.Server.Host.Tests/Tgstation.Server.Host.Tests.csproj b/tests/Tgstation.Server.Host.Tests/Tgstation.Server.Host.Tests.csproj index 84ed7d5882..268d2a524d 100644 --- a/tests/Tgstation.Server.Host.Tests/Tgstation.Server.Host.Tests.csproj +++ b/tests/Tgstation.Server.Host.Tests/Tgstation.Server.Host.Tests.csproj @@ -8,14 +8,14 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + diff --git a/tests/Tgstation.Server.Host.Watchdog.Tests/Tgstation.Server.Host.Watchdog.Tests.csproj b/tests/Tgstation.Server.Host.Watchdog.Tests/Tgstation.Server.Host.Watchdog.Tests.csproj index 6598062bed..e3e7216124 100644 --- a/tests/Tgstation.Server.Host.Watchdog.Tests/Tgstation.Server.Host.Watchdog.Tests.csproj +++ b/tests/Tgstation.Server.Host.Watchdog.Tests/Tgstation.Server.Host.Watchdog.Tests.csproj @@ -14,14 +14,14 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + diff --git a/tests/Tgstation.Server.Tests/IntegrationTest.cs b/tests/Tgstation.Server.Tests/IntegrationTest.cs index 09e7592142..592d6da6a6 100644 --- a/tests/Tgstation.Server.Tests/IntegrationTest.cs +++ b/tests/Tgstation.Server.Tests/IntegrationTest.cs @@ -152,7 +152,7 @@ namespace Tgstation.Server.Tests Assert.AreEqual(1, serverInformation.SwarmServers.Count); var controller = serverInformation.SwarmServers.SingleOrDefault(x => x.Identifier == "controller"); Assert.IsNotNull(controller); - Assert.AreEqual(controller.Address, "http://localhost:5011"); + Assert.AreEqual(controller.Address, new Uri("http://localhost:5011")); Assert.IsTrue(controller.Controller); } @@ -270,17 +270,17 @@ namespace Tgstation.Server.Tests var node1 = serverInformation.SwarmServers.SingleOrDefault(x => x.Identifier == "node1"); Assert.IsNotNull(node1); - Assert.AreEqual(node1.Address, "http://localhost:5012"); + Assert.AreEqual(node1.Address, new Uri("http://localhost:5012")); Assert.IsFalse(node1.Controller); var node2 = serverInformation.SwarmServers.SingleOrDefault(x => x.Identifier == "node2"); Assert.IsNotNull(node2); - Assert.AreEqual(node2.Address, "http://localhost:5013"); + Assert.AreEqual(node2.Address, new Uri("http://localhost:5013")); Assert.IsFalse(node2.Controller); var controller = serverInformation.SwarmServers.SingleOrDefault(x => x.Identifier == "controller"); Assert.IsNotNull(controller); - Assert.AreEqual(controller.Address, "http://localhost:5011"); + Assert.AreEqual(controller.Address, new Uri("http://localhost:5011")); Assert.IsTrue(controller.Controller); } @@ -483,17 +483,17 @@ namespace Tgstation.Server.Tests var node1 = serverInformation.SwarmServers.SingleOrDefault(x => x.Identifier == "node1"); Assert.IsNotNull(node1); - Assert.AreEqual(node1.Address, "http://localhost:5012"); + Assert.AreEqual(node1.Address, new Uri("http://localhost:5012")); Assert.IsFalse(node1.Controller); var node2 = serverInformation.SwarmServers.SingleOrDefault(x => x.Identifier == "node2"); Assert.IsNotNull(node2); - Assert.AreEqual(node2.Address, "http://localhost:5013"); + Assert.AreEqual(node2.Address, new Uri("http://localhost:5013")); Assert.IsFalse(node2.Controller); var controller = serverInformation.SwarmServers.SingleOrDefault(x => x.Identifier == "controller"); Assert.IsNotNull(controller); - Assert.AreEqual(controller.Address, "http://localhost:5011"); + Assert.AreEqual(controller.Address, new Uri("http://localhost:5011")); Assert.IsTrue(controller.Controller); } diff --git a/tests/Tgstation.Server.Tests/Tgstation.Server.Tests.csproj b/tests/Tgstation.Server.Tests/Tgstation.Server.Tests.csproj index 4c31c1b3c0..6e95c2cd3c 100644 --- a/tests/Tgstation.Server.Tests/Tgstation.Server.Tests.csproj +++ b/tests/Tgstation.Server.Tests/Tgstation.Server.Tests.csproj @@ -1,4 +1,4 @@ - + @@ -8,14 +8,14 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + diff --git a/tools/ReleaseNotes/Program.cs b/tools/ReleaseNotes/Program.cs index 89ed7a56ae..12e9dbe647 100644 --- a/tools/ReleaseNotes/Program.cs +++ b/tools/ReleaseNotes/Program.cs @@ -75,7 +75,6 @@ namespace ReleaseNotes Task milestoneTask = null; var milestoneTaskLock = new object(); var releaseDictionary = new Dictionary>>(StringComparer.OrdinalIgnoreCase); - var authorizedUsers = new Dictionary>(); bool postControlPanelMessage = false; @@ -111,44 +110,13 @@ namespace ReleaseNotes // if (!fullPR.Merged) //return; - async Task BuildNotesFromComment(string comment, User user) + void BuildNotesFromComment(string comment, User user) { if (comment == null) return; - async Task CommitNotes(string component, List notes) + void CommitNotes(string component, List notes) { - Task authTask; - TaskCompletionSource ourTcs = null; - lock (authorizedUsers) - { - if (!authorizedUsers.TryGetValue(user.Id, out authTask)) - { - ourTcs = new TaskCompletionSource(); - authTask = ourTcs.Task; - authorizedUsers.Add(user.Id, authTask); - } - } - - if (ourTcs != null) - try - { - //check if the user has access - var perm = String.IsNullOrWhiteSpace(githubToken) - ? PermissionLevel.Write - : (await client.Repository.Collaborator.ReviewPermission(RepoOwner, RepoName, user.Login).ConfigureAwait(false)).Permission; - ourTcs.SetResult(perm == PermissionLevel.Write || perm == PermissionLevel.Admin); - } - catch - { - ourTcs.SetResult(false); - throw; - } - - var authorized = await authTask.ConfigureAwait(false); - if (!authorized) - return; - lock (releaseDictionary) { foreach (var I in notes) @@ -180,7 +148,7 @@ namespace ReleaseNotes } if (trimmedLine.StartsWith("/:cl:", StringComparison.Ordinal)) { - await CommitNotes(targetComponent, notes); + CommitNotes(targetComponent, notes); targetComponent = null; notes.Clear(); continue; @@ -193,7 +161,9 @@ namespace ReleaseNotes } var comments = await client.Issue.Comment.GetAllForIssue(RepoOwner, RepoName, fullPR.Number).ConfigureAwait(false); - await Task.WhenAll(BuildNotesFromComment(fullPR.Body, fullPR.User), Task.WhenAll(comments.Select(x => BuildNotesFromComment(x.Body, x.User)))).ConfigureAwait(false); + BuildNotesFromComment(fullPR.Body, fullPR.User); + foreach(var x in comments) + BuildNotesFromComment(x.Body, x.User); } var tasks = new List(); diff --git a/tools/ReleaseNotes/ReleaseNotes.csproj b/tools/ReleaseNotes/ReleaseNotes.csproj index c366f54023..ce9d33e372 100644 --- a/tools/ReleaseNotes/ReleaseNotes.csproj +++ b/tools/ReleaseNotes/ReleaseNotes.csproj @@ -8,7 +8,7 @@ - +