diff --git a/.editorconfig b/.editorconfig index d5bd5ddc..bd485f8a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,6 +7,11 @@ end_of_line = lf insert_final_newline = true charset = utf-8 +[*.yml] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + [*.cs] # General Formatting indent_style = tab diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 00000000..b4c2998a --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,140 @@ +name: Build TS3AudioBot + +on: + push: + branches: [ "master", "develop" ] + +jobs: + test_tsab: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: | + dotnet build TSLibAutogen -c Release --no-restore + dotnet build -c Release --no-restore + + - name: Test + run: dotnet test --no-build --verbosity normal + + build_frontend: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 22 + + - name: Install yarn + run: npm install -g yarn + + - name: Install dependencies + run: | + cd WebInterface + yarn install --frozen-lockfile + + - name: Build + run: | + cd WebInterface + yarn run build + + - name: Archive + uses: actions/upload-artifact@v4 + with: + name: webinterface + path: WebInterface/dist + + publish: + needs: [ test_tsab, build_frontend ] + runs-on: ubuntu-latest + strategy: + matrix: + rid: [ linux-x64, linux-arm, linux-arm64, win-x64 ] + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + - name: Publish + run: | + dotnet publish TS3AudioBot\TS3AudioBot.csproj \ + -c Release \ + --framework net8.0 \ + --self-contained \ + --runtime ${{ matrix.rid }} \ + -p:PublishSingleFile=true,IncludeNativeLibrariesForSelfExtract=true \ + -o publish + + - name: Fetch WebInterface + uses: actions/download-artifact@v4 + with: + name: webinterface + path: publish/WebInterface + + - name: Archive + uses: actions/upload-artifact@v4 + with: + name: ts3audiobot-${{ matrix.rid }} + path: publish + + - name: Install nbgv + run: dotnet tool install --global nbgv + + - name: Get Version + id: get_version + run: | + cd publish + TSABVERSION=$(nbgv get-version -p TS3AudioBot -v NuGetPackageVersion) + TSABBRANCH="${{ github.head_ref || github.ref_name }}" + TASBBUILDSUFFIX=$(echo ${{ matrix.rid }} | tr '-' '_') + echo "TSABVERSION=$TSABVERSION" >> $GITHUB_ENV + echo "TSABBRANCH=$TSABBRANCH" >> $GITHUB_ENV + echo "TASBBUILD=${TSABBRANCH}_${TASBBUILDSUFFIX}" >> $GITHUB_ENV + + - name: Upload to Splamy.de + if: startsWith(matrix.rid, 'win-') + run: | + cd publish + zip -r TS3AudioBot.zip . + curl \ + -X PUT \ + -H "Content-Type: application/zip" \ + -H "Authorization: ${{ secrets.UPLOAD_TOKEN }}" \ + --data-binary @TS3AudioBot.zip \ + "https://splamy.de/api/nightly/projects/ts3ab/${TASBBUILD}?filename=TS3AudioBot.zip&commit=${{ github.sha }}&version=${TSABVERSION}" + + - name: Upload to Splamy.de + if: startsWith(matrix.rid, 'linux-') + run: | + cd publish + chmod 755 TS3AudioBot + tar -czf TS3AudioBot.tar.gz . + curl \ + -X PUT \ + -H "Content-Type: application/gzip" \ + -H "Authorization: ${{ secrets.UPLOAD_TOKEN }}" \ + --data-binary @TS3AudioBot.tar.gz \ + "https://splamy.de/api/nightly/projects/ts3ab/${TASBBUILD}?filename=TS3AudioBot.tar.gz&commit=${{ github.sha }}&version=$TSABVERSION" diff --git a/TS3ABotUnitTests/TS3ABotUnitTests.csproj b/TS3ABotUnitTests/TS3ABotUnitTests.csproj index 88ea8145..6dab2cf2 100644 --- a/TS3ABotUnitTests/TS3ABotUnitTests.csproj +++ b/TS3ABotUnitTests/TS3ABotUnitTests.csproj @@ -11,9 +11,9 @@ - - - + + + diff --git a/TS3AudioBot/TS3AudioBot.csproj b/TS3AudioBot/TS3AudioBot.csproj index 9fec4ccf..07fadcc8 100644 --- a/TS3AudioBot/TS3AudioBot.csproj +++ b/TS3AudioBot/TS3AudioBot.csproj @@ -30,6 +30,10 @@ false false true + + + false + partial @@ -46,15 +50,16 @@ + - - Designer - + diff --git a/TSLib/Full/PacketHandler.cs b/TSLib/Full/PacketHandler.cs index 6871fa5e..0add14cd 100644 --- a/TSLib/Full/PacketHandler.cs +++ b/TSLib/Full/PacketHandler.cs @@ -165,7 +165,7 @@ private E Initialize(IPEndPoint address, bool connect) pingCheckRunning = 0; pingCheck = Tools.Now; if (resendTimer == null) - resendTimer = new Timer((_) => { using (MappedDiagnosticsLogicalContext.SetScoped("BotId", id)) ResendLoop(); }, null, ClockResolution, ClockResolution); + resendTimer = new Timer((_) => { using (ScopeContext.PushProperty("BotId", id)) ResendLoop(); }, null, ClockResolution, ClockResolution); return R.Ok; } } @@ -335,7 +335,7 @@ private static void FetchPacketEvent(object? selfObj, SocketAsyncEventArgs args) if (self is null) { Trace.Fail("SocketEvent self is null"); return; } bool isAsync; - using (MappedDiagnosticsLogicalContext.SetScoped("BotId", self.id)) + using (ScopeContext.PushProperty("BotId", self.id)) { do { diff --git a/TSLib/Helper/Tools.cs b/TSLib/Helper/Tools.cs index 3f29f279..982104f4 100644 --- a/TSLib/Helper/Tools.cs +++ b/TSLib/Helper/Tools.cs @@ -7,6 +7,7 @@ // You should have received a copy of the Open Software License along with this // program. If not, see . +using NLog; using System; using System.Collections.Generic; using System.Linq; @@ -69,7 +70,7 @@ public static T PickRandom(IReadOnlyList collection) // Generic public static void SetLogId(Id id) => SetLogId(id.ToString()); - public static void SetLogId(string id) => NLog.MappedDiagnosticsLogicalContext.Set("BotId", id); + public static void SetLogId(string id) => ScopeContext.PushProperty("BotId", id); public static Exception UnhandledDefault(T value) where T : struct { return new MissingEnumCaseException(typeof(T).Name, value.ToString() ?? string.Empty); } } diff --git a/TSLib/TSLib.csproj b/TSLib/TSLib.csproj index bd90a3ab..64f85f4c 100644 --- a/TSLib/TSLib.csproj +++ b/TSLib/TSLib.csproj @@ -2,7 +2,7 @@ Library net8.0;netstandard2.0;netstandard2.1 - 10 + 12 TSLib TSLib @@ -33,18 +33,18 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + diff --git a/TSLibAutogen/TSLibAutogen.csproj b/TSLibAutogen/TSLibAutogen.csproj index 78cabe92..a8a667d0 100644 --- a/TSLibAutogen/TSLibAutogen.csproj +++ b/TSLibAutogen/TSLibAutogen.csproj @@ -2,15 +2,15 @@ netstandard2.0 - 10 + 12 enable true enable - - + +