Skip to content

Commit

Permalink
BUild test
Browse files Browse the repository at this point in the history
  • Loading branch information
Splamy committed Jul 13, 2024
1 parent d53419c commit c09bc6b
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
140 changes: 140 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 3 additions & 3 deletions TS3ABotUnitTests/TS3ABotUnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 8 additions & 3 deletions TS3AudioBot/TS3AudioBot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>

<!-- Trimming-->
<PublishTrimmed>false</PublishTrimmed>
<TrimMode>partial</TrimMode>
</PropertyGroup>

<ItemGroup>
Expand All @@ -46,15 +50,16 @@
<PackageReference Include="Nett" Version="0.15.0" />
<PackageReference Include="PlaylistsNET" Version="1.4.1" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.4" />
<!--<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.139">
<PrivateAssets>all</PrivateAssets>
</PackageReference>-->
<TrimmerRootAssembly Include="System.Text.Json" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Resources\DefaultRights.toml" />
<EmbeddedResource Include="Media\SleepingKitty.png" />
<EmbeddedResource Include="Resources\NLog.config">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Resources\NLog.config" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions TSLib/Full/PacketHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private E<Exception> 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;
}
}
Expand Down Expand Up @@ -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
{
Expand Down
3 changes: 2 additions & 1 deletion TSLib/Helper/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// You should have received a copy of the Open Software License along with this
// program. If not, see <https://opensource.org/licenses/OSL-3.0>.

using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -69,7 +70,7 @@ public static T PickRandom<T>(IReadOnlyList<T> 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>(T value) where T : struct { return new MissingEnumCaseException(typeof(T).Name, value.ToString() ?? string.Empty); }
}
14 changes: 7 additions & 7 deletions TSLib/TSLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>net8.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<LangVersion>10</LangVersion>
<LangVersion>12</LangVersion>
<RootNamespace>TSLib</RootNamespace>
<AssemblyName>TSLib</AssemblyName>

Expand Down Expand Up @@ -33,18 +33,18 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NLog" Version="4.7.13" />
<PackageReference Include="NLog" Version="5.3.2" />
<PackageReference Include="Heijden.Dns.Portable" Version="2.0.19" />
<PackageReference Include="Nullable" Version="1.3.0">
<PackageReference Include="Nullable" Version="1.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
<PackageReference Include="Splamy.Ed25519.Toolkit" Version="1.0.3" />
<PackageReference Include="System.IO.Pipelines" Version="6.0.1" />
<PackageReference Condition="'$(TargetFramework)' == 'netstandard2.0'" Include="System.Memory" Version="4.5.4" />
<PackageReference Condition="'$(TargetFramework)' == 'netstandard2.0'" Include="System.Text.Json" Version="6.0.1" />
<PackageReference Condition="'$(TargetFramework)' == 'netstandard2.1'" Include="System.Text.Json" Version="6.0.1" />
<PackageReference Include="System.IO.Pipelines" Version="8.0.0" />
<PackageReference Condition="'$(TargetFramework)' == 'netstandard2.0'" Include="System.Memory" Version="4.5.5" />
<PackageReference Condition="'$(TargetFramework)' == 'netstandard2.0'" Include="System.Text.Json" Version="8.0.4" />
<PackageReference Condition="'$(TargetFramework)' == 'netstandard2.1'" Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>
<ItemGroup>
<None Include="ReSpeak.png" Pack="true" PackagePath="\" />
Expand Down
6 changes: 3 additions & 3 deletions TSLibAutogen/TSLibAutogen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>10</LangVersion>
<LangVersion>12</LangVersion>
<Nullable>enable</Nullable>
<IsRoslynComponent>true</IsRoslynComponent>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit c09bc6b

Please sign in to comment.