Skip to content

Commit 28e838e

Browse files
committed
Apply latest Library.Template
2 parents 538af29 + 2bcf967 commit 28e838e

26 files changed

+363
-119
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ _TeamCity*
140140
# Visual Studio code coverage results
141141
*.coverage
142142
*.coveragexml
143+
/coveragereport/
143144

144145
# NCrunch
145146
_NCrunch_*

Directory.Build.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<DebugType>embedded</DebugType>
2424

2525
<SignAssembly>true</SignAssembly>
26-
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)\strongname.snk</AssemblyOriginatorKeyFile>
26+
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)strongname.snk</AssemblyOriginatorKeyFile>
2727

2828
<Authors>Andrew Arnott</Authors>
2929
<Owners>aarnott</Owners>
@@ -42,9 +42,9 @@
4242
<ItemGroup>
4343
<PackageReference Include="CSharpIsNullAnalyzer" Version="0.1.300" PrivateAssets="all" />
4444
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
45-
<PackageReference Include="Nullable" Version="1.3.0" PrivateAssets="all" />
45+
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="all" />
4646
<!-- Use the Unstable package ID so that update tools will help us keep it current even though it seems to be ever-unstable lately. -->
47-
<PackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.406" PrivateAssets="all" />
47+
<PackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.435" PrivateAssets="all" />
4848
</ItemGroup>
4949
<ItemGroup>
5050
<None Include="$(MSBuildThisFileDirectory)3rdPartyNotices.txt" Pack="true" PackagePath="" />
@@ -81,7 +81,7 @@
8181
It's also not necessary to generate these assets.
8282
-->
8383
<PropertyGroup Condition="'$(IsWpfTempProject)' == 'true'">
84-
<_WpfTempProjectNuGetFilePathNoExt>$(RepoRootPath)obj\$(_TargetAssemblyProjectName)\$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g</_WpfTempProjectNuGetFilePathNoExt>
84+
<_WpfTempProjectNuGetFilePathNoExt>$(BaseIntermediateOutputPath)..\$(_TargetAssemblyProjectName)\$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g</_WpfTempProjectNuGetFilePathNoExt>
8585

8686
<EnableSourceLink>false</EnableSourceLink>
8787
<EmbedUntrackedSources>false</EmbedUntrackedSources>

azure-pipelines.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ trigger:
1313
- .github/
1414
- azure-pipelines/release.yml
1515

16+
parameters:
17+
- name: RunTests
18+
displayName: Run tests
19+
type: boolean
20+
default: true
21+
1622
resources:
1723
containers:
1824
- container: xenial
@@ -37,9 +43,12 @@ stages:
3743
- stage: Build
3844
jobs:
3945
- template: azure-pipelines/build.yml
46+
parameters:
47+
RunTests: ${{ parameters.RunTests }}
4048

