Skip to content

Commit f886e24

Browse files
committed
Use the artifacts output layout
Also remove all conditions on ContinuousIntegrationBuild in the tests and store test results and coverage files in the artifacts directory.
1 parent 5bff729 commit f886e24

File tree

6 files changed

+29
-30
lines changed

6 files changed

+29
-30
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,34 +50,34 @@ jobs:
5050
uses: actions/upload-artifact@v4
5151
if: failure()
5252
with:
53-
name: Received-${{ runner.os }}
53+
name: Received (${{ runner.os }})
5454
path: "**/*.received.*"
5555
- name: 📤 Upload test results
5656
uses: actions/upload-artifact@v4
5757
if: always()
5858
with:
59-
name: TestResults-${{ runner.os }}.trx
60-
path: "*.trx"
59+
name: Test Results (${{ runner.os }})
60+
path: artifacts/test-results
6161
- name: 📊 Test Report
6262
uses: dorny/test-reporter@v2
6363
if: always()
6464
with:
6565
name: 🚦 Test Results
66-
path: '*.trx'
66+
path: artifacts/test-results/*/*.trx
6767
reporter: dotnet-trx
6868
- name: 📤 Upload coverage report
6969
if: matrix.os == 'ubuntu-latest'
7070
uses: actions/upload-artifact@v4
7171
with:
7272
name: Coverage Report
73-
path: coverage
73+
path: artifacts/coverage
7474
- name: ☂️ Upload coverage report to Codecov
7575
env:
7676
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
7777
if: matrix.os == 'ubuntu-latest' && env.CODECOV_TOKEN != ''
7878
uses: codecov/codecov-action@v5
7979
with:
80-
files: coverage/*/coverage.cobertura.xml
80+
files: artifacts/coverage/*/coverage.cobertura.xml
8181
token: ${{ env.CODECOV_TOKEN }}
8282
- name: ☂️ Upload coverage report to Codacy
8383
env:
@@ -86,7 +86,7 @@ jobs:
8686
uses: codacy/codacy-coverage-reporter-action@v1
8787
with:
8888
project-token: ${{ env.CODACY_PROJECT_TOKEN }}
89-
coverage-reports: coverage/*/coverage.cobertura.xml
89+
coverage-reports: artifacts/coverage/*/coverage.cobertura.xml
9090
- name: 📦 Create NuGet package
9191
run: dotnet pack --no-build --output .
9292
- name: 📤 Upload NuGet package artifact

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
bin
2-
obj
3-
coverage
1+
artifacts/
42
.vs/
53
.idea/
64
*.user

Directory.Build.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project>
2+
<PropertyGroup>
3+
<UseArtifactsOutput>true</UseArtifactsOutput>
4+
</PropertyGroup>
5+
</Project>

serilog-formatting-log4net.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ProjectSection(SolutionItems) = preProject
1010
CHANGELOG.md = CHANGELOG.md
1111
CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md
1212
LICENSE = LICENSE
13+
Directory.Build.props = Directory.Build.props
1314
EndProjectSection
1415
EndProject
1516
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Formatting.Log4Net", "src\Serilog.Formatting.Log4Net.csproj", "{66DF8036-B2E9-4FD1-9204-012EE3F9A2E4}"

tests/PublicApi.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ public class PublicApi
1717
public Task ApprovePublicApi(string targetFramework)
1818
{
1919
var testAssembly = typeof(PublicApi).Assembly;
20-
var configuration = testAssembly.GetCustomAttribute<AssemblyConfigurationAttribute>()?.Configuration
20+
var configuration = testAssembly.GetCustomAttribute<AssemblyConfigurationAttribute>()?.Configuration.ToLowerInvariant()
2121
?? throw new InvalidDataException($"{nameof(AssemblyConfigurationAttribute)} not found in {testAssembly.Location}");
22-
var assemblyPath = Path.Combine(GetSrcDirectoryPath(), "bin", configuration, targetFramework, "Serilog.Formatting.Log4Net.dll");
22+
var assemblyPath = Path.Combine(GetRootDirectoryPath(), "artifacts", "bin", "Serilog.Formatting.Log4Net", $"{configuration}_{targetFramework}", "Serilog.Formatting.Log4Net.dll");
2323
var assembly = Assembly.LoadFile(assemblyPath);
2424
var publicApi = assembly.GeneratePublicApi();
2525
return Verifier.Verify(publicApi, "cs").UseFileName($"PublicApi.{targetFramework}");
2626
}
2727

28-
private static string GetSrcDirectoryPath([CallerFilePath] string path = "") => Path.Combine(Path.GetDirectoryName(path)!, "..", "src");
28+
private static string GetRootDirectoryPath([CallerFilePath] string path = "") => Path.Combine(Path.GetDirectoryName(path)!, "..");
2929

3030
private class TargetFrameworksTheoryData : TheoryData<string>
3131
{
3232
public TargetFrameworksTheoryData()
3333
{
34-
var csprojPath = Path.Combine(GetSrcDirectoryPath(), "Serilog.Formatting.Log4Net.csproj");
34+
var csprojPath = Path.Combine(GetRootDirectoryPath(), "src", "Serilog.Formatting.Log4Net.csproj");
3535
var project = XDocument.Load(csprojPath);
3636
var targetFrameworks = project.XPathSelectElement("/Project/PropertyGroup/TargetFrameworks")
3737
?? throw new InvalidDataException($"TargetFrameworks element not found in {csprojPath}");

tests/Serilog.Formatting.Log4Net.Tests.csproj

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@
2121
</ItemGroup>
2222

2323
<ItemGroup>
24-
<VSTestLogger Include="trx%3BLogFileName=TestResults-$(TargetFramework).trx" Visible="false" Condition="$(ContinuousIntegrationBuild) == 'true'" />
25-
<VSTestLogger Include="html%3BLogFileName=TestResults-$(TargetFramework).html" Visible="false" />
24+
<VSTestLogger Include="trx%3BLogFileName=$(MSBuildProjectName).trx" Visible="false" />
25+
<VSTestLogger Include="html%3BLogFileName=$(MSBuildProjectName).html" Visible="false" />
2626
</ItemGroup>
2727

2828
<PropertyGroup Label="Coverage">
29-
<RootDirectory>$([System.IO.Directory]::GetParent($(MSBuildProjectDirectory)))</RootDirectory>
30-
<CoverageReportDirectory>$([System.IO.Path]::Combine($(RootDirectory),'coverage',$(TargetFramework)))</CoverageReportDirectory>
31-
<VSTestResultsDirectory Condition="$(ContinuousIntegrationBuild) == 'true'">$(RootDirectory)</VSTestResultsDirectory>
32-
<VSTestResultsDirectory Condition="$(ContinuousIntegrationBuild) != 'true'">$([System.IO.Path]::Combine($(CoverageReportDirectory),'results'))</VSTestResultsDirectory>
29+
<CoverageReportDirectory>$([System.IO.Path]::Combine($(ArtifactsPath),'coverage',$(TargetFramework)))</CoverageReportDirectory>
30+
<VSTestResultsDirectory>$([System.IO.Path]::Combine($(ArtifactsPath),'test-results',$(TargetFramework)))</VSTestResultsDirectory>
3331
<VSTestCollect>XPlat Code Coverage%3BExcludeByAttribute=GeneratedCodeAttribute</VSTestCollect>
3432
<VSTestLogger>@(VSTestLogger)</VSTestLogger>
3533
</PropertyGroup>
@@ -39,29 +37,26 @@
3937
<CoverageReport Include="$(VSTestResultsDirectory)/*/coverage.cobertura.xml" />
4038
</ItemGroup>
4139
<ReportGenerator ReportFiles="@(CoverageReport)" TargetDirectory="$(CoverageReportDirectory)" ReportTypes="HtmlInline;TextSummary" />
40+
<Move SourceFiles="@(CoverageReport)" DestinationFolder="$(CoverageReportDirectory)" />
4241
</Target>
4342

