Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Action to run tests on PRs #379

Merged
merged 15 commits into from
Feb 12, 2024
31 changes: 31 additions & 0 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: pr-validation

on: pull_request

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
dotnetVersion: [3.1.x, 5.x, 6.x, 7.x, 8.x]
include:
- dotnetVersion: 3.1.x
targetFramework: netcoreapp3.1
- dotnetVersion: 5.x
targetFramework: net5.0
- dotnetVersion: 6.x
targetFramework: net6.0
- dotnetVersion: 7.x
targetFramework: net7.0
- dotnetVersion: 8.x
targetFramework: net8.0
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnetVersion }}
- run: dotnet build DacFx.sln
- run: dotnet pack DacFx.sln --no-build
- run: dotnet test DacFx.sln --no-build -f ${{ matrix.targetFramework }}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<TemplateIntermediateOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)\$(MSBuildThisFileName)\sqlproject</TemplateIntermediateOutputPath>
<!-- NU5128 warns about dependencies, template package has no dependencies. -->
<NoWarn>$(NoWarn);NU5128</NoWarn>
<NoDefaultExcludes>true</NoDefaultExcludes>
</PropertyGroup>

<ItemGroup>
Expand All @@ -39,6 +40,7 @@
MatchExpression="###ASSEMBLY_VERSION###"
ReplacementText="$(PackageVersion)" />
<ItemGroup>
<Content Remove="$(TemplateIntermediateOutputPath)\**" />
<Content Include="$(TemplateIntermediateOutputPath)\**" PackagePath="content/" Pack="true" />
</ItemGroup>
</Target>
Expand Down
7 changes: 4 additions & 3 deletions test/Microsoft.Build.Sql.Tests/TestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Microsoft.Build.Sql.Tests
public static class TestUtils
{
private const string DotnetToolPathEnvironmentVariable = "DOTNET_TOOL_PATH";
private const string DotnetRootEnvironmentVariable = "DOTNET_ROOT";

/// <summary>
/// Returns the full path to the dotnet executable based on the current operating system.
Expand All @@ -18,7 +19,7 @@ public static class TestUtils
public static string GetDotnetPath()
{
string dotnetExecutable = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "dotnet.exe" : "dotnet";
string? dotnetPath = Environment.GetEnvironmentVariable(DotnetToolPathEnvironmentVariable);
string? dotnetPath = Environment.GetEnvironmentVariable(DotnetToolPathEnvironmentVariable) ?? Environment.GetEnvironmentVariable(DotnetRootEnvironmentVariable);
if (string.IsNullOrEmpty(dotnetPath))
{
// Determine OS specific dotnet installation path
Expand All @@ -28,7 +29,7 @@ public static string GetDotnetPath()
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
dotnetPath = "/usr/bin/dotnet";
dotnetPath = "/usr/share/dotnet";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Expand Down Expand Up @@ -73,4 +74,4 @@ public static void CopyDirectoryRecursive(string sourceDirectoryPath, string tar
}
}
}
}
}