From 674a0fc5dd5181e05e32125f63117b2a1a197344 Mon Sep 17 00:00:00 2001 From: Chris Johnston Date: Fri, 28 Sep 2018 15:19:00 -0700 Subject: [PATCH 1/4] Add Ubuntu target to AppVeyor CI build (#1149) * Target Ubuntu in Appveyor CI build AppVeyor has released support for targetting Ubuntu 18.04 environments. This adds Ubuntu to the list of build images for Appveyor to use. * Set clone folder to use appveyor defaults * Check if appveyor provides appveyor-retry by trying to run it * Minor syntax change * Minor syntax change * Skip using appveyor-retry (for now) * Use forward slash for paths so that it works on both windows and linux * Implement replacement for appveyor-retry * Script cleanup * Remove commented out line * Only package releases on Windows * Add the isWindows condition to the deploy stage --- appveyor.yml | 65 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 54b9a1251..0c0c7b102 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,13 +2,17 @@ version: build-{build} branches: only: - dev -image: Visual Studio 2017 +image: +- Visual Studio 2017 +- Ubuntu nuget: disable_publish_on_pr: true pull_requests: do_not_increment_build_number: true -clone_folder: C:\Projects\Discord.Net +# Use the default clone_folder +# Windows: C:\Projects\discord-net +# Ubuntu: /home/appveyor/projects/discord-net cache: test/Discord.Net.Tests/cache.db environment: @@ -20,23 +24,50 @@ init: - ps: $Env:BUILD = "$($Env:APPVEYOR_BUILD_NUMBER.PadLeft(5, "0"))" build_script: -- ps: appveyor-retry dotnet restore Discord.Net.sln -v Minimal /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" +- ps: >- + if ($isLinux) + { + # AppVeyor Linux images do not have appveyor-retry, which retries the commands a few times + # until the command exits with code 0. + # So, this is done with a short script. + $code = 0 + $counter = 0 + do + { + dotnet restore Discord.Net.sln -v Minimal /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" + $code = $LASTEXITCODE + $counter++ + if ($code -ne 0) + { + # Wait 5s before attempting to run again + Start-sleep -Seconds 5 + } + } + until ($counter -eq 5 -or $code -eq 0) + } + else + { + appveyor-retry dotnet restore Discord.Net.sln -v Minimal /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" + } - ps: dotnet build Discord.Net.sln -c "Release" /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" after_build: -- ps: dotnet pack "src\Discord.Net.Core\Discord.Net.Core.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" -- ps: dotnet pack "src\Discord.Net.Rest\Discord.Net.Rest.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" -- ps: dotnet pack "src\Discord.Net.WebSocket\Discord.Net.WebSocket.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" -- ps: dotnet pack "src\Discord.Net.Commands\Discord.Net.Commands.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" -- ps: dotnet pack "src\Discord.Net.Webhook\Discord.Net.Webhook.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" -- ps: dotnet pack "src\Discord.Net.Providers.WS4Net\Discord.Net.Providers.WS4Net.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" -- ps: dotnet pack "src\Discord.Net.Analyzers\Discord.Net.Analyzers.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" +- ps: if ($isWindows) { dotnet pack "src\Discord.Net.Core\Discord.Net.Core.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" } +- ps: if ($isWindows) { dotnet pack "src\Discord.Net.Rest\Discord.Net.Rest.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" } +- ps: if ($isWindows) { dotnet pack "src\Discord.Net.WebSocket\Discord.Net.WebSocket.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" } +- ps: if ($isWindows) { dotnet pack "src\Discord.Net.Commands\Discord.Net.Commands.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" } +- ps: if ($isWindows) { dotnet pack "src\Discord.Net.Webhook\Discord.Net.Webhook.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" } +- ps: if ($isWindows) { dotnet pack "src\Discord.Net.Providers.WS4Net\Discord.Net.Providers.WS4Net.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" } +- ps: if ($isWindows) { dotnet pack "src\Discord.Net.Analyzers\Discord.Net.Analyzers.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" } - ps: >- - if ($Env:APPVEYOR_REPO_TAG -eq "true") { - nuget pack src\Discord.Net\Discord.Net.nuspec -OutputDirectory "artifacts" -properties suffix="" - } else { - nuget pack src\Discord.Net\Discord.Net.nuspec -OutputDirectory "artifacts" -properties suffix="-$Env:BUILD" + if ($isWindows) + { + if ($Env:APPVEYOR_REPO_TAG -eq "true") { + nuget pack src/Discord.Net/Discord.Net.nuspec -OutputDirectory "artifacts" -properties suffix="" + } else { + nuget pack src/Discord.Net/Discord.Net.nuspec -OutputDirectory "artifacts" -properties suffix="-$Env:BUILD" + } } -- ps: Get-ChildItem artifacts\*.nupkg | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } +- ps: if ($isWindows) { Get-ChildItem artifacts/*.nupkg | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } } test_script: - ps: >- @@ -52,10 +83,12 @@ deploy: symbol_server: https://www.myget.org/F/discord-net/symbols/api/v2/package on: branch: dev + isWindows: True - provider: NuGet server: https://www.myget.org/F/rogueexception/api/v2/package api_key: secure: D+vW2O2LBf/iJb4f+q8fkyIW2VdIYIGxSYLWNrOD4BHlDBZQlJipDbNarWjUr2Kn symbol_server: https://www.myget.org/F/rogueexception/symbols/api/v2/package on: - branch: dev \ No newline at end of file + branch: dev + isWindows: True From efaedac98f306e1d855f6dc6f9efb5dd99eeb554 Mon Sep 17 00:00:00 2001 From: Still Hsu <341464@gmail.com> Date: Sat, 29 Sep 2018 06:20:38 +0800 Subject: [PATCH 2/4] docs: Fix for incomplete structure sample (#1145) --- docs/guides/getting_started/samples/intro/structure.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/guides/getting_started/samples/intro/structure.cs b/docs/guides/getting_started/samples/intro/structure.cs index a9a018c3a..5165e2fdb 100644 --- a/docs/guides/getting_started/samples/intro/structure.cs +++ b/docs/guides/getting_started/samples/intro/structure.cs @@ -36,7 +36,7 @@ class Program // you must set the MessageCacheSize. You may adjust the number as needed. //MessageCacheSize = 50, - // If your platform doesn't have native websockets, + // If your platform doesn't have native WebSockets, // add Discord.Net.Providers.WS4Net from NuGet, // add the `using` at the top, and uncomment this line: //WebSocketProvider = WS4NetProvider.Instance @@ -57,7 +57,7 @@ class Program _commands.Log += Log; // Setup your DI container. - _services = ConfigureServices(), + _services = ConfigureServices(); } @@ -116,7 +116,9 @@ class Program await InitCommands(); // Login and connect. - await _client.LoginAsync(TokenType.Bot, /* */); + await _client.LoginAsync(TokenType.Bot, + // < DO NOT HARDCODE YOUR TOKEN > + Environment.GetEnvironmentVariable("DiscordToken")); await _client.StartAsync(); // Wait infinitely so your bot actually stays connected. @@ -160,7 +162,7 @@ class Program // Execute the command. (result does not indicate a return value, // rather an object stating if the command executed successfully). - var result = await _commands.ExecuteAsync(context, pos); + var result = await _commands.ExecuteAsync(context, pos, _services); // Uncomment the following lines if you want the bot // to send a message if it failed. From c898325e4594c7b0ea6455c715903c775ec42a2a Mon Sep 17 00:00:00 2001 From: Paulo Date: Fri, 28 Sep 2018 19:22:48 -0300 Subject: [PATCH 3/4] Fix GetReactionUsersAsync (#1151) --- src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs b/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs index 3dc3e74e9..30ee75c47 100644 --- a/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs +++ b/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs @@ -71,7 +71,7 @@ namespace Discord.Rest }, nextPage: (info, lastPage) => { - if (lastPage.Count != DiscordConfig.MaxUsersPerBatch) + if (lastPage.Count != DiscordConfig.MaxUserReactionsPerBatch) return false; info.Position = lastPage.Max(x => x.Id); From de4d4150533327d29bfb1200835fff6fcff8f50a Mon Sep 17 00:00:00 2001 From: Chris Johnston Date: Fri, 28 Sep 2018 18:46:05 -0700 Subject: [PATCH 4/4] Fix deploy conditions in CI script (#1157) * Fix deploy conditions in CI script The deploy conditions had been using a powershell-only variable, and not a environment variable. This meant that the deployment failed on both Windows and Linux (expected only on Linux). * Remove an extra newline * Remove Debug statements from appveyor build script --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 0c0c7b102..ef5f1667e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -83,7 +83,7 @@ deploy: symbol_server: https://www.myget.org/F/discord-net/symbols/api/v2/package on: branch: dev - isWindows: True + CI_WINDOWS: true - provider: NuGet server: https://www.myget.org/F/rogueexception/api/v2/package api_key: @@ -91,4 +91,4 @@ deploy: symbol_server: https://www.myget.org/F/rogueexception/symbols/api/v2/package on: branch: dev - isWindows: True + CI_WINDOWS: true