Skip to content

Commit 74a823f

Browse files
committed
Fix build script and move approval test into new project
1 parent eae1ded commit 74a823f

File tree

6 files changed

+47
-17
lines changed

6 files changed

+47
-17
lines changed

Build.ps1

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ echo "build: Build started"
33
Push-Location $PSScriptRoot
44

55
if(Test-Path .\artifacts) {
6-
echo "build: Cleaning .\artifacts"
6+
Write-Output "build: Cleaning .\artifacts"
77
Remove-Item .\artifacts -Force -Recurse
88
}
99

@@ -13,23 +13,27 @@ $suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch
1313
$commitHash = $(git rev-parse --short HEAD)
1414
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
1515

16-
echo "build: Package version suffix is $suffix"
17-
echo "build: Build version suffix is $buildSuffix"
16+
Write-Output "build: Package version suffix is $suffix"
17+
Write-Output "build: Build version suffix is $buildSuffix"
1818

1919
& dotnet build --configuration Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true
2020

21-
if($LASTEXITCODE -ne 0) { exit 1 }
21+
if($LASTEXITCODE -ne 0) { throw 'build failed' }
2222

2323
if($suffix) {
2424
& dotnet pack src\Serilog.Settings.Configuration --configuration Release --no-build --no-restore -o artifacts --version-suffix=$suffix
2525
} else {
2626
& dotnet pack src\Serilog.Settings.Configuration --configuration Release --no-build --no-restore -o artifacts
2727
}
2828

29-
if($LASTEXITCODE -ne 0) { exit 2 }
29+
if($LASTEXITCODE -ne 0) { throw 'pack failed' }
3030

3131
Write-Output "build: Testing"
3232

3333
& dotnet test test\Serilog.Settings.Configuration.Tests --configuration Release --no-build --no-restore
3434

35-
if($LASTEXITCODE -ne 0) { exit 3 }
35+
if($LASTEXITCODE -ne 0) { throw 'unit tests failed' }
36+
37+
& dotnet test test\Serilog.Settings.Configuration.ApprovalTests --configuration Release --no-build --no-restore
38+
39+
if($LASTEXITCODE -ne 0) { throw 'approval tests failed' }

