Skip to content

Commit

Permalink
[build] Rename tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyAkinshin committed Jul 12, 2023
1 parent c97d158 commit 9b95c91
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 121 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/generate-changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/generate-gh-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 20 additions & 20 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down
29 changes: 7 additions & 22 deletions build/BenchmarkDotNet.Build/CommandLineParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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:");
Expand Down Expand Up @@ -139,7 +139,7 @@ private void PrintHelp()

WritePrefix();
Write(CallScriptName + " ");
WriteTask("unittests ");
WriteTask("unit-tests ");
WriteOption("--exclusive --verbosity ");
WriteArg("Diagnostic");
WriteLine();
Expand Down Expand Up @@ -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());
Expand Down
85 changes: 12 additions & 73 deletions build/BenchmarkDotNet.Build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@ public static int Main(string[] args)
}
}

[TaskName("Restore")]
[TaskName("restore")]
[TaskDescription("Restore NuGet packages")]
public class RestoreTask : FrostingTask<BuildContext>
{
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<BuildContext>
{
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<BuildContext>
{
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<BuildContext>
Expand All @@ -49,15 +49,15 @@ public class InTestsFullTask : FrostingTask<BuildContext>
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<BuildContext>
{
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))]
Expand All @@ -66,24 +66,15 @@ public class AllTestsTask : FrostingTask<BuildContext>
{
}

[TaskName("Pack")]
[TaskName("pack")]
[TaskDescription("Pack Nupkg packages")]
[IsDependentOn(typeof(BuildTask))]
public class PackTask : FrostingTask<BuildContext>
{
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<BuildContext>
{
}

[TaskName("DocsUpdate")]
[TaskName("docs-update")]
[TaskDescription("Update generated documentation files")]
public class DocsUpdateTask : FrostingTask<BuildContext>, IHelpProvider
{
Expand All @@ -99,7 +90,7 @@ public HelpInfo GetHelp()
}
}

[TaskName("DocsPrepare")]
[TaskName("docs-prepare")]
[TaskDescription("Prepare auxiliary documentation files")]
public class DocsPrepareTask : FrostingTask<BuildContext>, IHelpProvider
{
Expand All @@ -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<BuildContext>, IHelpProvider
Expand All @@ -127,11 +114,12 @@ public class DocsBuildTask : FrostingTask<BuildContext>, 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))]
Expand All @@ -140,53 +128,4 @@ public class DocsBuildTask : FrostingTask<BuildContext>, IHelpProvider
public class ReleaseTask : FrostingTask<BuildContext>
{
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>
{
}
4 changes: 2 additions & 2 deletions docs/articles/contributing/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9b95c91

Please sign in to comment.