mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-26 22:48:20 +01:00
Merge branch 'dev' into 1205-ChannelJson
This commit is contained in:
@@ -31,7 +31,7 @@ jobs:
|
||||
run: |
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libc6-i386 libstdc++6:i386
|
||||
sudo apt-get install -y -o APT::Immediate-Configure=0 libc6-i386 libstdc++6:i386
|
||||
|
||||
- name: Install BYOND
|
||||
if: steps.cache-byond.outputs.cache-hit != 'true'
|
||||
@@ -268,12 +268,11 @@ jobs:
|
||||
needs: dmapi-build
|
||||
services: # We start all dbs here so we can just code the stuff once
|
||||
postgres:
|
||||
image: postgres
|
||||
image: cyberboss/postgres-max-connections # Fork of _/postgres:latest with max_connections=500 becuase GitHub actions service containers have no way to set command lines. Rebuilds with updates.
|
||||
ports:
|
||||
- 5432:5432
|
||||
env:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
# Set health checks to wait until postgres has started
|
||||
options: >-
|
||||
--health-cmd pg_isready
|
||||
--health-interval 10s
|
||||
@@ -315,7 +314,7 @@ jobs:
|
||||
run: |
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libc6-i386 libstdc++6:i386 gdb
|
||||
sudo apt-get install -y -o APT::Immediate-Configure=0 libc6-i386 libstdc++6:i386 gdb
|
||||
|
||||
- name: Install Node 12.X
|
||||
uses: actions/setup-node@v1
|
||||
|
||||
@@ -452,7 +452,7 @@ Should you end up with a lost database for some reason or want to reattach a det
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Feel free to ask for help at the coderbus discord in \#hosting-questions: https://discord.gg/Vh8TJp9. Cyberboss#0016 can answer most questions.
|
||||
Feel free to ask for help [on the discussions page](https://github.com/tgstation/tgstation-server/discussions).
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
return;
|
||||
}
|
||||
|
||||
logger.LogDebug("Starting swarm request processing...");
|
||||
logger.LogTrace("Starting swarm request processing...");
|
||||
await base.OnActionExecutionAsync(context, next).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Octokit;
|
||||
using Tgstation.Server.Host.Configuration;
|
||||
using Tgstation.Server.Host.System;
|
||||
|
||||
namespace Tgstation.Server.Host.Core
|
||||
@@ -12,35 +14,43 @@ namespace Tgstation.Server.Host.Core
|
||||
/// </summary>
|
||||
readonly IAssemblyInformationProvider assemblyInformationProvider;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GeneralConfiguration"/> for the <see cref="GitHubClientFactory"/>.
|
||||
/// </summary>
|
||||
readonly GeneralConfiguration generalConfiguration;
|
||||
|
||||
/// <summary>
|
||||
/// Construct a <see cref="GitHubClientFactory"/>
|
||||
/// </summary>
|
||||
/// <param name="assemblyInformationProvider">The value of <see cref="assemblyInformationProvider"/></param>
|
||||
public GitHubClientFactory(IAssemblyInformationProvider assemblyInformationProvider)
|
||||
/// <param name="assemblyInformationProvider">The value of <see cref="assemblyInformationProvider"/>.</param>
|
||||
/// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/>.</param>
|
||||
public GitHubClientFactory(IAssemblyInformationProvider assemblyInformationProvider, IOptions<GeneralConfiguration> generalConfigurationOptions)
|
||||
{
|
||||
this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
|
||||
generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a <see cref="GitHubClient"/>
|
||||
/// Create a <see cref="GitHubClient"/>.
|
||||
/// </summary>
|
||||
/// <param name="accessToken">Optional access token to use as credentials.</param>
|
||||
/// <returns>A new <see cref="GitHubClient"/></returns>
|
||||
GitHubClient CreateBaseClient() => new GitHubClient(
|
||||
new ProductHeaderValue(
|
||||
assemblyInformationProvider.ProductInfoHeaderValue.Product.Name,
|
||||
assemblyInformationProvider.ProductInfoHeaderValue.Product.Version));
|
||||
|
||||
/// <inheritdoc />
|
||||
public IGitHubClient CreateClient() => CreateBaseClient();
|
||||
|
||||
/// <inheritdoc />
|
||||
public IGitHubClient CreateClient(string accessToken)
|
||||
GitHubClient CreateClientImpl(string accessToken)
|
||||
{
|
||||
if (accessToken == null)
|
||||
throw new ArgumentNullException(nameof(accessToken));
|
||||
var result = CreateBaseClient();
|
||||
result.Credentials = new Credentials(accessToken);
|
||||
return result;
|
||||
var client = new GitHubClient(
|
||||
new ProductHeaderValue(
|
||||
assemblyInformationProvider.ProductInfoHeaderValue.Product.Name,
|
||||
assemblyInformationProvider.ProductInfoHeaderValue.Product.Version));
|
||||
if (accessToken != null)
|
||||
client.Credentials = new Credentials(accessToken);
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IGitHubClient CreateClient() => CreateClientImpl(generalConfiguration.GitHubAccessToken);
|
||||
|
||||
/// <inheritdoc />
|
||||
public IGitHubClient CreateClient(string accessToken) => CreateClientImpl(accessToken ?? throw new ArgumentNullException(nameof(accessToken)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Tgstation.Server.Host.Core
|
||||
public interface IGitHubClientFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a client with anonymous authentication or general authentica. Low rate limit. Attempts to use the server's token to bypass this.
|
||||
/// Create a <see cref="IGitHubClient"/> client. Low rate limit unless the server's GitHubAccessToken is set to bypass it.
|
||||
/// </summary>
|
||||
/// <returns>A new <see cref="IGitHubClient"/>.</returns>
|
||||
IGitHubClient CreateClient();
|
||||
|
||||
@@ -535,6 +535,11 @@ namespace Tgstation.Server.Host.Swarm
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogTrace("No need to re-initiate update as it originated here on the swarm controller");
|
||||
updateCommitTcs = new TaskCompletionSource<bool>();
|
||||
}
|
||||
|
||||
logger.LogDebug("Prepared for update to version {0}", version);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<Target Name="ClientInstall" Inputs="../../build/ControlPanelVersion.props" Outputs="$(NpmInstallStampFile)">
|
||||
<Message Text="Pulling web control panel..." Importance="high" />
|
||||
<RemoveDir Directories="ClientApp" />
|
||||
<Exec Command="git clone https://github.com/tgstation/tgstation-server-control-panel --branch v$(TgsControlPanelVersion) --depth 1 ClientApp" />
|
||||
<Exec Command="git clone https://github.com/tgstation/tgstation-server-webpanel --branch v$(TgsControlPanelVersion) --depth 1 ClientApp" />
|
||||
<Message Text="Restoring npm packages..." Importance="high" />
|
||||
<Exec WorkingDirectory="ClientApp" Command="npm ci" />
|
||||
<Touch Files="$(NpmInstallStampFile)" AlwaysCreate="true" />
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Octokit;
|
||||
using System;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Host.Configuration;
|
||||
using Tgstation.Server.Host.System;
|
||||
|
||||
namespace Tgstation.Server.Host.Core.Tests
|
||||
@@ -12,7 +14,11 @@ namespace Tgstation.Server.Host.Core.Tests
|
||||
public sealed class TestGitHubClientFactory
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestContruction() => Assert.ThrowsException<ArgumentNullException>(() => new GitHubClientFactory(null));
|
||||
public void TestContruction()
|
||||
{
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new GitHubClientFactory(Mock.Of<IAssemblyInformationProvider>(), null));
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new GitHubClientFactory(null, null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task TestCreateBasicClient()
|
||||
@@ -20,7 +26,12 @@ namespace Tgstation.Server.Host.Core.Tests
|
||||
var mockApp = new Mock<IAssemblyInformationProvider>();
|
||||
mockApp.SetupGet(x => x.ProductInfoHeaderValue).Returns(new ProductInfoHeaderValue("TGSTests", "1.2.3")).Verifiable();
|
||||
|
||||
var factory = new GitHubClientFactory(mockApp.Object);
|
||||
var mockOptions = new Mock<IOptions<GeneralConfiguration>>();
|
||||
|
||||
var gc = new GeneralConfiguration();
|
||||
Assert.IsNull(gc.GitHubAccessToken);
|
||||
mockOptions.SetupGet(x => x.Value).Returns(gc);
|
||||
var factory = new GitHubClientFactory(mockApp.Object, mockOptions.Object);
|
||||
|
||||
var client = factory.CreateClient();
|
||||
Assert.IsNotNull(client);
|
||||
@@ -28,6 +39,12 @@ namespace Tgstation.Server.Host.Core.Tests
|
||||
|
||||
Assert.AreEqual(AuthenticationType.Anonymous, credentials.AuthenticationType);
|
||||
|
||||
gc.GitHubAccessToken = "asdfasdfasdfasdfasdfasdf";
|
||||
client = factory.CreateClient();
|
||||
Assert.IsNotNull(client);
|
||||
credentials = await client.Connection.CredentialStore.GetCredentials().ConfigureAwait(false);
|
||||
|
||||
Assert.AreEqual(AuthenticationType.Oauth, credentials.AuthenticationType);
|
||||
|
||||
mockApp.VerifyAll();
|
||||
}
|
||||
@@ -38,7 +55,9 @@ namespace Tgstation.Server.Host.Core.Tests
|
||||
var mockApp = new Mock<IAssemblyInformationProvider>();
|
||||
mockApp.SetupGet(x => x.ProductInfoHeaderValue).Returns(new ProductInfoHeaderValue("TGSTests", "1.2.3")).Verifiable();
|
||||
|
||||
var factory = new GitHubClientFactory(mockApp.Object);
|
||||
var mockOptions = new Mock<IOptions<GeneralConfiguration>>();
|
||||
mockOptions.SetupGet(x => x.Value).Returns(new GeneralConfiguration());
|
||||
var factory = new GitHubClientFactory(mockApp.Object, mockOptions.Object);
|
||||
|
||||
Assert.ThrowsException<ArgumentNullException>(() => factory.CreateClient(null));
|
||||
|
||||
|
||||
@@ -91,12 +91,12 @@ namespace Tgstation.Server.Tests
|
||||
var updatedAssemblyVersion = FileVersionInfo.GetVersionInfo(updatedAssemblyPath);
|
||||
Assert.AreEqual(testUpdateVersion, Version.Parse(updatedAssemblyVersion.FileVersion).Semver());
|
||||
}
|
||||
catch (RateLimitException)
|
||||
catch (RateLimitException ex)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("TGS4_TEST_GITHUB_TOKEN")))
|
||||
throw;
|
||||
|
||||
Assert.Inconclusive("GitHub rate limit hit!");
|
||||
Assert.Inconclusive("GitHub rate limit hit: {0}", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -257,7 +257,7 @@ namespace Tgstation.Server.Tests
|
||||
await Assert.ThrowsExceptionAsync<ConflictException>(() => node1Client.Instances.GetId(controllerInstance, cancellationToken));
|
||||
|
||||
// test update
|
||||
var testUpdateVersion = new Version(4, 6, 2);
|
||||
var testUpdateVersion = new Version(4, 8, 1);
|
||||
await node1Client.Administration.Update(
|
||||
new Administration
|
||||
{
|
||||
@@ -276,11 +276,43 @@ namespace Tgstation.Server.Tests
|
||||
|
||||
var updatedAssemblyVersion = FileVersionInfo.GetVersionInfo(updatedAssemblyPath);
|
||||
Assert.AreEqual(testUpdateVersion, Version.Parse(updatedAssemblyVersion.FileVersion).Semver());
|
||||
Directory.Delete(server.UpdatePath, true);
|
||||
}
|
||||
|
||||
CheckServerUpdated(controller);
|
||||
CheckServerUpdated(node1);
|
||||
CheckServerUpdated(node2);
|
||||
|
||||
// regression: test it also works from the controller
|
||||
serverTask = Task.WhenAll(
|
||||
node1.Run(cancellationToken),
|
||||
node2.Run(cancellationToken),
|
||||
controller.Run(cancellationToken));
|
||||
|
||||
using var controllerClient2 = await CreateAdminClient(controller.Url, cancellationToken);
|
||||
using var node1Client2 = await CreateAdminClient(node1.Url, cancellationToken);
|
||||
using var node2Client2 = await CreateAdminClient(node2.Url, cancellationToken);
|
||||
|
||||
await controllerClient2.Administration.Update(
|
||||
new Administration
|
||||
{
|
||||
NewVersion = testUpdateVersion
|
||||
},
|
||||
cancellationToken);
|
||||
|
||||
await Task.WhenAny(Task.Delay(TimeSpan.FromMinutes(2)), serverTask);
|
||||
Assert.IsTrue(serverTask.IsCompleted);
|
||||
|
||||
CheckServerUpdated(controller);
|
||||
CheckServerUpdated(node1);
|
||||
CheckServerUpdated(node2);
|
||||
}
|
||||
catch (RateLimitException ex)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("TGS4_TEST_GITHUB_TOKEN")))
|
||||
throw;
|
||||
|
||||
Assert.Inconclusive("GitHub rate limit hit: {0}", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -472,6 +504,13 @@ namespace Tgstation.Server.Tests
|
||||
Assert.AreEqual(2, node2Info.SwarmServers.Count);
|
||||
Assert.IsNotNull(node2Info.SwarmServers.SingleOrDefault(x => x.Identifier == "controller"));
|
||||
}
|
||||
catch (RateLimitException ex)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("TGS4_TEST_GITHUB_TOKEN")))
|
||||
throw;
|
||||
|
||||
Assert.Inconclusive("GitHub rate limit hit: {0}", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
serverCts.Cancel();
|
||||
|
||||
@@ -263,7 +263,7 @@ namespace ReleaseNotes
|
||||
if (webControlVersion.Major == 0)
|
||||
postControlPanelMessage = true;
|
||||
|
||||
prefix = $"Please refer to the [README](https://github.com/tgstation/tgstation-server#setup) for setup instructions.{Environment.NewLine}{Environment.NewLine}#### Component Versions\nCore: {coreVersion}\nConfiguration: {configVersion}\nHTTP API: {apiVersion}\nDreamMaker API: {dmApiVersion} (Interop: {interopVersion})\n[Web Control Panel](https://github.com/tgstation/tgstation-server-control-panel): {webControlVersion}\nHost Watchdog: {hostWatchdogVersion}";
|
||||
prefix = $"Please refer to the [README](https://github.com/tgstation/tgstation-server#setup) for setup instructions.{Environment.NewLine}{Environment.NewLine}#### Component Versions\nCore: {coreVersion}\nConfiguration: {configVersion}\nHTTP API: {apiVersion}\nDreamMaker API: {dmApiVersion} (Interop: {interopVersion})\n[Web Control Panel](https://github.com/tgstation/tgstation-server-webpanel): {webControlVersion}\nHost Watchdog: {hostWatchdogVersion}";
|
||||
break;
|
||||
case 3:
|
||||
prefix = "The /tg/station server suite";
|
||||
|
||||
Reference in New Issue
Block a user