4149
- stage: Test
4250
displayName: Functional testing
51+
condition: and(succeeded(), ${{ parameters.RunTests }})
4352
jobs:
4453
- job: linux
4554
strategy:
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<#
2+
.SYNOPSIS
3+
Downloads the CodeCov.io uploader tool and returns the path to it.
4+
.PARAMETER AllowSkipVerify
5+
Allows skipping signature verification of the downloaded tool if gpg is not installed.
6+
#>
7+
[CmdletBinding()]
8+
Param(
9+
[switch]$AllowSkipVerify
10+
)
11+
12+
if ($IsMacOS) {
13+
$codeCovUrl = "https://uploader.codecov.io/latest/macos/codecov"
14+
$toolName = 'codecov'
15+
}
16+
elseif ($IsLinux) {
17+
$codeCovUrl = "https://uploader.codecov.io/latest/linux/codecov"
18+
$toolName = 'codecov'
19+
}
20+
else {
21+
$codeCovUrl = "https://uploader.codecov.io/latest/windows/codecov.exe"
22+
$toolName = 'codecov.exe'
23+
}
24+
25+
$shaSuffix = ".SHA256SUM"
26+
$sigSuffix = $shaSuffix + ".sig"
27+
28+
Function Get-FileFromWeb([Uri]$Uri, $OutDir) {
29+
$OutFile = Join-Path $OutDir $Uri.Segments[-1]
30+
if (!(Test-Path $OutFile)) {
31+
Write-Verbose "Downloading $Uri..."
32+
if (!(Test-Path $OutDir)) { New-Item -ItemType Directory -Path $OutDir | Out-Null }
33+
try {
34+
(New-Object System.Net.WebClient).DownloadFile($Uri, $OutFile)
35+
} finally {
36+
# This try/finally causes the script to abort
37+
}
38+
}
39+
40+
$OutFile
41+
}
42+
43+
$toolsPath = & "$PSScriptRoot\Get-TempToolsPath.ps1"
44+
$binaryToolsPath = Join-Path $toolsPath codecov
45+
$testingPath = Join-Path $binaryToolsPath unverified
46+
$finalToolPath = Join-Path $binaryToolsPath $toolName
47+
48+
if (!(Test-Path $finalToolPath)) {
49+
if (Test-Path $testingPath) {
50+
Remove-Item -Recurse -Force $testingPath # ensure we download all matching files
51+
}
52+
$tool = Get-FileFromWeb $codeCovUrl $testingPath
53+
$sha = Get-FileFromWeb "$codeCovUrl$shaSuffix" $testingPath
54+
$sig = Get-FileFromWeb "$codeCovUrl$sigSuffix" $testingPath
55+
$key = Get-FileFromWeb https://keybase.io/codecovsecurity/pgp_keys.asc $testingPath
56+
57+
if ((Get-Command gpg -ErrorAction SilentlyContinue)) {
58+
Write-Host "Importing codecov key" -ForegroundColor Yellow
59+
gpg --import $key
60+
Write-Host "Verifying signature on codecov hash" -ForegroundColor Yellow
61+
gpg --verify $sig $sha
62+
} else {
63+
if ($AllowSkipVerify) {
64+
Write-Warning "gpg not found. Unable to verify hash signature."
65+
} else {
66+
throw "gpg not found. Unable to verify hash signature. Install gpg or add -AllowSkipVerify to override."
67+
}
68+
}
69+
70+
Write-Host "Verifying hash on downloaded tool" -ForegroundColor Yellow
71+
$actualHash = (Get-FileHash -Path $tool -Algorithm SHA256).Hash
72+
$expectedHash = (Get-Content $sha).Split()[0]
73+
if ($actualHash -ne $expectedHash) {
74+
# Validation failed. Delete the tool so we can't execute it.
75+
#Remove-Item $codeCovPath
76+
throw "codecov uploader tool failed signature validation."
77+
}
78+
79+
Copy-Item $tool $finalToolPath
80+
81+
if ($IsMacOS -or $IsLinux) {
82+
chmod u+x $finalToolPath
83+
}
84+
}
85+
86+
return $finalToolPath

azure-pipelines/Get-SymbolFiles.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Write-Progress -Activity $ActivityName -CurrentOperation "Discovery PDB files"
1818
$PDBs = Get-ChildItem -rec "$Path/*.pdb"
1919

2020
# Filter PDBs to product OR test related.
21-
$testregex = "unittest|tests"
21+
$testregex = "unittest|tests|\.test\."
2222

