Skip to content

Commit cb6d1a8

Browse files
committed
Adds test to make sure readme and csproj align.
1 parent 0731836 commit cb6d1a8

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

TestReadmeVersion.ps1

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
$ReadmePath = Join-Path $PSScriptRoot 'README.md'
2+
If (-not (Test-Path $ReadmePath)) {
3+
Write-Error 'Unable to find README.md'
4+
Exit 1
5+
}
6+
7+
$ReadmeContents = Get-Content $ReadmePath -Raw
8+
[regex]$Regex = 'dotnet tool install --global https --version (.+)-\*'
9+
$Match = $Regex.Match($ReadmeContents)
10+
If (-not $Match.Success) {
11+
Write-Error 'Unable to find version information in README.md'
12+
Exit 1
13+
}
14+
15+
$HttpsCsprojPath = Join-Path $PSScriptRoot 'src/https/https.csproj'
16+
If (-not (Test-Path $HttpsCsprojPath)) {
17+
Write-Error 'Unable to find https.csproj'
18+
Exit 1
19+
}
20+
21+
[xml]$HttpsCsproj = Get-Content $HttpsCsprojPath
22+
23+
$Expected = $HttpsCsproj.Project.PropertyGroup.VersionPrefix |
24+
Where-Object { $null -ne $_ } |
25+
ForEach-Object { $_.ToString().Trim() }
26+
$Actual = $Match.Groups[1].ToString().Trim()
27+
If ($Expected -ne $Actual) {
28+
Write-Error "Expected to have ${Expected} version in README.md, but found ${Actual}"
29+
Exit 1
30+
}

azure-pipelines.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ variables:
1010
buildConfiguration: 'Release'
1111

1212
steps:
13+
- task: PowerShell@2
14+
inputs:
15+
filePath: 'TestReadmeVersion.ps1'
16+
failOnStderr: true
17+
1318
- task: DotNetCoreCLI@2
1419
displayName: Pack https
1520
inputs:

0 commit comments

Comments
 (0)