Skip to content

Commit

Permalink
Merge pull request #1958 from PathogenDavid/issue-1948-fixup
Browse files Browse the repository at this point in the history
Fix test target framework issues
  • Loading branch information
glopesdev authored Aug 7, 2024
2 parents bfc8409 + cf0f86a commit 5f8e06e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 12 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/Bonsai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
release_version: ${{github.event.release.tag_name}}
workflow_dispatch_version: ${{github.event.inputs.version}}
workflow_dispatch_will_publish_packages: ${{github.event.inputs.will_publish_packages}}

# ----------------------------------------------------------------------- Build
- name: Restore
run: dotnet restore Bonsai.sln
Expand All @@ -122,9 +122,15 @@ jobs:
run: dotnet pack Bonsai.sln --no-restore --no-build --configuration ${{matrix.configuration}}

# ----------------------------------------------------------------------- Test
- name: Test
- name: Test .NET Framework 4.7.2
if: '!matrix.dummy-build'
run: dotnet test Bonsai.sln --no-restore --no-build --configuration ${{matrix.configuration}} --verbosity normal --framework net472
- name: Test .NET 8
if: '!matrix.dummy-build'
run: dotnet test Bonsai.sln --no-restore --no-build --configuration ${{matrix.configuration}} --verbosity normal
run: dotnet test Bonsai.sln --no-restore --no-build --configuration ${{matrix.configuration}} --verbosity normal --framework net8.0
- name: Test .NET 8 Windows
if: ${{!matrix.dummy-build && matrix.platform.rid == 'win-x64'}}
run: dotnet test Bonsai.sln --no-restore --no-build --configuration ${{matrix.configuration}} --verbosity normal --framework net8.0-windows

# ----------------------------------------------------------------------- Create portable zip
- name: Create portable zip
Expand Down Expand Up @@ -153,7 +159,7 @@ jobs:
id: create-installer
if: matrix.create-installer
run: msbuild /nologo /maxCpuCount Bonsai.Setup.sln /p:Configuration=${{matrix.configuration}}

# ----------------------------------------------------------------------- Collect artifacts
- name: Collect NuGet packages
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -412,7 +418,7 @@ jobs:
env:
version_file_path: tooling/CurrentVersion.props
just_released_version: ${{github.event.release.tag_name}}

# ----------------------------------------------------------------------- Commit and push changes
- name: Commit changes
if: steps.main-revision.outputs.sha == github.sha
Expand Down
2 changes: 0 additions & 2 deletions Bonsai.Core.Tests/Bonsai.Core.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsPackable>false</IsPackable>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
Expand Down
4 changes: 1 addition & 3 deletions Bonsai.Editor.Tests/Bonsai.Editor.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsPackable>false</IsPackable>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
<TargetFrameworks>net472;net8.0-windows</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="**\*.bonsai" />
Expand Down
2 changes: 0 additions & 2 deletions Bonsai.System.Tests/Bonsai.System.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsPackable>false</IsPackable>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
Expand Down
24 changes: 24 additions & 0 deletions tooling/Common.Tests.csproj.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project>
<PropertyGroup>
<!-- Common test properties -->
<IsPackable>false</IsPackable>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
</PropertyGroup>
<Target Name="VerifyTestTargetFramework" BeforeTargets="Build" Condition="'$(TargetFramework)' != ''">
<ItemGroup>
<!--
Due to limitations in `dotnet test`, tests must only target specific target frameworks which are explicitly ran by CI.
Do not add any target frameworks to this list without also updating the CI workflow.
-->
<_PermittedTestFramework Remove="*" />
<_PermittedTestFramework Include="net472" />
<_PermittedTestFramework Include="net8.0" />
<_PermittedTestFramework Include="net8.0-windows" />
</ItemGroup>
<PropertyGroup>
<_IsPermittedTestFramework>false</_IsPermittedTestFramework>
<_IsPermittedTestFramework Condition="'%(_PermittedTestFramework.Identity)' == '$(TargetFramework)'">true</_IsPermittedTestFramework>
</PropertyGroup>
<Error Condition="'$(_IsPermittedTestFramework)' != 'true'" Text="Test project targets '$(TargetFramework)', which is not permitted for test projects." />
</Target>
</Project>
4 changes: 4 additions & 0 deletions tooling/Common.csproj.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<!-- Ignore warnings about PackageLicenseUrl and PackageIconUrl, we still use them for MyGet support -->
<NoWarn>$(NoWarn);NU5125;NU5048</NoWarn>

<!-- Error when restore graph contains mismatched target frameworks -->
<WarningsAsErrors>$(WarningsAsErrors);NU1701</WarningsAsErrors>

<!-- Embed untracked sources in the PDB when building from CI -->
<EmbedUntrackedSources>false</EmbedUntrackedSources>
<EmbedUntrackedSources Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</EmbedUntrackedSources>
Expand All @@ -39,4 +42,5 @@
<DebugType Condition="'$(IsReferenceDummyBuild)' == 'true'">none</DebugType>
</PropertyGroup>
<Import Project="Versioning.props" />
<Import Project="Common.Tests.csproj.props" Condition="$(MSBuildProjectName.EndsWith('.Tests'))" />
</Project>

0 comments on commit 5f8e06e

Please sign in to comment.