This commit is contained in:
Andrey Akinshin 2023-07-12 16:15:43 +04:00
Родитель 7de12a1d3e
Коммит 3f890fd4a8
6 изменённых файлов: 45 добавлений и 121 удалений

2
.github/workflows/generate-changelog.yaml поставляемый
Просмотреть файл

@ -20,7 +20,7 @@ jobs:
ref: master ref: master
- name: Download changelog - name: Download changelog
run: ./build.cmd DocsUpdate --depth 1 --preview run: ./build.cmd docs-update --depth 1 --preview
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

6
.github/workflows/generate-gh-pages.yaml поставляемый
Просмотреть файл

@ -20,15 +20,15 @@ jobs:
ref: docs-stable ref: docs-stable
- name: Build BenchmarkDotNet - name: Build BenchmarkDotNet
run: ./build.cmd Build run: ./build.cmd build
- name: Download changelog - name: Download changelog
run: ./build.cmd DocsUpdate --depth 1 --preview run: ./build.cmd docs-update --depth 1 --preview
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build documentation - name: Build documentation
run: ./build.cmd DocsBuild run: ./build.cmd docs-build
- name: Upload Artifacts - name: Upload Artifacts
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v1

40
.github/workflows/run-tests.yaml поставляемый
Просмотреть файл

@ -18,16 +18,16 @@ jobs:
run: Set-MpPreference -DisableRealtimeMonitoring $true run: Set-MpPreference -DisableRealtimeMonitoring $true
shell: powershell shell: powershell
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Run task 'Build' - name: Run task 'build'
shell: cmd shell: cmd
run: | run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
./build.cmd Build ./build.cmd build
- name: Run task 'InTestsCore' - name: Run task 'in-tests-core'
shell: cmd shell: cmd
run: | run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
./build.cmd InTestsCore -e ./build.cmd in-tests-core -e
- name: Upload test results - name: Upload test results
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
if: always() if: always()
@ -42,16 +42,16 @@ jobs:
run: Set-MpPreference -DisableRealtimeMonitoring $true run: Set-MpPreference -DisableRealtimeMonitoring $true
shell: powershell shell: powershell
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Run task 'Build' - name: Run task 'build'
shell: cmd shell: cmd
run: | run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
./build.cmd Build ./build.cmd build
- name: Run task 'InTestsFull' - name: Run task 'in-tests-full'
shell: cmd shell: cmd
run: | run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
./build.cmd InTestsFull -e ./build.cmd in-tests-full -e
- name: Upload test results - name: Upload test results
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
if: always() if: always()
@ -70,12 +70,12 @@ jobs:
platform: x64 platform: x64
- name: Set up zlib-static - name: Set up zlib-static
run: sudo apt-get install -y libkrb5-dev run: sudo apt-get install -y libkrb5-dev
- name: Run task 'Build' - name: Run task 'build'
run: ./build.cmd Build run: ./build.cmd build
- name: Run task 'UnitTests' - name: Run task 'unit-tests'
run: ./build.cmd UnitTests -e run: ./build.cmd unit-tests -e
- name: Run task 'InTestsCore' - name: Run task 'in-tests-core'
run: ./build.cmd InTestsCore -e run: ./build.cmd in-tests-core -e
- name: Upload test results - name: Upload test results
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
if: always() if: always()
@ -87,12 +87,12 @@ jobs:
runs-on: macos-13 runs-on: macos-13
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Run task 'Build' - name: Run task 'build'
run: ./build.cmd Build run: ./build.cmd build
- name: Run task 'UnitTests' - name: Run task 'unit-tests'
run: ./build.cmd UnitTests -e run: ./build.cmd unit-tests -e
- name: Run task 'InTestsCore' - name: Run task 'in-tests-core'
run: ./build.cmd InTestsCore -e run: ./build.cmd in-tests-core -e
- name: Upload test results - name: Upload test results
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
if: always() if: always()

Просмотреть файл