2323
Write-Progress -Activity $ActivityName -CurrentOperation "De-duplicating symbols"
2424
$PDBsByHash = @{}
@@ -49,8 +49,13 @@ $PDBs |% {
4949
$BinaryImagePath = $dllPath
5050
} elseif (Test-Path $exePath) {
5151
$BinaryImagePath = $exePath
52+
} else {
53+
Write-Warning "`"$_`" found with no matching binary file."
54+
$BinaryImagePath = $null
5255
}
5356

54-
Write-Output $BinaryImagePath
55-
Write-Output $_.FullName
57+
if ($BinaryImagePath) {
58+
Write-Output $BinaryImagePath
59+
Write-Output $_.FullName
60+
}
5661
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env pwsh
2+
3+
<#
4+
.SYNOPSIS
5+
Merges code coverage reports.
6+
.PARAMETER Path
7+
The path(s) to search for Cobertura code coverage reports.
8+
.PARAMETER Format
9+
The format for the merged result. The default is Cobertura
10+
.PARAMETER OutputDir
11+
The directory the merged result will be written to. The default is `coveragereport` in the root of this repo.
12+
#>
13+
[CmdletBinding()]
14+
Param(
15+
[Parameter(Mandatory=$true)]
16+
[string[]]$Path,
17+
[ValidateSet('Badges', 'Clover', 'Cobertura', 'CsvSummary', 'Html', 'Html_Dark', 'Html_Light', 'HtmlChart', 'HtmlInline', 'HtmlInline_AzurePipelines', 'HtmlInline_AzurePipelines_Dark', 'HtmlInline_AzurePipelines_Light', 'HtmlSummary', 'JsonSummary', 'Latex', 'LatexSummary', 'lcov', 'MarkdownSummary', 'MHtml', 'PngChart', 'SonarQube', 'TeamCitySummary', 'TextSummary', 'Xml', 'XmlSummary')]
18+
[string]$Format='Cobertura',
19+
[string]$OutputDir=("$PSScriptRoot/../coveragereport")
20+
)
21+
22+
$RepoRoot = [string](Resolve-Path $PSScriptRoot/..)
23+
24+
if (!(Test-Path $RepoRoot/obj/reportgenerator*)) {
25+
dotnet tool install --tool-path $RepoRoot/obj dotnet-reportgenerator-globaltool --version 5.1.9 --configfile $PSScriptRoot/justnugetorg.nuget.config
26+
}
27+
28+
Write-Verbose "Searching $Path for *.cobertura.xml files"
29+
$reports = Get-ChildItem -Recurse $Path -Filter *.cobertura.xml
30+
31+
if ($reports) {
32+
$reports |% { $_.FullName } |% {
33+
# In addition to replacing {reporoot}, we also normalize on one kind of slash so that the report aggregates data for a file whether data was collected on Windows or not.
34+
$xml = [xml](Get-Content -Path $_)
35+
$xml.coverage.packages.package.classes.class |? { $_.filename} |% {
36+
$_.filename = $_.filename.Replace('{reporoot}', $RepoRoot).Replace([IO.Path]::AltDirectorySeparatorChar, [IO.Path]::DirectorySeparatorChar)
37+
}
38+
39+
$xml.Save($_)
40+
}
41+
42+
$Inputs = [string]::join(';', ($reports |% { Resolve-Path -relative $_.FullName }))
43+
& "$RepoRoot/obj/reportgenerator" -reports:"$Inputs" -targetdir:$OutputDir -reporttypes:$Format
44+
} else {
45+
Write-Error "No reports found to merge."
46+
}

azure-pipelines/artifacts/_all.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
Executes artifact scripts even if they have already been staged.
1616
#>
1717

18+
[CmdletBinding(SupportsShouldProcess = $true)]
1819
param (
1920
[string]$ArtifactNameSuffix,
2021
[switch]$Force

azure-pipelines/artifacts/_pipelines.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
# This script translates all the artifacts described by _all.ps1
2-
# into commands that instruct Azure Pipelines to actually collect those artifacts.
1+
<#
2+
.SYNOPSIS
3+
This script translates all the artifacts described by _all.ps1
4+
into commands that instruct Azure Pipelines to actually collect those artifacts.
5+
#>
36

7+
[CmdletBinding()]
48
param (
59
[string]$ArtifactNameSuffix,
610
[switch]$StageOnly

azure-pipelines/artifacts/_stage_all.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
# This script links all the artifacts described by _all.ps1
2-
# into a staging directory, reading for uploading to a cloud build artifact store.
3-
# It returns a sequence of objects with Name and Path properties.
1+
<#
2+
.SYNOPSIS
3+
This script links all the artifacts described by _all.ps1
4+
into a staging directory, reading for uploading to a cloud build artifact store.
5+
It returns a sequence of objects with Name and Path properties.
6+
#>
7+
48
[CmdletBinding()]
59
param (
610
[string]$ArtifactNameSuffix

azure-pipelines/artifacts/coverageResults.ps1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..")
22

3+
$coverageFiles = @(Get-ChildItem "$RepoRoot/test/*.cobertura.xml" -Recurse | Where {$_.FullName -notlike "*/In/*" -and $_.FullName -notlike "*\In\*" })
4+
35
# Prepare code coverage reports for merging on another machine
46
if ($env:SYSTEM_DEFAULTWORKINGDIRECTORY) {
57
Write-Host "Substituting $env:SYSTEM_DEFAULTWORKINGDIRECTORY with `"{reporoot}`""
6-
$reports = Get-ChildItem "$RepoRoot/bin/coverage.*cobertura.xml" -Recurse
7-
$reports |% {
8+
$coverageFiles |% {
89
$content = Get-Content -Path $_ |% { $_ -Replace [regex]::Escape($env:SYSTEM_DEFAULTWORKINGDIRECTORY), "{reporoot}" }
910
Set-Content -Path $_ -Value $content -Encoding UTF8
1011
}
@@ -16,7 +17,7 @@ if (!((Test-Path $RepoRoot\bin) -and (Test-Path $RepoRoot\obj))) { return }
1617

1718
@{
1819
$RepoRoot = (
19-
@(Get-ChildItem "$RepoRoot\bin\coverage.*cobertura.xml" -Recurse) +
20+
$coverageFiles +
2021
(Get-ChildItem "$RepoRoot\obj\*.cs" -Recurse)
2122
);
2223
}

0 commit comments

Comments
 (0)