-
Notifications
You must be signed in to change notification settings - Fork 647
Parallelise outerloop quarantined test execution #8618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1e723f2
Parallelise outerloop quarantined test execution
RussKie 02413e1
fixup! Parallelise outerloop quarantined test execution
RussKie 2579e7e
Use exe directly
Youssef1313 9aa3f57
Update for MTP
RussKie 372e461
Only pass relevant command-line options
Youssef1313 a93aa01
Remove binlog
RussKie a680ecf
Fix trx path
RussKie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<Project> | ||
|
||
<!-- | ||
In short, this file automates the creation of a combined JSON runsheet from individual test runsheets, | ||
making it easy to integrate quarantined test execution into CI workflows, especially GitHub Actions. | ||
--> | ||
|
||
<!-- | ||
This MSBuild targets file automates the generation of a combined test runsheet after building a solution, | ||
using the QuarantinedTestRunsheetBuilder (located in eng/QuarantinedTestRunsheetBuilder/QuarantinedTestRunsheetBuilder.targets). | ||
|
||
Here's a high-level overview of its logic: | ||
|
||
1. **Conditionally Triggered Target**: | ||
- The target _GenerateTestMatrix runs before the Test target, but only if the TestRunnerName property is set to QuarantinedTestRunsheetBuilder. | ||
|
||
2. **Define Paths and Script Content**: | ||
- Defines a combined runsheet JSON file path (_CombinedRunsheetFile) in the artifacts temporary directory. | ||
- Defines a PowerShell script (_Command) that: | ||
- Finds all individual .runsheet.json files in the artifacts directory. | ||
- Reads and merges their JSON content into a single combined JSON array. | ||
- Writes the combined JSON to the combined runsheet file. | ||
- Checks if running in GitHub Actions environment: | ||
- If yes, outputs the combined JSON to GitHub Actions output (GITHUB_OUTPUT). | ||
- If no, prints the combined JSON to the console. | ||
|
||
3. **Write and Execute the Script**: | ||
- Writes the defined PowerShell script content to a temporary script file (create-runsheet.ps1). | ||
- Executes this script using MSBuild's <Exec> task. | ||
|
||
4. **Output Results**: | ||
- After execution, logs a message indicating the combined runsheet was created, along with the script's output. | ||
|
||
A runsheet is a JSON file that describes what tests to be run. | ||
For example: | ||
|
||
```json | ||
[ | ||
{ | ||
"project": "Aspire.Test", | ||
"os": "windows-latest", | ||
"command": "./eng/build.ps1 -restore -build -test -projects \"$(RelativeTestProjectPath)\" /bl:\"$(RelativeTestBinLog)\" -c $(Configuration) -ci /p:RunQuarantinedTests=true /p:CI=false" | ||
}, | ||
{ | ||
"project": "Aspire.Cli.Test", | ||
"os": "ubuntu-latest", | ||
"command": "./eng/build.sh -restore -build -test -projects \"$(RelativeTestProjectPath)\" /bl:\"$(RelativeTestBinLog)\" -c $(Configuration) -ci /p:RunQuarantinedTests=true /p:CI=false" | ||
} | ||
] | ||
``` | ||
|
||
--> | ||
<Target Name="_GenerateTestMatrix" BeforeTargets="Test" Condition=" '$(TestRunnerName)' == 'QuarantinedTestRunsheetBuilder' "> | ||
RussKie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<PropertyGroup> | ||
<_CombinedRunsheetFile>$(ArtifactsTmpDir)/combined_runsheet.json</_CombinedRunsheetFile> | ||
<_Command> | ||
$combined = @() | ||
Get-ChildItem -Path '$(ArtifactsTmpDir)' -Filter '*.runsheet.json' | | ||
ForEach-Object { | ||
$content = Get-Content -Raw $_.FullName | ConvertFrom-Json | ||
if ($content -is [Array]) { | ||
$combined += $content | ||
} | ||
else { | ||
$combined += @($content) | ||
} | ||
} | ||
$jsonString = ($combined | ConvertTo-Json -Depth 10 -Compress) | ||
$jsonString | Set-Content '$(_CombinedRunsheetFile)'; | ||
|
||
# determine if the script is running in a GitHub Actions environment | ||
if ($env:CI -and $env:GITHUB_ACTIONS) { | ||
"runsheet=$jsonString" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | ||
} | ||
else { | ||
Write-Host "runsheet=$jsonString" | ||
} | ||
</_Command> | ||
<_Script>$([MSBuild]::NormalizePath($(ArtifactsTmpDir), 'create-runsheet.ps1'))</_Script> | ||
</PropertyGroup> | ||
|
||
<WriteLinesToFile File="$(_Script)" | ||
Lines="$(_Command)" | ||
Overwrite="true" /> | ||
<Exec Command="pwsh -File $(_Script)" ConsoleToMSBuild="true"> | ||
<Output TaskParameter="ConsoleOutput" PropertyName="ScriptOutput" /> | ||
</Exec> | ||
<Message Importance="high" Text="Combined runsheet created%0D%0A%0D%0A$(ScriptOutput)" /> | ||
</Target> | ||
</Project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.