@ -34,15 +34,18 @@ public class CommandLineParser
if (Is(taskName, "-t", "--target") && argsToProcess.Any()) if (Is(taskName, "-t", "--target") && argsToProcess.Any())
taskName = argsToProcess.Dequeue(); taskName = argsToProcess.Dequeue();
taskName = taskName.Replace("-", "");
var taskNames = GetTaskNames(); var taskNames = GetTaskNames();
if (!taskNames.Contains(taskName)) var matchedTaskName = taskNames
.FirstOrDefault(name => string.Equals(name.Replace("-", ""), taskName.Replace("-", ""),
StringComparison.OrdinalIgnoreCase));
if (matchedTaskName == null)
{ {
PrintError($"'{taskName}' is not a task"); PrintError($"'{taskName}' is not a task");
return null; return null;
} }
taskName = matchedTaskName;
if (argsToProcess.Count == 1 && Is(argsToProcess.Peek(), "-h", "--help")) if (argsToProcess.Count == 1 && Is(argsToProcess.Peek(), "-h", "--help"))
{ {
PrintTaskHelp(taskName); PrintTaskHelp(taskName);
@ -93,9 +96,6 @@ public class CommandLineParser
WritePrefix(); WritePrefix();
WriteLine("BenchmarkDotNet build script"); WriteLine("BenchmarkDotNet build script");
WritePrefix();
WriteLine("Task names are case-insensitive, dashes are ignored");
WriteLine(); WriteLine();
WriteHeader("Usage:"); WriteHeader("Usage:");
@ -139,7 +139,7 @@ public class CommandLineParser
WritePrefix(); WritePrefix();
Write(CallScriptName + " "); Write(CallScriptName + " ");
WriteTask("unittests "); WriteTask("unit-tests ");
WriteOption("--exclusive --verbosity "); WriteOption("--exclusive --verbosity ");
WriteArg("Diagnostic"); WriteArg("Diagnostic");
WriteLine(); WriteLine();
@ -289,21 +289,6 @@ public class CommandLineParser
WriteTask(taskName); WriteTask(taskName);
WriteLine(); WriteLine();
if (taskName.StartsWith("docs", StringComparison.OrdinalIgnoreCase))
{
WritePrefix();
Write(ScriptName + " ");
WriteTask("docs-" + taskName[4..].ToLowerInvariant());
WriteLine();
}
else
{
WritePrefix();
Write(ScriptName + " ");
WriteTask(taskName.ToLowerInvariant());
WriteLine();
}
WriteLine(); WriteLine();
PrintOptions(helpInfo.Options.Concat(baseOptions).ToArray()); PrintOptions(helpInfo.Options.Concat(baseOptions).ToArray());

Просмотреть файл

@ -16,14 +16,14 @@ public static class Program
} }
} }
[TaskName("Restore")] [TaskName("restore")]
[TaskDescription("Restore NuGet packages")] [TaskDescription("Restore NuGet packages")]
public class RestoreTask : FrostingTask<BuildContext> public class RestoreTask : FrostingTask<BuildContext>
{ {
public override void Run(BuildContext context) => context.BuildRunner.Restore(); public override void Run(BuildContext context) => context.BuildRunner.Restore();
} }
[TaskName("Build")] [TaskName("build")]
[TaskDescription("Build BenchmarkDotNet.sln solution")] [TaskDescription("Build BenchmarkDotNet.sln solution")]
[IsDependentOn(typeof(RestoreTask))] [IsDependentOn(typeof(RestoreTask))]
public class BuildTask : FrostingTask<BuildContext> public class BuildTask : FrostingTask<BuildContext>
@ -31,7 +31,7 @@ public class BuildTask : FrostingTask<BuildContext>
public override void Run(BuildContext context) => context.BuildRunner.Build(); public override void Run(BuildContext context) => context.BuildRunner.Build();
} }
[TaskName("UnitTests")] [TaskName("unit-tests")]
[TaskDescription("Run unit tests (fast)")] [TaskDescription("Run unit tests (fast)")]
[IsDependentOn(typeof(BuildTask))] [IsDependentOn(typeof(BuildTask))]
public class UnitTestsTask : FrostingTask<BuildContext> public class UnitTestsTask : FrostingTask<BuildContext>
@ -39,7 +39,7 @@ public class UnitTestsTask : FrostingTask<BuildContext>
public override void Run(BuildContext context) => context.UnitTestRunner.RunUnitTests(); public override void Run(BuildContext context) => context.UnitTestRunner.RunUnitTests();
} }
[TaskName("InTestsFull")] [TaskName("in-tests-full")]
[TaskDescription("Run integration tests using .NET Framework 4.6.2+ (slow)")] [TaskDescription("Run integration tests using .NET Framework 4.6.2+ (slow)")]
[IsDependentOn(typeof(BuildTask))] [IsDependentOn(typeof(BuildTask))]
public class InTestsFullTask : FrostingTask<BuildContext> public class InTestsFullTask : FrostingTask<BuildContext>
@ -49,7 +49,7 @@ public class InTestsFullTask : FrostingTask<BuildContext>
public override void Run(BuildContext context) => context.UnitTestRunner.RunInTests("net462"); public override void Run(BuildContext context) => context.UnitTestRunner.RunInTests("net462");
} }
[TaskName("InTestsCore")] [TaskName("in-tests-core")]
[TaskDescription("Run integration tests using .NET 7 (slow)")] [TaskDescription("Run integration tests using .NET 7 (slow)")]
[IsDependentOn(typeof(BuildTask))] [IsDependentOn(typeof(BuildTask))]
public class InTestsCoreTask : FrostingTask<BuildContext> public class InTestsCoreTask : FrostingTask<BuildContext>
@ -57,7 +57,7 @@ public class InTestsCoreTask : FrostingTask<BuildContext>
public override void Run(BuildContext context) => context.UnitTestRunner.RunInTests("net7.0"); public override void Run(BuildContext context) => context.UnitTestRunner.RunInTests("net7.0");
} }
[TaskName("AllTests")] [TaskName("all-tests")]
[TaskDescription("Run all unit and integration tests (slow)")] [TaskDescription("Run all unit and integration tests (slow)")]
[IsDependentOn(typeof(UnitTestsTask))] [IsDependentOn(typeof(UnitTestsTask))]
[IsDependentOn(typeof(InTestsFullTask))] [IsDependentOn(typeof(InTestsFullTask))]
@ -66,7 +66,7 @@ public class AllTestsTask : FrostingTask<BuildContext>
{ {
} }
[TaskName("Pack")] [TaskName("pack")]
[TaskDescription("Pack Nupkg packages")] [TaskDescription("Pack Nupkg packages")]
[IsDependentOn(typeof(BuildTask))] [IsDependentOn(typeof(BuildTask))]
public class PackTask : FrostingTask<BuildContext> public class PackTask : FrostingTask<BuildContext>
@ -74,16 +74,7 @@ public class PackTask : FrostingTask<BuildContext>
public override void Run(BuildContext context) => context.BuildRunner.Pack(); public override void Run(BuildContext context) => context.BuildRunner.Pack();
} }
[TaskName("CI")] [TaskName("docs-update")]
[TaskDescription("Perform all CI-related tasks: Restore, Build, AllTests, Pack")]
[IsDependentOn(typeof(BuildTask))]
[IsDependentOn(typeof(AllTestsTask))]
[IsDependentOn(typeof(PackTask))]
public class CiTask : FrostingTask<BuildContext>
{
}
[TaskName("DocsUpdate")]
[TaskDescription("Update generated documentation files")] [TaskDescription("Update generated documentation files")]
public class DocsUpdateTask : FrostingTask<BuildContext>, IHelpProvider public class DocsUpdateTask : FrostingTask<BuildContext>, IHelpProvider
{ {
@ -99,7 +90,7 @@ public class DocsUpdateTask : FrostingTask<BuildContext>, IHelpProvider
} }
} }
[TaskName("DocsPrepare")] [TaskName("docs-prepare")]
[TaskDescription("Prepare auxiliary documentation files")] [TaskDescription("Prepare auxiliary documentation files")]
public class DocsPrepareTask : FrostingTask<BuildContext>, IHelpProvider public class DocsPrepareTask : FrostingTask<BuildContext>, IHelpProvider
{ {
@ -114,11 +105,7 @@ public class DocsPrepareTask : FrostingTask<BuildContext>, IHelpProvider
} }
} }
// In order to work around xref issues in DocFx, BenchmarkDotNet and BenchmarkDotNet.Annotations must be build [TaskName("docs-build")]
// before running the DocFX_Build target. However, including a dependency on BuildTask here may have unwanted
// side effects (CleanTask).
// TODO: Define dependencies when a CI workflow scenario for using the "DocFX_Build" target exists.
[TaskName("DocsBuild")]
[TaskDescription("Build final documentation")] [TaskDescription("Build final documentation")]
[IsDependentOn(typeof(DocsPrepareTask))] [IsDependentOn(typeof(DocsPrepareTask))]
public class DocsBuildTask : FrostingTask<BuildContext>, IHelpProvider public class DocsBuildTask : FrostingTask<BuildContext>, IHelpProvider
@ -127,11 +114,12 @@ public class DocsBuildTask : FrostingTask<BuildContext>, IHelpProvider
public HelpInfo GetHelp() => new() public HelpInfo GetHelp() => new()
{ {
Description = "The 'build' task should be run manually to build api docs",
Options = new IOption[] { KnownOptions.DocsPreview } Options = new IOption[] { KnownOptions.DocsPreview }
}; };
} }
[TaskName("Release")] [TaskName("release")]
[TaskDescription("Release new version")] [TaskDescription("Release new version")]
[IsDependentOn(typeof(BuildTask))] [IsDependentOn(typeof(BuildTask))]
[IsDependentOn(typeof(PackTask))] [IsDependentOn(typeof(PackTask))]
@ -140,53 +128,4 @@ public class DocsBuildTask : FrostingTask<BuildContext>, IHelpProvider
public class ReleaseTask : FrostingTask<BuildContext> public class ReleaseTask : FrostingTask<BuildContext>
{ {
public override void Run(BuildContext context) => context.ReleaseRunner.Run(); public override void Run(BuildContext context) => context.ReleaseRunner.Run();
}
[TaskName("FastTests")]
[TaskDescription("OBSOLETE: use 'UnitTests'")]
[IsDependentOn(typeof(UnitTestsTask))]
public class FastTestsTask : FrostingTask<BuildContext>
{
}
[TaskName("SlowFullFrameworkTests")]
[TaskDescription("OBSOLETE: use 'InTestsFull'")]
[IsDependentOn(typeof(InTestsFullTask))]
public class SlowFullFrameworkTestsTask : FrostingTask<BuildContext>
{
}
[TaskName("SlowTestsNetCore")]
[TaskDescription("OBSOLETE: use 'InTestsCore'")]
[IsDependentOn(typeof(InTestsCoreTask))]
public class SlowTestsNetCoreTask : FrostingTask<BuildContext>
{
}
[TaskName("DocFX_Changelog_Download")]
[TaskDescription("OBSOLETE: use 'DocsUpdate'")]
[IsDependentOn(typeof(DocsUpdateTask))]
public class DocFxChangelogDownloadTask : FrostingTask<BuildContext>
{
}
[TaskName("DocFX_Changelog_Generate")]
[TaskDescription("OBSOLETE: use 'DocsPrepare'")]
[IsDependentOn(typeof(DocsPrepareTask))]
public class DocfxChangelogGenerateTask : FrostingTask<BuildContext>
{
}
[TaskName("DocFX_Generate_Redirects")]
[TaskDescription("OBSOLETE: use 'DocsBuild'")]
[IsDependentOn(typeof(DocsBuildTask))]
public class DocfxGenerateRedirectsTask : FrostingTask<BuildContext>
{
}
[TaskName("DocFX_Build")]
[TaskDescription("OBSOLETE: use 'DocsBuild'")]
[IsDependentOn(typeof(DocsBuildTask))]
public class DocfxBuildTask : FrostingTask<BuildContext>
{
} }

Просмотреть файл

@ -49,10 +49,10 @@ It will be transformed to:
## Building documentation locally ## Building documentation locally
You can build documentation locally with the help of the `DocsBuild` build task: You can build documentation locally with the help of the `docs-build` build task:
``` ```
build.cmd DocsBuild build.cmd docs-build
``` ```
## See also ## See also