From 3215aefbbfff44916369ca626e1f23ef20bcfdc7 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 13 May 2020 13:01:23 -0400 Subject: [PATCH 1/6] Change dox generation to a travis job --- .travis.yml | 23 ++++++++++++++++++----- appveyor.yml | 5 +---- build/BuildDox.ps1 | 42 ------------------------------------------ build/build_dox.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 51 deletions(-) delete mode 100644 build/BuildDox.ps1 create mode 100755 build/build_dox.sh diff --git a/.travis.yml b/.travis.yml index fdf2ca5900..38e1a220ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,15 @@ branches: jobs: include: - env: + - DoxGeneration=true + name: "Dox Generation" + addons: + apt: + packages: + - doxygen + - graphviz + - env: + - DoxGeneration=false - DockerBuild=false - DMAPI=true - BYOND_MAJOR="513" @@ -28,6 +37,7 @@ jobs: - libc6-i386 - libstdc++6:i386 - env: + - DoxGeneration=false - DockerBuild=false - DMAPI=false - CONFIG=Debug @@ -46,6 +56,7 @@ jobs: - libc6-i386 - libstdc++6:i386 - env: + - DoxGeneration=false - DockerBuild=false - DMAPI=false - CONFIG=Release @@ -64,16 +75,18 @@ jobs: - libc6-i386 - libstdc++6:i386 - env: + - DoxGeneration=false - DockerBuild=true name: "Docker Build" services: - docker install: - - if [ $DockerBuild = false ] && [ $DMAPI = true ]; then build/install_byond.sh; fi - - if [ $DockerBuild = false ] && [ $DMAPI = false ]; then dotnet restore tgstation-server.sln; fi + - if [ $DoxGeneration = false ] && [ $DockerBuild = false ] && [ $DMAPI = true ]; then build/install_byond.sh; fi + - if [ $DoxGeneration = false ] && [ $DockerBuild = false ] && [ $DMAPI = false ]; then dotnet restore tgstation-server.sln; fi script: - - if [ $DockerBuild = false ] && [ $DMAPI = true ]; then tests/DMAPI/BasicOperation/build_byond.sh || travis_terminate 1; fi - - if [ $DockerBuild = false ] && [ $DMAPI = false ]; then build/test_core.sh; fi - - if [ $DockerBuild = true ]; then docker build . -f build/Dockerfile; fi + - if [ $DoxGeneration = false ] && [ $DockerBuild = false ] && [ $DMAPI = true ]; then tests/DMAPI/BasicOperation/build_byond.sh || travis_terminate 1; fi + - if [ $DoxGeneration = false ] && [ $DockerBuild = false ] && [ $DMAPI = false ]; then build/test_core.sh; fi + - if [ $DoxGeneration = false ] && [ $DockerBuild = true ]; then docker build . -f build/Dockerfile; fi + - if [ $DoxGeneration = true ]; then build/build_dox.sh; fi diff --git a/appveyor.yml b/appveyor.yml index eda65fa50a..be9b44d4fb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -36,9 +36,7 @@ artifacts: name: ServerUpdatePackage - path: src/DMAPI name: DMAPI - - path: tgsdox - name: DocumentationHtml - - path: swagger.json + - path: C:/swagger.json name: SwaggerSpec cache: - ~\.nuget\packages -> **\*.csproj @@ -82,7 +80,6 @@ test_script: - lint-openapi -p -c build/OpenApiValidationSettings.json C:/swagger.json after_test: - ps: build/UploadCoverage.ps1 - - ps: build/BuildDox.ps1 #host updater - dotnet publish src/Tgstation.Server.Host/Tgstation.Server.Host.csproj -o artifacts/ServerHost -c %CONFIGURATION% #console diff --git a/build/BuildDox.ps1 b/build/BuildDox.ps1 deleted file mode 100644 index 4e0b4dcf13..0000000000 --- a/build/BuildDox.ps1 +++ /dev/null @@ -1,42 +0,0 @@ -$bf = $Env:APPVEYOR_BUILD_FOLDER - -$doxdir = "C:\tgsdox" - -New-Item -Path $doxdir -ItemType directory - -$publish_dox = (-not (Test-Path Env:APPVEYOR_PULL_REQUEST_NUMBER)) -and ("$Env:APPVEYOR_REPO_BRANCH" -eq "master") - -if($publish_dox){ - $github_url = "github.com/$Env:APPVEYOR_REPO_NAME" - echo "Cloning https://git@$github_url..." - git clone -b gh-pages --single-branch "https://git@$github_url" "$doxdir" 2>$null - rm -r "$doxdir\*" -} - -Add-Content "$bf\docs\Doxyfile" "`nPROJECT_NUMBER = $version`nINPUT = $bf`nOUTPUT_DIRECTORY = $doxdir`nPROJECT_LOGO = $bf/build/tgs.ico`nHAVE_DOT=YES" - -&"C:\Program Files\doxygen\bin\doxygen.exe" "$bf\docs\Doxyfile" - -if($publish_dox){ - cd $doxdir - git config --global push.default simple - git config user.name "tgstation-server" - git config user.email "tgstation-server@tgstation13.org" - echo '# THIS BRANCH IS AUTO GENERATED BY APPVEYOR CI' > README.md - - # Add in the swagger specification - cp C:/swagger.json "$doxdir/swagger.json" - - # Need to create a .nojekyll file to allow filenames starting with an underscore - # to be seen on the gh-pages site. Therefore creating an empty .nojekyll file. - echo "" > .nojekyll - git add --all - git commit -m "Deploy code docs to GitHub Pages for Appveyor build $Env:APPVEYOR_BUILD_NUMBER" -m "Commit: $Env:APPVEYOR_REPO_COMMIT" - git push -f "https://$Env:TGS4_TEST_GITHUB_TOKEN@$github_url" 2>&1 | out-null - cd "$bf" - rm -r "$doxdir/.git" -} -mv C:/tgsdox "$bf/tgsdox" - -# Add in the swagger specification -cp C:/swagger.json "$bf/swagger.json" diff --git a/build/build_dox.sh b/build/build_dox.sh new file mode 100755 index 0000000000..3091c8e17b --- /dev/null +++ b/build/build_dox.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +BUILD_FOLDER=$TRAVIS_BUILD_DIR + +DOXDIR=~/tgsdox + +mkdir -p $DOXDIR + +if [ "$TRAVIS_PULL_REQUEST" -eq "$false" ] && [ "$TRAVIS_BRANCH" -eq "master" ]; then + PUBLISH_DOX=true +else + PUBLISH_DOX=false +fi + +if [ "$PUBLISH_DOX" = true ] ; then + GITHUB_URL="github.com/$TRAVIS_PULL_REQUEST_SLUG" + echo "Cloning https://git@$GITHUB_URL..." + git clone -b gh-pages --single-branch "https://git@$GITHUB_URL" "$DOXDIR" 2> /dev/null + rm -r "$DOXDIR\*" +fi + +VERSION=cat "$BUILD_FOLDER/build/Version.props" | grep -oPm1 "(?<=)[^<]+" + +echo -e "\nPROJECT_NUMBER = $VERSION\nINPUT = $BUILD_FOLDER\nOUTPUT_DIRECTORY = $DOXDIR\nPROJECT_LOGO = $BUILD_FOLDER/build/tgs.ico\nHAVE_DOT=YES" >> "$BUILD_FOLDER/docs/Doxyfile" + +doxygen "$BUILD_FOLDER/docs/Doxyfile" + +if [ "$PUBLISH_DOX" = true ] ; then + cd $DOXDIR + git config --global push.default simple + git config user.name "tgstation-server" + git config user.email "tgstation-server@tgstation13.org" + echo '# THIS BRANCH IS AUTO GENERATED BY APPVEYOR CI' > README.md + + # Need to create a .nojekyll file to allow filenames starting with an underscore + # to be seen on the gh-pages site. Therefore creating an empty .nojekyll file. + echo "" > .nojekyll + git add --all + git commit -m "Deploy code docs to GitHub Pages for Travis build $TRAVIS_BUILD_NUMBER" -m "Commit: $TRAVIS_COMMIT" + git push -f "https://$TGS4_TEST_GITHUB_TOKEN@$GITHUB_URL" 2>&1 | out-null + cd "$BUILD_FOLDER" + rm -r "$DOXDIR/.git" +fi + +mv $DOXDIR "$BUILD_FOLDER/tgsdox" From 2f66248c593508b0d4b953aec5f09dd09b0e9fa2 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 13 May 2020 13:36:24 -0400 Subject: [PATCH 2/6] Remove spurious discord test --- .../Tgstation.Server.Tests/IntegrationTest.cs | 54 ------------------- 1 file changed, 54 deletions(-) diff --git a/tests/Tgstation.Server.Tests/IntegrationTest.cs b/tests/Tgstation.Server.Tests/IntegrationTest.cs index 5ce60d7749..060f70d322 100644 --- a/tests/Tgstation.Server.Tests/IntegrationTest.cs +++ b/tests/Tgstation.Server.Tests/IntegrationTest.cs @@ -25,59 +25,6 @@ namespace Tgstation.Server.Tests { readonly IServerClientFactory clientFactory = new ServerClientFactory(new ProductHeaderValue(Assembly.GetExecutingAssembly().GetName().Name, Assembly.GetExecutingAssembly().GetName().Version.ToString())); - static string RequireDiscordToken() - { - var discordToken = Environment.GetEnvironmentVariable("TGS4_TEST_DISCORD_TOKEN"); - if (String.IsNullOrWhiteSpace(discordToken)) - Assert.Inconclusive("The TGS4_TEST_DISCORD_TOKEN environment variable must be set to run this test!"); - - return discordToken; - } - - [TestMethod] - public async Task TestAutomaticDiscordReconnection() - { - var discordToken = RequireDiscordToken(); - - using var discordProvider = new DiscordProvider(Mock.Of>(), discordToken, 1); - var connectResult = await discordProvider.Connect(default).ConfigureAwait(false); - Assert.IsTrue(connectResult, "Failed to connect to discord!"); - Assert.IsTrue(discordProvider.Connected, "Discord provider is not connected!"); - - // Forcefully close the connection under the provider's nose - // This will be detected in real life scenarios - DiscordSocketClient socketClient = typeof(DiscordProvider) - .GetField("client", BindingFlags.Instance | BindingFlags.NonPublic) - ?.GetValue(discordProvider) - as DiscordSocketClient; - Assert.IsNotNull(socketClient, "Reflection unable to read discord socket client!"); - - await socketClient.LogoutAsync().ConfigureAwait(false); - - Assert.IsFalse(discordProvider.Connected, "Discord provider is still connected!"); - - try - { - using CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(70)); - do - { - var message = await discordProvider.NextMessage(cts.Token).ConfigureAwait(false); - if (message == null) - break; - } - while (true); - - // Prevents a deadlock coming from having the NextMessage continuation call Dispose - await Task.Yield(); - } - catch (OperationCanceledException) - { - Assert.Fail("Failed to reconnect within the time period!"); - } - - Assert.IsTrue(discordProvider.Connected, "Discord provider not connected!"); - } - [TestMethod] public async Task TestServerUpdate() { @@ -153,7 +100,6 @@ namespace Tgstation.Server.Tests [TestMethod] public async Task TestFullStandardOperation() { - RequireDiscordToken(); using var server = new TestingServer(clientFactory); using var serverCts = new CancellationTokenSource(); var cancellationToken = serverCts.Token; From 7b12e8598d60a6c5ed85822a8c1a005f9a64dc90 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 13 May 2020 14:08:02 -0400 Subject: [PATCH 3/6] Why can't appveyor artifacts accept absolute paths --- appveyor.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index be9b44d4fb..2a05e6eead 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -36,7 +36,7 @@ artifacts: name: ServerUpdatePackage - path: src/DMAPI name: DMAPI - - path: C:/swagger.json + - path: swagger.json name: SwaggerSpec cache: - ~\.nuget\packages -> **\*.csproj @@ -79,6 +79,7 @@ test_script: - ps: $wc.UploadFile("https://ci.appveyor.com/api/testresults/mstest/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\tests\Tgstation.Server.Tests\TestResults\results.trx)) - lint-openapi -p -c build/OpenApiValidationSettings.json C:/swagger.json after_test: + - ps: Move-Item -path C:/swagger.json swagger.json - ps: build/UploadCoverage.ps1 #host updater - dotnet publish src/Tgstation.Server.Host/Tgstation.Server.Host.csproj -o artifacts/ServerHost -c %CONFIGURATION% From 3cd5ee0125df68c06d0abe924e92240471034be5 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 13 May 2020 14:33:25 -0400 Subject: [PATCH 4/6] Drop the debug configuration from appveyor Remove all DEBUG conditionals --- appveyor.yml | 1 - .../Watchdog.cs | 37 ++++++++++--------- .../Extensions/ServiceCollectionExtensions.cs | 6 +-- .../Setup/SetupWizard.cs | 2 - 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 2a05e6eead..e91ac3db7d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,7 +24,6 @@ branches: skip_tags: true image: Visual Studio 2019 configuration: - - Debug - Release shallow_clone: true artifacts: diff --git a/src/Tgstation.Server.Host.Watchdog/Watchdog.cs b/src/Tgstation.Server.Host.Watchdog/Watchdog.cs index 739fa4c73e..19e2ba2ea7 100644 --- a/src/Tgstation.Server.Host.Watchdog/Watchdog.cs +++ b/src/Tgstation.Server.Host.Watchdog/Watchdog.cs @@ -78,27 +78,30 @@ namespace Tgstation.Server.Host.Watchdog var rootLocation = Path.GetDirectoryName(executingAssembly.Location); var assemblyStoragePath = Path.Combine(rootLocation, "lib"); // always always next to watchdog -#if DEBUG - Directory.CreateDirectory(assemblyStoragePath); -#endif + var defaultAssemblyPath = Path.GetFullPath(Path.Combine(assemblyStoragePath, "Default")); -#if DEBUG - // just copy the shit where it belongs - Directory.Delete(assemblyStoragePath, true); - Directory.CreateDirectory(defaultAssemblyPath); - var sourcePath = "../../../../Tgstation.Server.Host/bin/Debug/netcoreapp3.1"; - foreach (string dirPath in Directory.GetDirectories(sourcePath, "*", SearchOption.AllDirectories)) - Directory.CreateDirectory(dirPath.Replace(sourcePath, defaultAssemblyPath)); + if (Debugger.IsAttached) + { + // VS special tactics + // just copy the shit where it belongs + Directory.Delete(assemblyStoragePath, true); + Directory.CreateDirectory(defaultAssemblyPath); - foreach (string newPath in Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories)) - File.Copy(newPath, newPath.Replace(sourcePath, defaultAssemblyPath), true); + var sourcePath = "../../../../Tgstation.Server.Host/bin/Debug/netcoreapp3.1"; + foreach (string dirPath in Directory.GetDirectories(sourcePath, "*", SearchOption.AllDirectories)) + Directory.CreateDirectory(dirPath.Replace(sourcePath, defaultAssemblyPath)); - const string AppSettingsJson = "appsettings.json"; - var rootJson = Path.Combine(rootLocation, AppSettingsJson); - File.Delete(rootJson); - File.Move(Path.Combine(defaultAssemblyPath, AppSettingsJson), rootJson); -#endif + foreach (string newPath in Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories)) + File.Copy(newPath, newPath.Replace(sourcePath, defaultAssemblyPath), true); + + const string AppSettingsJson = "appsettings.json"; + var rootJson = Path.Combine(rootLocation, AppSettingsJson); + File.Delete(rootJson); + File.Move(Path.Combine(defaultAssemblyPath, AppSettingsJson), rootJson); + } + else + Directory.CreateDirectory(assemblyStoragePath); var assemblyName = String.Join(".", nameof(Tgstation), nameof(Server), nameof(Host), "dll"); var assemblyPath = Path.Combine(defaultAssemblyPath, assemblyName); diff --git a/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs b/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs index c118826332..2e6a5d1326 100644 --- a/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs @@ -4,6 +4,7 @@ using Microsoft.Extensions.Logging; using Serilog; using Serilog.Configuration; using System; +using System.Diagnostics; using System.Globalization; using Tgstation.Server.Host.Configuration; @@ -76,9 +77,8 @@ namespace Tgstation.Server.Host.Extensions builder.AddSerilog(configuration.CreateLogger(), true); -#if DEBUG - builder.AddDebug(); -#endif + if (Debugger.IsAttached) + builder.AddDebug(); }); } } diff --git a/src/Tgstation.Server.Host/Setup/SetupWizard.cs b/src/Tgstation.Server.Host/Setup/SetupWizard.cs index 35b3bdca0e..3e5f78bb8e 100644 --- a/src/Tgstation.Server.Host/Setup/SetupWizard.cs +++ b/src/Tgstation.Server.Host/Setup/SetupWizard.cs @@ -279,7 +279,6 @@ namespace Tgstation.Server.Host.Setup /// A resulting in the input . async Task PromptDatabaseType(CancellationToken cancellationToken) { -#if !DEBUG await console.WriteAsync(String.Empty, true, cancellationToken).ConfigureAwait(false); await console.WriteAsync( "NOTE: It is HIGHLY reccommended that TGS runs on a complete relational database, specfically *NOT* Sqlite.", @@ -304,7 +303,6 @@ namespace Tgstation.Server.Host.Setup await console.WriteAsync(String.Empty, true, cancellationToken).ConfigureAwait(false); await asyncDelayer.Delay(TimeSpan.FromSeconds(3), cancellationToken).ConfigureAwait(false); -#endif await console.WriteAsync("What SQL database type will you be using?", true, cancellationToken).ConfigureAwait(false); do From 9a0c3ce0483199d5b36654ef382c4a69f3d6032f Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 13 May 2020 14:42:09 -0400 Subject: [PATCH 5/6] Don't need these anymore --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index e91ac3db7d..3ba2f056f9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -42,7 +42,7 @@ cache: services: - mssql2017 install: - - choco install doxygen.install codecov graphviz.portable opencover.portable + - choco install codecov opencover.portable - npm i -g ibm-openapi-validator - nuget restore tgstation-server.sln - ps: Install-Product node 10 From 02df113fb4fae602f7a890b2f1eb92230c661556 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 13 May 2020 14:43:36 -0400 Subject: [PATCH 6/6] Complexity increasing --- src/Tgstation.Server.Host.Watchdog/Watchdog.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Tgstation.Server.Host.Watchdog/Watchdog.cs b/src/Tgstation.Server.Host.Watchdog/Watchdog.cs index 19e2ba2ea7..caec57251d 100644 --- a/src/Tgstation.Server.Host.Watchdog/Watchdog.cs +++ b/src/Tgstation.Server.Host.Watchdog/Watchdog.cs @@ -57,6 +57,7 @@ namespace Tgstation.Server.Host.Watchdog /// #pragma warning disable CA1502 // TODO: Decomplexify + #pragma warning disable CA1506 public async Task RunAsync(bool runConfigure, string[] args, CancellationToken cancellationToken) { logger.LogInformation("Host watchdog starting..."); @@ -312,5 +313,6 @@ namespace Tgstation.Server.Host.Watchdog } } #pragma warning restore CA1502 + #pragma warning restore CA1506 } }