Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
branches: [ main, feature/*, hotfix/* ]
workflow_dispatch:

env:
NO_COLOR: true

jobs:
test:
runs-on: ${{ matrix.os }}
Expand All @@ -31,30 +34,47 @@ jobs:
shell: bash
working-directory: templates

- run: dotnet test -c Release -f net10.0 --no-build --collect:"XPlat Code Coverage" --consoleLoggerParameters:"Summary;Verbosity=Minimal"
- name: Install Chromium headless shell
shell: pwsh
working-directory: src/docfx/bin/Release/net8.0
run: |
$env:PLAYWRIGHT_NODEJS_PATH = (Get-Command node).Path
./playwright.ps1 install chromium --only-shell

- name: Install `dotnet-coverage` as .NET Global Tool
run: dotnet tool install -g dotnet-coverage

- name: Start dotnet-coverage with background server mode
run: dotnet coverage collect --session-id docfx_coverage --settings test/CodeCoverage.runsettings --server-mode --background

- run: dotnet coverage connect docfx_coverage "dotnet test -c Release -f net10.0 --no-build"
id: test-net100

- run: dotnet test -c Release -f net9.0 --no-build --collect:"XPlat Code Coverage" --consoleLoggerParameters:"Summary;Verbosity=Minimal"
- run: dotnet coverage connect docfx_coverage "dotnet test -c Release -f net9.0 --no-build"
if: matrix.os == 'ubuntu-latest'
id: test-net90

- run: dotnet test -c Release -f net8.0 --no-build --collect:"XPlat Code Coverage" --consoleLoggerParameters:"Summary;Verbosity=Minimal"
- run: dotnet coverage connect docfx_coverage "dotnet test -c Release -f net8.0 --no-build"
if: matrix.os == 'ubuntu-latest'
id: test-net80

- run: npm i -g @percy/cli
if: matrix.os == 'ubuntu-latest'

- run: percy exec -- dotnet test -c Release -f net10.0 --filter Stage=Percy --no-build --collect:"XPlat Code Coverage"
- run: dotnet coverage connect docfx_coverage "percy exec -- dotnet test -c Release -f net10.0 --no-build -- --filter-trait "Stage=Percy""
if: matrix.os == 'ubuntu-latest'
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}

- name: Shutdown dotnet-coverage server.
run: dotnet coverage shutdown docfx_coverage --timeout 60000

- uses: codecov/codecov-action@v5
if: matrix.os == 'ubuntu-latest'
with:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
directory: test/TestResults/code-coverages

- run: echo "DOTNET_DbgEnableMiniDump=1" >> $GITHUB_ENV
if: matrix.os == 'ubuntu-latest'
Expand All @@ -74,8 +94,10 @@ jobs:
name: logs-${{ matrix.os }}
path: |
msbuild.binlog
test/**/TestResults/*.log
test/**/TestResults/*.trx
test/**/TestResults/*.html
test/**/TestResults/*.ctrf

- uses: actions/upload-artifact@v6
if: ${{ failure() && matrix.os == 'ubuntu-latest' }}
Expand Down
4 changes: 0 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)\README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<!-- Remove Node.js runtime dependencies that used by playwright -->
<Target Name="RemoveNodeJsRuntimes" AfterTargets="CopyPlaywrightFilesToOutput">
<ItemGroup>
Expand Down
7 changes: 7 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project>

<ItemGroup Condition="'$(IsPackable)' == 'true'">
<None Include="$(MSBuildThisFileDirectory)\README.md" Pack="true" PackagePath="\" />
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions docfx.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<Folder Name="/Solution Items/">
<File Path=".editorconfig" />
<File Path="Directory.Build.props" />
<File Path="Directory.Build.targets" />
<File Path="Directory.Packages.props" />
</Folder>
<Folder Name="/src/">
Expand Down Expand Up @@ -38,6 +39,7 @@
</Folder>
<Folder Name="/test/">
<File Path="test/Directory.Build.props" />
<File Path="test/Directory.Build.targets" />
<File Path="test/Directory.Packages.props" />
<Project Path="test/Docfx.Build.Common.Tests/Docfx.Build.Common.Tests.csproj" />
<Project Path="test/Docfx.Build.Tests/Docfx.Build.Tests.csproj" />
Expand Down
5 changes: 5 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"test": {
"runner": "Microsoft.Testing.Platform"
}
}
2 changes: 2 additions & 0 deletions samples/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<Project>
</Project>
47 changes: 47 additions & 0 deletions test/CodeCoverage.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<!-- Available Options: https://github.com/microsoft/codecoverage/blob/main/docs/configuration.md -->
<CoverageFileName>coverage.cobertura.xml</CoverageFileName>
<Format>cobertura</Format>
<IncludeTestAssembly>false</IncludeTestAssembly>
<DeterministicReport>true</DeterministicReport>
<CollectFromChildProcesses>true</CollectFromChildProcesses>
<CodeCoverage>
<ModulePaths>
<Include>
<ModulePath>.*Docfx.*\.dll$</ModulePath>
</Include>
<Exclude>
<!-- Exclude test DLLs -->
<ModulePath>.*Docfx\.Tests\.Common\.dll$</ModulePath>
<ModulePath>.*\.Tests\.dll$</ModulePath>

<!-- Exclude third party DLLs -->
<ModulePath>.*ICSharpCode\.Decompiler\.dll$</ModulePath>
<ModulePath>.*Spectre\.Console\.Cli\.dll$</ModulePath>
<ModulePath>.*Spectre\.Console\.dll$</ModulePath>
<ModulePath>.*DiffEngine\.dll$</ModulePath>

<!-- Following DLLs are included when using `dotnet coverage` commands -->
<ModulePath>.*Argon\.dll$</ModulePath>
<ModulePath>.*EmptyFiles\.dll$</ModulePath>
<ModulePath>.*Verify\.dll$</ModulePath>
<ModulePath>.*Verify\.DiffPlex\.dll$</ModulePath>
<ModulePath>.*Verify\.XunitV3\.dll$</ModulePath>
</Exclude>
</ModulePaths>
<Attributes>
<Exclude>
<Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
</Exclude>
</Attributes>
<Sources>
<Exclude>
<Source>.*\\[^\\]*\.g\.cs</Source>
</Exclude>
</Sources>
<!-- Disable following settings. Because C++ code is not contained (See: https://github.com/microsoft/codecoverage/blob/main/README.md#get-started)-->
<EnableStaticNativeInstrumentation>False</EnableStaticNativeInstrumentation>
<EnableDynamicNativeInstrumentation>False</EnableDynamicNativeInstrumentation>
</CodeCoverage>
</Configuration>
69 changes: 52 additions & 17 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,37 +1,72 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)../'))" />

<PropertyGroup>
<IsPackable>false</IsPackable>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<IsTestingPlatformApplication>true</IsTestingPlatformApplication>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<!-- .NET 9 or later run tests per TargetFramework in parallel by default.
It is necessary to disable this feature because there are tests that need to be executed sequentially that are marked with `[Collection("docfx STA")]`. -->
<PropertyGroup>
<!--
.NET 9 preview 2 or later run tests in parallel by default.
It is necessary to disable this feature because there are tests that need to be executed sequentially that are marked with `[Collection("docfx STA")]`.
-->
<TestTfmsInParallel>false</TestTfmsInParallel>
</PropertyGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)../'))" />
<!-- Configure `Microsoft.Testing.Platform` mode behaviors (https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-platform-integration-dotnet-test)-->

<ItemGroup>
<None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<!-- Following settings are required for .NET 9 SDK and earlier -->
<PropertyGroup Condition="'$(TargetFramework)'=='net9.0' OR '$(TargetFramework)'=='net8.0'">
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
<TestingPlatformCaptureOutput>false</TestingPlatformCaptureOutput>
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
</PropertyGroup>

<PropertyGroup>
<!-- Use `Microsoft.Testing.Platform` entrypoint -->
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
</PropertyGroup>

<PropertyGroup>
<!-- Show xUnit.net headers and information -->
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --xunit-info</TestingPlatformCommandLineArguments>

<!-- Change TestResults output directory. And enable detailed log outputs -->
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --results-directory "$(MSBuildThisFileDirectory)TestResults"</TestingPlatformCommandLineArguments>

<!-- Ignore exit code 8 (the test session run zero tests) -->
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --ignore-exit-code 8</TestingPlatformCommandLineArguments>

<!-- Enable output for passed tests -->
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --output Detailed</TestingPlatformCommandLineArguments>
</PropertyGroup>

<!-- Settings for CI environment -->
<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' == 'true' AND '$(PERCY_TOKEN)' == ''">
<VSTestResultsDirectory>$(MSBuildThisFileDirectory)TestResults</VSTestResultsDirectory>
<VSTestLogger>$(VSTestLogger);trx%3BLogFileName=TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).trx</VSTestLogger>
<VSTestLogger>$(VSTestLogger);html%3BLogFileName=TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).html</VSTestLogger>
<!-- Disable progress reports -->
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --no-progress</TestingPlatformCommandLineArguments>

<!-- Enable reporters (trx/html/ctrf ) -->
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-xunit-trx --report-xunit-trx-filename TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).trx</TestingPlatformCommandLineArguments>
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-xunit-html --report-xunit-html-filename TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).html</TestingPlatformCommandLineArguments>
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-ctrf --report-ctrf-filename TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).ctrf</TestingPlatformCommandLineArguments>
</PropertyGroup>

<ItemGroup Condition="'$(IsTestProject)' == 'true'">
<ItemGroup Condition="$(MSBuildProjectName.EndsWith('.Tests'))">
<!-- Set [assembly:CaptureConsole] attribute to assembly -->
<AssemblyAttribute Include="Xunit.CaptureConsole" />

<!-- Add project items -->
<None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" />
<None Include="$(MSBuildThisFileDirectory)xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />

<!-- Add Docfx.Tests.Common` project reference to test projects -->
<ProjectReference Include="$(MSBuildThisFileDirectory)Docfx.Tests.Common/Docfx.Tests.Common.csproj" />
</ItemGroup>

<ItemGroup>
<!-- Add common test package references -->
<PackageReference Include="AwesomeAssertions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3.mtp-v2" />
</ItemGroup>

</Project>
3 changes: 3 additions & 0 deletions test/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)../'))" />
</Project>
14 changes: 6 additions & 8 deletions test/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@

<ItemGroup>
<PackageVersion Include="AwesomeAssertions" Version="9.3.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageVersion Include="Verify.DiffPlex" Version="3.1.2" />
<PackageVersion Include="Verify.Xunit" Version="31.9.4" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageVersion Include="xunit" Version="2.9.3" />
</ItemGroup>

<ItemGroup>
<GlobalPackageReference Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="Verify.XunitV3" Version="31.9.4" />
<PackageVersion Include="xunit.v3" Version="3.2.1" />
<PackageVersion Include="xunit.v3.assert" Version="3.2.1" />
<PackageVersion Include="xunit.v3.extensibility.core" Version="3.2.1" />
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.1" />
</ItemGroup>

</Project>
4 changes: 4 additions & 0 deletions test/Docfx.Build.Common.Tests/Docfx.Build.Common.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build.Common\Docfx.Build.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.ManagedReference\Docfx.Build.ManagedReference.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Markdig" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build.OverwriteDocuments\Docfx.Build.OverwriteDocuments.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.YamlSerialization\Docfx.YamlSerialization.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build.OperationLevelRestApi\Docfx.Build.OperationLevelRestApi.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.TagLevelRestApi\Docfx.Build.TagLevelRestApi.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build.Common\Docfx.Build.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />
Expand Down
4 changes: 4 additions & 0 deletions test/Docfx.Build.Tests/Docfx.Build.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<Compile Remove="TestData\snippets\dataflowdegreeofparallelism.cs" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/Docfx.Build.Tests/ExtractSearchIndexFromHtmlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ This is article title
manifest.Files.Add(manifestItem);

// process the fake manifest, using tempTestFolder as the output folder
_extractor.Process(manifest, tempTestFolder);
_extractor.Process(manifest, tempTestFolder, TestContext.Current.CancellationToken);

var expectedIndexJSON = @"{
""index.html"": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void TestSitemapGenerator()
var sitemapPath = Path.Combine(outputFolder, "sitemap.xml");

// Act
manifest = sitemapGenerator.Process(manifest, outputFolder);
manifest = sitemapGenerator.Process(manifest, outputFolder, TestContext.Current.CancellationToken);

// Assert
Assert.Equal("https://example.com/", manifest.Sitemap.BaseUrl);
Expand Down
2 changes: 1 addition & 1 deletion test/Docfx.Build.Tests/RemoveDebugInfoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void TestBasicFeature()
new HtmlPostProcessor
{
Handlers = { new RemoveDebugInfo() }
}.Process(manifest, _outputFolder);
}.Process(manifest, _outputFolder, TestContext.Current.CancellationToken);

var actual = File.ReadAllText(Path.Combine(_outputFolder, "a.html"));
Assert.Equal("<p id='b1'>section<a href='http://bing.com#top'>Microsoft Bing</a></p>", actual);
Expand Down
Loading