44-
<!-- Because of https://github.com/microsoft/vstest/issues/2378 -->
45-
<Target Name="MoveCoverageReport" AfterTargets="GenerateHtmlCoverageReport" Condition="$(TargetFramework) != ''">
46-
<Move SourceFiles="@(CoverageReport)" DestinationFolder="$(CoverageReportDirectory)" />
47-
<PropertyGroup>
48-
<CoverageReport>@(CoverageReport)</CoverageReport>
49-
</PropertyGroup>
43+
<!-- Because of https://github.com/microsoft/vstest/issues/2334 and https://github.com/microsoft/vstest/issues/2378 -->
44+
<Target Name="RemoveSpuriousDirectories" AfterTargets="GenerateHtmlCoverageReport" Condition="$(TargetFramework) != ''">
5045
<ItemGroup>
51-
<CoverageReportParentDirectory Include="$([System.IO.Path]::Combine($(CoverageReport),'..'))" Condition="$(CoverageReport) != ''" />
46+
<SpuriousDirectory Include="$([System.IO.Directory]::GetDirectories($(VSTestResultsDirectory)))" />
5247
</ItemGroup>
53-
<RemoveDir Directories="@(CoverageReportParentDirectory)" />
48+
<RemoveDir Directories="@(SpuriousDirectory)" />
5449
</Target>
5550

56-
<Target Name="DisplayCoverageSummary" AfterTargets="MoveCoverageReport" Condition="$(TargetFramework) != ''">
51+
<Target Name="DisplayCoverageSummary" AfterTargets="GenerateHtmlCoverageReport" Condition="$(TargetFramework) != ''">
5752
<PropertyGroup>
5853
<CatCommand Condition="!$([MSBuild]::IsOSPlatform('Windows'))">cat</CatCommand>
5954
<CatCommand Condition="$([MSBuild]::IsOSPlatform('Windows'))">type</CatCommand>
6055
</PropertyGroup>
6156
<Exec WorkingDirectory="$(CoverageReportDirectory)" Command="$(CatCommand) Summary.txt" />
6257
</Target>
6358

64-
<Target Name="OpenHtmlCoverageReport" AfterTargets="MoveCoverageReport" Condition="$(TargetFramework) != '' AND $(ContinuousIntegrationBuild) != 'true'">
59+
<Target Name="OpenHtmlCoverageReport" AfterTargets="GenerateHtmlCoverageReport" Condition="$(TargetFramework) != ''">
6560
<PropertyGroup>
6661
<OpenCommand Condition="$([MSBuild]::IsOSPlatform('Linux'))">xdg-open</OpenCommand>
6762
<OpenCommand Condition="$([MSBuild]::IsOSPlatform('OSX'))">open</OpenCommand>

0 commit comments

Comments
 (0)