serilog-settings-configuration.sln

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.29709.97
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.33516.290
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4E41FD57-5FAB-4E3C-B16E-463DE98338BC}"
77
EndProject
@@ -13,11 +13,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{62D0B9
1313
Build.ps1 = Build.ps1
1414
CHANGES.md = CHANGES.md
1515
Directory.Build.props = Directory.Build.props
16+
global.json = global.json
1617
assets\icon.png = assets\icon.png
1718
LICENSE = LICENSE
1819
README.md = README.md
1920
serilog-settings-configuration.sln.DotSettings = serilog-settings-configuration.sln.DotSettings
20-
global.json = global.json
2121
EndProjectSection
2222
EndProject
2323
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{D551DCB0-7771-4D01-BEBD-F7B57D1CF0E3}"
@@ -32,6 +32,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample", "sample\Sample\Sam
3232
EndProject
3333
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestDummies", "test\TestDummies\TestDummies.csproj", "{B7CF5068-DD19-4868-A268-5280BDE90361}"
3434
EndProject
35+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Settings.Configuration.ApprovalTests", "test\Serilog.Settings.Configuration.ApprovalTests\Serilog.Settings.Configuration.ApprovalTests.csproj", "{4AB826F2-925E-4A65-80B9-0097B05AA926}"
36+
EndProject
3537
Global
3638
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3739
Debug|Any CPU = Debug|Any CPU
@@ -54,6 +56,10 @@ Global
5456
{B7CF5068-DD19-4868-A268-5280BDE90361}.Debug|Any CPU.Build.0 = Debug|Any CPU
5557
{B7CF5068-DD19-4868-A268-5280BDE90361}.Release|Any CPU.ActiveCfg = Release|Any CPU
5658
{B7CF5068-DD19-4868-A268-5280BDE90361}.Release|Any CPU.Build.0 = Release|Any CPU
59+
{4AB826F2-925E-4A65-80B9-0097B05AA926}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
60+
{4AB826F2-925E-4A65-80B9-0097B05AA926}.Debug|Any CPU.Build.0 = Debug|Any CPU
61+
{4AB826F2-925E-4A65-80B9-0097B05AA926}.Release|Any CPU.ActiveCfg = Release|Any CPU
62+
{4AB826F2-925E-4A65-80B9-0097B05AA926}.Release|Any CPU.Build.0 = Release|Any CPU
5763
EndGlobalSection
5864
GlobalSection(SolutionProperties) = preSolution
5965
HideSolutionNode = FALSE
@@ -63,6 +69,7 @@ Global
6369
{F793C6E8-C40A-4018-8884-C97E2BE38A54} = {D551DCB0-7771-4D01-BEBD-F7B57D1CF0E3}
6470
{A00E5E32-54F9-401A-BBA1-2F6FCB6366CD} = {D24872B9-57F3-42A7-BC8D-F9DA222FCE1B}
6571
{B7CF5068-DD19-4868-A268-5280BDE90361} = {D551DCB0-7771-4D01-BEBD-F7B57D1CF0E3}
72+
{4AB826F2-925E-4A65-80B9-0097B05AA926} = {D551DCB0-7771-4D01-BEBD-F7B57D1CF0E3}
6673
EndGlobalSection
6774
GlobalSection(ExtensibilityGlobals) = postSolution
6875
SolutionGuid = {485F8843-42D7-4267-B5FB-20FE9181DEE9}

test/Serilog.Settings.Configuration.Tests/ApiApprovalTests.cs renamed to test/Serilog.Settings.Configuration.ApprovalTests/ApiApprovalTests.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
#if NET7_0
2-
31
using PublicApiGenerator;
2+
using Serilog.Settings.Configuration;
43
using Shouldly;
5-
6-
namespace Serilog.Settings.Configuration.Tests;
4+
using Xunit;
75

86
public class ApiApprovalTests
97
{
@@ -18,8 +16,11 @@ public void PublicApi_Should_Not_Change_Unintentionally()
1816
ExcludeAttributes = new[] { "System.Diagnostics.DebuggerDisplayAttribute" },
1917
});
2018

21-
publicApi.ShouldMatchApproved(options => options.WithFilenameGenerator((_, _, fileType, fileExtension) => $"{assembly.GetName().Name!}.{fileType}.{fileExtension}"));
19+
publicApi.ShouldMatchApproved(options =>
20+
{
21+
// Comment this line out to view the failure as a diff. Leave it here so that CI builds don't hang when this test fails.
22+
options.NoDiff();
23+
options.WithFilenameGenerator((_, _, fileType, fileExtension) => $"{assembly.GetName().Name!}.{fileType}.{fileExtension}");
24+
});
2225
}
2326
}
24-
25-
#endif
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
9+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" PrivateAssets="all" />
10+
<PackageReference Include="xunit" Version="2.4.2" />
11+
<PackageReference Include="Shouldly" Version="4.1.0" />
12+
<PackageReference Include="PublicApiGenerator" Version="11.0.0" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<ProjectReference Include="..\..\src\Serilog.Settings.Configuration\Serilog.Settings.Configuration.csproj" />
17+
</ItemGroup>
18+
19+
</Project>

test/Serilog.Settings.Configuration.Tests/Serilog.Settings.Configuration.Tests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
2424
<PackageReference Include="xunit" Version="2.4.2" />
2525
<PackageReference Include="Shouldly" Version="4.1.0" />
26-
<PackageReference Include="PublicApiGenerator" Version="11.0.0" />
2726
</ItemGroup>
2827

2928
<ItemGroup>

0 commit comments

Comments
 (0)