Add test project filter to verify test workflow (#1246)

This commit is contained in:
Paulo Janotti 2022-09-19 22:27:04 -07:00 committed by GitHub
parent d4be5903f1
commit 19d19e6b82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 3 deletions

View File

@ -4,11 +4,14 @@ name: verify-test
on:
workflow_dispatch:
inputs:
testProjectFilter:
description: String that partially matches test projects to run. Defaults to all test projects.
required: false
testName:
description: 'Test name'
description: 'String that partially matches the tests to run'
required: true
count:
description: 'Test execution count'
description: 'Test execution count'
default: '20'
jobs:
@ -31,7 +34,7 @@ jobs:
dotnet-version: |
3.1.x
6.0.x
- run: ./build.cmd BuildTracer ManagedTests --containers ${{ matrix.containers }} --test-name "${{ github.event.inputs.testName }}" --test-count ${{ github.event.inputs.count }}
- run: ./build.cmd BuildTracer ManagedTests --containers ${{ matrix.containers }} --test-project-filter "${{ github.event.inputs.testProjectFilter }}" --test-name "${{ github.event.inputs.testName }}" --test-count ${{ github.event.inputs.count }}
- name: Upload logs
uses: actions/upload-artifact@v3.1.0
if: always()

View File

@ -295,6 +295,17 @@ partial class Build
Solution.GetProject(Projects.Tests.AutoInstrumentationTests)
};
if (!string.IsNullOrWhiteSpace(TestProjectFilter))
{
unitTestProjects = unitTestProjects
.Where(p => p.Name.Contains(TestProjectFilter, StringComparison.OrdinalIgnoreCase))
.ToArray();
if (unitTestProjects.Length == 0)
{
return;
}
}
for (int i = 0; i < TestCount; i++)
{
DotNetTest(config => config
@ -315,6 +326,10 @@ partial class Build
.Executes(() =>
{
var project = Solution.GetProject("IntegrationTests");
if (!string.IsNullOrWhiteSpace(TestProjectFilter) && !project.Name.Contains(TestProjectFilter, StringComparison.OrdinalIgnoreCase))
{
return;
}
IEnumerable<TargetFramework> frameworks = IsWin ? TestFrameworks : TestFrameworks.ExceptNetFramework();
@ -414,6 +429,11 @@ partial class Build
private void RunBootstrappingTests()
{
var project = Solution.GetProject(Projects.Tests.AutoInstrumentationBootstrappingTests);
if (!string.IsNullOrWhiteSpace(TestProjectFilter) && !project.Name.Contains(TestProjectFilter, StringComparison.OrdinalIgnoreCase))
{
// Test project was not selected.
return;
}
const string testPrefix = "OpenTelemetry.AutoInstrumentation.Bootstrapping.Tests.InstrumentationTests";
var testNames = new[] {

View File

@ -25,6 +25,9 @@ partial class Build : NukeBuild
const string ContainersLinux = "linux";
const string ContainersWindows = "windows";
[Parameter("Test projects to be run. Optional, default matches all test projects. The project will be selected if the string is part of its name.")]
readonly string TestProjectFilter = "";
[Parameter("Test name to be run. Optional")]
readonly string TestName;