From 9b95c9153750e1d98719898ac61f0b623982f106 Mon Sep 17 00:00:00 2001 From: Andrey Akinshin Date: Wed, 12 Jul 2023 16:15:43 +0400 Subject: [PATCH] [build] Rename tasks --- .github/workflows/generate-changelog.yaml | 2 +- .github/workflows/generate-gh-pages.yaml | 6 +- .github/workflows/run-tests.yaml | 40 ++++----- .../CommandLineParser.cs | 29 ++----- build/BenchmarkDotNet.Build/Program.cs | 85 +++---------------- docs/articles/contributing/documentation.md | 4 +- 6 files changed, 45 insertions(+), 121 deletions(-) diff --git a/.github/workflows/generate-changelog.yaml b/.github/workflows/generate-changelog.yaml index 54dd5c2250..71592e4d46 100644 --- a/.github/workflows/generate-changelog.yaml +++ b/.github/workflows/generate-changelog.yaml @@ -20,7 +20,7 @@ jobs: ref: master - name: Download changelog - run: ./build.cmd DocsUpdate --depth 1 --preview + run: ./build.cmd docs-update --depth 1 --preview env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/generate-gh-pages.yaml b/.github/workflows/generate-gh-pages.yaml index 868fa49c5c..cb01860995 100644 --- a/.github/workflows/generate-gh-pages.yaml +++ b/.github/workflows/generate-gh-pages.yaml @@ -20,15 +20,15 @@ jobs: ref: docs-stable - name: Build BenchmarkDotNet - run: ./build.cmd Build + run: ./build.cmd build - name: Download changelog - run: ./build.cmd DocsUpdate --depth 1 --preview + run: ./build.cmd docs-update --depth 1 --preview env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Build documentation - run: ./build.cmd DocsBuild + run: ./build.cmd docs-build - name: Upload Artifacts uses: actions/upload-artifact@v1 diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 66326dbc34..58a248382d 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -18,16 +18,16 @@ jobs: run: Set-MpPreference -DisableRealtimeMonitoring $true shell: powershell - uses: actions/checkout@v3 - - name: Run task 'Build' + - name: Run task 'build' shell: cmd run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - ./build.cmd Build - - name: Run task 'InTestsCore' + ./build.cmd build + - name: Run task 'in-tests-core' shell: cmd run: | 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 uses: actions/upload-artifact@v3 if: always() @@ -42,16 +42,16 @@ jobs: run: Set-MpPreference -DisableRealtimeMonitoring $true shell: powershell - uses: actions/checkout@v3 - - name: Run task 'Build' + - name: Run task 'build' shell: cmd run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - ./build.cmd Build - - name: Run task 'InTestsFull' + ./build.cmd build + - name: Run task 'in-tests-full' shell: cmd run: | 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 uses: actions/upload-artifact@v3 if: always() @@ -70,12 +70,12 @@ jobs: platform: x64 - name: Set up zlib-static run: sudo apt-get install -y libkrb5-dev - - name: Run task 'Build' - run: ./build.cmd Build - - name: Run task 'UnitTests' - run: ./build.cmd UnitTests -e - - name: Run task 'InTestsCore' - run: ./build.cmd InTestsCore -e + - name: Run task 'build' + run: ./build.cmd build + - name: Run task 'unit-tests' + run: ./build.cmd unit-tests -e + - name: Run task 'in-tests-core' + run: ./build.cmd in-tests-core -e - name: Upload test results uses: actions/upload-artifact@v3 if: always() @@ -87,12 +87,12 @@ jobs: runs-on: macos-13 steps: - uses: actions/checkout@v3 - - name: Run task 'Build' - run: ./build.cmd Build - - name: Run task 'UnitTests' - run: ./build.cmd UnitTests -e - - name: Run task 'InTestsCore' - run: ./build.cmd InTestsCore -e + - name: Run task 'build' + run: ./build.cmd build + - name: Run task 'unit-tests' + run: ./build.cmd unit-tests -e + - name: Run task 'in-tests-core' + run: ./build.cmd in-tests-core -e - name: Upload test results uses: actions/upload-artifact@v3 if: always() diff --git a/build/BenchmarkDotNet.Build/CommandLineParser.cs b/build/BenchmarkDotNet.Build/CommandLineParser.cs index 5e797e6375..50dd344811 100644 --- a/build/BenchmarkDotNet.Build/CommandLineParser.cs +++ b/build/BenchmarkDotNet.Build/CommandLineParser.cs @@ -34,15 +34,18 @@ public class CommandLineParser if (Is(taskName, "-t", "--target") && argsToProcess.Any()) taskName = argsToProcess.Dequeue(); - taskName = taskName.Replace("-", ""); - 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"); return null; } + taskName = matchedTaskName; + if (argsToProcess.Count == 1 && Is(argsToProcess.Peek(), "-h", "--help")) { PrintTaskHelp(taskName); @@ -93,9 +96,6 @@ private void PrintHelp() WritePrefix(); WriteLine("BenchmarkDotNet build script"); - WritePrefix(); - WriteLine("Task names are case-insensitive, dashes are ignored"); - WriteLine(); WriteHeader("Usage:"); @@ -139,7 +139,7 @@ private void PrintHelp() WritePrefix(); Write(CallScriptName + " "); - WriteTask("unittests "); + WriteTask("unit-tests "); WriteOption("--exclusive --verbosity "); WriteArg("Diagnostic"); WriteLine(); @@ -289,21 +289,6 @@ private void PrintTaskHelp(string taskName) WriteTask(taskName); 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(); PrintOptions(helpInfo.Options.Concat(baseOptions).ToArray()); diff --git a/build/BenchmarkDotNet.Build/Program.cs b/build/BenchmarkDotNet.Build/Program.cs index 2717e9b20a..a0ab546188 100644 --- a/build/BenchmarkDotNet.Build/Program.cs +++ b/build/BenchmarkDotNet.Build/Program.cs @@ -16,14 +16,14 @@ public static int Main(string[] args) } } -[TaskName("Restore")] +[TaskName("restore")] [TaskDescription("Restore NuGet packages")] public class RestoreTask : FrostingTask { public override void Run(BuildContext context) => context.BuildRunner.Restore(); } -[TaskName("Build")] +[TaskName("build")] [TaskDescription("Build BenchmarkDotNet.sln solution")] [IsDependentOn(typeof(RestoreTask))] public class BuildTask : FrostingTask @@ -31,7 +31,7 @@ public class BuildTask : FrostingTask public override void Run(BuildContext context) => context.BuildRunner.Build(); } -[TaskName("UnitTests")] +[TaskName("unit-tests")] [TaskDescription("Run unit tests (fast)")] [IsDependentOn(typeof(BuildTask))] public class UnitTestsTask : FrostingTask @@ -39,7 +39,7 @@ public class UnitTestsTask : FrostingTask 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)")] [IsDependentOn(typeof(BuildTask))] public class InTestsFullTask : FrostingTask @@ -49,7 +49,7 @@ public class InTestsFullTask : FrostingTask public override void Run(BuildContext context) => context.UnitTestRunner.RunInTests("net462"); } -[TaskName("InTestsCore")] +[TaskName("in-tests-core")] [TaskDescription("Run integration tests using .NET 7 (slow)")] [IsDependentOn(typeof(BuildTask))] public class InTestsCoreTask : FrostingTask @@ -57,7 +57,7 @@ public class InTestsCoreTask : FrostingTask public override void Run(BuildContext context) => context.UnitTestRunner.RunInTests("net7.0"); } -[TaskName("AllTests")] +[TaskName("all-tests")] [TaskDescription("Run all unit and integration tests (slow)")] [IsDependentOn(typeof(UnitTestsTask))] [IsDependentOn(typeof(InTestsFullTask))] @@ -66,7 +66,7 @@ public class AllTestsTask : FrostingTask { } -[TaskName("Pack")] +[TaskName("pack")] [TaskDescription("Pack Nupkg packages")] [IsDependentOn(typeof(BuildTask))] public class PackTask : FrostingTask @@ -74,16 +74,7 @@ public class PackTask : FrostingTask public override void Run(BuildContext context) => context.BuildRunner.Pack(); } -[TaskName("CI")] -[TaskDescription("Perform all CI-related tasks: Restore, Build, AllTests, Pack")] -[IsDependentOn(typeof(BuildTask))] -[IsDependentOn(typeof(AllTestsTask))] -[IsDependentOn(typeof(PackTask))] -public class CiTask : FrostingTask -{ -} - -[TaskName("DocsUpdate")] +[TaskName("docs-update")] [TaskDescription("Update generated documentation files")] public class DocsUpdateTask : FrostingTask, IHelpProvider { @@ -99,7 +90,7 @@ public HelpInfo GetHelp() } } -[TaskName("DocsPrepare")] +[TaskName("docs-prepare")] [TaskDescription("Prepare auxiliary documentation files")] public class DocsPrepareTask : FrostingTask, IHelpProvider { @@ -114,11 +105,7 @@ public HelpInfo GetHelp() } } -// In order to work around xref issues in DocFx, BenchmarkDotNet and BenchmarkDotNet.Annotations must be 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")] +[TaskName("docs-build")] [TaskDescription("Build final documentation")] [IsDependentOn(typeof(DocsPrepareTask))] public class DocsBuildTask : FrostingTask, IHelpProvider @@ -127,11 +114,12 @@ public class DocsBuildTask : FrostingTask, IHelpProvider public HelpInfo GetHelp() => new() { + Description = "The 'build' task should be run manually to build api docs", Options = new IOption[] { KnownOptions.DocsPreview } }; } -[TaskName("Release")] +[TaskName("release")] [TaskDescription("Release new version")] [IsDependentOn(typeof(BuildTask))] [IsDependentOn(typeof(PackTask))] @@ -140,53 +128,4 @@ public class DocsBuildTask : FrostingTask, IHelpProvider public class ReleaseTask : FrostingTask { public override void Run(BuildContext context) => context.ReleaseRunner.Run(); -} - -[TaskName("FastTests")] -[TaskDescription("OBSOLETE: use 'UnitTests'")] -[IsDependentOn(typeof(UnitTestsTask))] -public class FastTestsTask : FrostingTask -{ -} - -[TaskName("SlowFullFrameworkTests")] -[TaskDescription("OBSOLETE: use 'InTestsFull'")] -[IsDependentOn(typeof(InTestsFullTask))] -public class SlowFullFrameworkTestsTask : FrostingTask -{ -} - -[TaskName("SlowTestsNetCore")] -[TaskDescription("OBSOLETE: use 'InTestsCore'")] -[IsDependentOn(typeof(InTestsCoreTask))] -public class SlowTestsNetCoreTask : FrostingTask -{ -} - -[TaskName("DocFX_Changelog_Download")] -[TaskDescription("OBSOLETE: use 'DocsUpdate'")] -[IsDependentOn(typeof(DocsUpdateTask))] -public class DocFxChangelogDownloadTask : FrostingTask -{ -} - -[TaskName("DocFX_Changelog_Generate")] -[TaskDescription("OBSOLETE: use 'DocsPrepare'")] -[IsDependentOn(typeof(DocsPrepareTask))] -public class DocfxChangelogGenerateTask : FrostingTask -{ -} - -[TaskName("DocFX_Generate_Redirects")] -[TaskDescription("OBSOLETE: use 'DocsBuild'")] -[IsDependentOn(typeof(DocsBuildTask))] -public class DocfxGenerateRedirectsTask : FrostingTask -{ -} - -[TaskName("DocFX_Build")] -[TaskDescription("OBSOLETE: use 'DocsBuild'")] -[IsDependentOn(typeof(DocsBuildTask))] -public class DocfxBuildTask : FrostingTask -{ } \ No newline at end of file diff --git a/docs/articles/contributing/documentation.md b/docs/articles/contributing/documentation.md index a0f23dd2d2..73854e928b 100644 --- a/docs/articles/contributing/documentation.md +++ b/docs/articles/contributing/documentation.md @@ -49,10 +49,10 @@ It will be transformed to: ## 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