From 67d1e21bb67fb5dffbb78372b588ce3044326ef7 Mon Sep 17 00:00:00 2001 From: Gleb Date: Wed, 10 Jul 2024 19:11:53 +0100 Subject: [PATCH] Unit tests in Github Action --- .config/dotnet-tools.json | 2 +- .github/workflows/build-master.yml | 45 +++++++++++++++---- RbfxTemplate.Tests/SampleUnitTestFixture.cs | 2 +- .../SimpleHeadlessApplication.cs | 1 + RbfxTemplate/UrhoApplication.cs | 3 +- 5 files changed, 41 insertions(+), 12 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 73d4929..7cb7955 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "ezpipeline": { - "version": "0.0.44", + "version": "0.0.45", "commands": [ "ezpipeline" ] diff --git a/.github/workflows/build-master.yml b/.github/workflows/build-master.yml index 961167a..1a9623e 100644 --- a/.github/workflows/build-master.yml +++ b/.github/workflows/build-master.yml @@ -16,7 +16,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Restore tools run: dotnet tool restore @@ -48,9 +48,33 @@ jobs: ANDROID_VERSION: ${{ env.ANDROID_VERSION }} HAS_PLAY_KEYSTORE: ${{ env.HAS_PLAY_KEYSTORE }} + # --------------------------------------------------------------------------------------- + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 8.0.x + + - name: Restore tools + run: dotnet tool restore + + - name: Test in Debug configuration + working-directory: ./RbfxTemplate.Tests + run: dotnet test --configuration Debug --verbosity normal + + - name: Test in Release configuration + working-directory: ./RbfxTemplate.Tests + run: dotnet test --configuration Release --verbosity normal + # --------------------------------------------------------------------------------------- build_desktop: - needs: set_version + needs: [set_version, tests] runs-on: ${{ matrix.os }} strategy: matrix: @@ -83,7 +107,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Restore tools run: dotnet tool restore @@ -126,10 +150,8 @@ jobs: shell: bash # --------------------------------------------------------------------------------------- build_android: - needs: set_version + needs: [set_version, tests] runs-on: ubuntu-latest - env: - ANDROID_PACKAGENAME: "com.companyname.RbfxTemplate.android" steps: - uses: actions/checkout@v3 @@ -140,7 +162,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Restore tools run: dotnet tool restore @@ -179,6 +201,11 @@ jobs: fileName: 'googleplay.jks' encodedString: ${{ secrets.PLAY_KEYSTORE }} + - name: Extract ApplicationId from RbfxTemplate.Android.csproj + working-directory: ./RbfxTemplate.Android + run: | + dotnet tool run ezpipeline get-msbuild-property -i RbfxTemplate.Android.csproj -p ApplicationId -v ANDROID_PACKAGENAME + - name: Dotnet Publish working-directory: ./RbfxTemplate.Android run: | @@ -226,7 +253,7 @@ jobs: track: internal # --------------------------------------------------------------------------------------- build_uwp: - needs: set_version + needs: [set_version, tests] runs-on: windows-latest steps: @@ -238,7 +265,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v1.1 diff --git a/RbfxTemplate.Tests/SampleUnitTestFixture.cs b/RbfxTemplate.Tests/SampleUnitTestFixture.cs index 1dd94a1..201e21a 100644 --- a/RbfxTemplate.Tests/SampleUnitTestFixture.cs +++ b/RbfxTemplate.Tests/SampleUnitTestFixture.cs @@ -41,7 +41,7 @@ async Task TestMethod() await Assert.ThrowsAsync(TestMethod); } - [Fact] + [Fact(Skip = "This test demonstrates that async failing test handled properly")] public async Task SampleFailingTest() { await RbfxTestFramework.ToMainThreadAsync(); diff --git a/RbfxTemplate.Tests/SimpleHeadlessApplication.cs b/RbfxTemplate.Tests/SimpleHeadlessApplication.cs index 5c899ff..6a49495 100644 --- a/RbfxTemplate.Tests/SimpleHeadlessApplication.cs +++ b/RbfxTemplate.Tests/SimpleHeadlessApplication.cs @@ -19,6 +19,7 @@ public override void Setup() { base.Setup(); EngineParameters[Urho3D.EpHeadless] = true; + EngineParameters[Urho3D.EpSound] = false; } /// diff --git a/RbfxTemplate/UrhoApplication.cs b/RbfxTemplate/UrhoApplication.cs index 6018c53..9e15c33 100644 --- a/RbfxTemplate/UrhoApplication.cs +++ b/RbfxTemplate/UrhoApplication.cs @@ -119,8 +119,9 @@ public override void Stop() _pluginApplication.Ptr.UnloadPlugin(); _pluginApplication.Dispose(); } - +#if DEBUG _debugHud?.Dispose(); +#endif base.Stop(); }