Merge pull request #138 from AArnott/testAllTFMsSimply

Replace several `DotNetCoreCLI` task with one `dotnet test` task
This commit is contained in:
Andrew Arnott 2022-02-04 13:54:57 -07:00 коммит произвёл GitHub
Родитель 9fb050e9d0 04f05d67b8
Коммит f9f2c97f1e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 55 добавлений и 38 удалений

4
.github/workflows/build.yml поставляемый
Просмотреть файл

@ -39,9 +39,7 @@ jobs:
run: azure-pipelines/variables/_pipelines.ps1
shell: pwsh
- name: build
run: dotnet build --no-restore -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/build.binlog"
- name: pack
run: dotnet pack --no-build -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/pack.binlog"
run: dotnet build -t:build,pack --no-restore -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/build.binlog"
- name: test
run: dotnet test --no-build -c ${{ env.BUILDCONFIGURATION }} /bl:"bin/build_logs/test.binlog" --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --logger trx --blame-hang-timeout 30s --blame-crash
- name: Update pipeline variables based on build outputs

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

@ -0,0 +1,13 @@
Param(
[switch]$CleanIfLocal
)
if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) {
$ArtifactStagingFolder = $env:BUILD_ARTIFACTSTAGINGDIRECTORY
} else {
$ArtifactStagingFolder = Join-Path (Resolve-Path $PSScriptRoot/..) (Join-Path obj _artifacts)
if ($CleanIfLocal -and (Test-Path $ArtifactStagingFolder)) {
Remove-Item $ArtifactStagingFolder -Recurse -Force
}
}
$ArtifactStagingFolder

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

@ -7,14 +7,7 @@ param (
)
$RepoRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot (Join-Path .. ..)))
if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) {
$ArtifactStagingFolder = $env:BUILD_ARTIFACTSTAGINGDIRECTORY
} else {
$ArtifactStagingFolder = Join-Path $RepoRoot (Join-Path obj _artifacts)
if (Test-Path $ArtifactStagingFolder) {
Remove-Item $ArtifactStagingFolder -Recurse -Force
}
}
$ArtifactStagingFolder = & "$PSScriptRoot/../Get-ArtifactsStagingDirectory.ps1" -CleanIfLocal
function Create-SymbolicLink {
param (

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

@ -0,0 +1,37 @@
Param(
[string]$Configuration='Debug',
[string]$Agent='Local',
[switch]$PublishResults
)
$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot '..')
$ArtifactStagingFolder = & "$PSScriptRoot/Get-ArtifactsStagingDirectory.ps1"
dotnet test $RepoRoot `
--no-build `
-c $Configuration `
--filter "TestCategory!=FailsInCloudTest" `
-p:CollectCoverage=true `
--blame-hang-timeout 30s `
--blame-crash `
-bl:"$ArtifactStagingFolder/build_logs/test.binlog" `
--diag "$ArtifactStagingFolder/test_logs/diag.log;TraceLevel=info" `
--logger trx
$unknownCounter = 0
Get-ChildItem -Recurse -Path $RepoRoot\test\*.trx |% {
Copy-Item $_ -Destination $ArtifactStagingFolder/test_logs/
if ($PublishResults) {
$x = [xml](Get-Content -Path $_)
$storage = $x.TestRun.TestDefinitions.GetElementsByTagName('UnitTest')[0].storage -replace '\\','/'
if ($storage -match '/(?<tfm>[^/]+)/(?<lib>[^/]+)\.dll$') {
$runTitle = "$($matches.lib) ($($matches.tfm), $Agent)"
} else {
$unknownCounter += 1;
$runTitle = "unknown$unknownCounter ($Agent)";
}
Write-Host "##vso[results.publish type=VSTest;runTitle=$runTitle;publishRunAttachments=true;resultFiles=$_;failTaskOnFailedTests=true;testRunSystem=VSTS - PTR;]"
}
}

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

@ -1,34 +1,10 @@
steps:
- script: dotnet build --no-restore -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog"
- script: dotnet build -t:build,pack --no-restore -c $(BuildConfiguration) /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog"
displayName: dotnet build
- script: dotnet pack --no-build -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/pack.binlog"
displayName: dotnet pack
- task: DotNetCoreCLI@2
displayName: dotnet test -f net472
inputs:
command: test
arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --blame-hang-timeout 30s --blame-crash /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_net472.binlog" --diag "$(Build.ArtifactStagingDirectory)/test_logs/net472.txt;TraceLevel=info"
testRunTitle: net472-$(Agent.JobName)
condition: succeededOrFailed()
- task: DotNetCoreCLI@2
displayName: dotnet test -f netcoreapp3.1
inputs:
command: test
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --blame-hang-timeout 30s --blame-crash /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_netcoreapp3.1.binlog" --diag "$(Build.ArtifactStagingDirectory)/test_logs/netcoreapp3.1.txt;TraceLevel=info"
testRunTitle: netcoreapp3.1-$(Agent.JobName)
condition: succeededOrFailed()
- task: DotNetCoreCLI@2
displayName: dotnet test -f net5.0
inputs:
command: test
arguments: --no-build -c $(BuildConfiguration) -f net5.0 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --blame-hang-timeout 30s --blame-crash /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_net5.0.binlog" --diag "$(Build.ArtifactStagingDirectory)/test_logs/net5.0.txt;TraceLevel=info"
testRunTitle: net5.0-$(Agent.JobName)
condition: succeededOrFailed()
- powershell: azure-pipelines/dotnet-test-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults
displayName: dotnet test
- powershell: azure-pipelines/variables/_pipelines.ps1
failOnStderr: true