Skip to content

Commit 264df39

Browse files
author
Bart Koelman
committed
cibuild matrix (Windows and Linux)
1 parent 3c8cbe7 commit 264df39

File tree

4 files changed

+77
-74
lines changed

4 files changed

+77
-74
lines changed

Build.ps1

Lines changed: 39 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
1-
# Gets the version suffix from the repo tag
2-
# example: v1.0.0-preview1-final => preview1-final
3-
function Get-Version-Suffix-From-Tag {
4-
$tag=$env:APPVEYOR_REPO_TAG_NAME
5-
$split=$tag -split "-"
6-
$suffix=$split[1..2]
7-
$final=$suffix -join "-"
8-
return $final
9-
}
10-
111
function CheckLastExitCode {
122
param ([int[]]$SuccessCodes = @(0), [scriptblock]$CleanupScript=$null)
133

144
if ($SuccessCodes -notcontains $LastExitCode) {
15-
$msg = "EXE RETURNED EXIT CODE $LastExitCode"
16-
throw $msg
5+
throw "Executable returned exit code $LastExitCode"
176
}
187
}
198

209
function RunInspectCode {
2110
$outputPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.xml')
22-
dotnet jb inspectcode JsonApiDotNetCore.MongoDb.sln --output="$outputPath" --profile=JsonApiDotNetCore-WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=SolutionPersonal -dsl=ProjectPersonal
11+
dotnet jb inspectcode JsonApiDotNetCore.MongoDb.sln --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=SolutionPersonal -dsl=ProjectPersonal
2312
CheckLastExitCode
2413

2514
[xml]$xml = Get-Content "$outputPath"
@@ -50,22 +39,24 @@ function RunCleanupCode {
5039
# When running in cibuild for a pull request, this reformats only the files changed in the PR and fails if the reformat produces changes.
5140

5241
if ($env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT) {
53-
Write-Output "Running code cleanup in cibuild for pull request"
42+
Write-Output "Running code cleanup on changed files in pull request"
5443

55-
$sourceCommitHash = $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT
44+
# In the past, we used $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT for the merge commit hash. That is the pinned hash at the time the build is enqueued.
45+
# When a force-push happens after that, while the build hasn't yet started, this hash becomes invalid during the build, resulting in a lookup error.
46+
# To prevent failing the build for unobvious reasons we use HEAD, which is always the latest version.
47+
$mergeCommitHash = git rev-parse "HEAD"
5648
$targetCommitHash = git rev-parse "$env:APPVEYOR_REPO_BRANCH"
5749

58-
Write-Output "Source commit hash = $sourceCommitHash"
59-
Write-Output "Target commit hash = $targetCommitHash"
60-
61-
dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --jb --profile --jb --profile='\"JADNC Full Cleanup\"' --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $sourceCommitHash -b $targetCommitHash --fail-on-diff --print-diff
50+
dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --jb --profile --jb --profile='\"JADNC Full Cleanup\"' --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $mergeCommitHash -b $targetCommitHash --fail-on-diff --print-diff
6251
CheckLastExitCode
6352
}
6453
}
6554

6655
function ReportCodeCoverage {
6756
if ($env:APPVEYOR) {
68-
dotnet codecov -f "**\coverage.cobertura.xml"
57+
if ($IsWindows) {
58+
dotnet codecov -f "**\coverage.cobertura.xml"
59+
}
6960
}
7061
else {
7162
dotnet reportgenerator -reports:**\coverage.cobertura.xml -targetdir:artifacts\coverage
@@ -74,8 +65,33 @@ function ReportCodeCoverage {
7465
CheckLastExitCode
7566
}
7667

77-
$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
78-
$revision = "{0:D4}" -f [convert]::ToInt32($revision, 10)
68+
function CreateNuGetPackage {
69+
if ($env:APPVEYOR_REPO_TAG -eq $true) {
70+
# Get the version suffix from the repo tag. Example: v1.0.0-preview1-final => preview1-final
71+
$segments = $env:APPVEYOR_REPO_TAG_NAME -split "-"
72+
$suffixSegments = $segments[1..2]
73+
$versionSuffix = $suffixSegments -join "-"
74+
}
75+
else {
76+
# Get the version suffix from the auto-incrementing build number. Example: "123" => "pre-0123".
77+
if ($env:APPVEYOR_BUILD_NUMBER) {
78+
$revision = "{0:D4}" -f [convert]::ToInt32($env:APPVEYOR_BUILD_NUMBER, 10)
79+
$versionSuffix = "pre-$revision"
80+
}
81+
else {
82+
$versionSuffix = "pre-0001"
83+
}
84+
}
85+
86+
if ([string]::IsNullOrWhitespace($versionSuffix)) {
87+
dotnet pack .\src\JsonApiDotNetCore.MongoDb -c Release -o .\artifacts
88+
}
89+
else {
90+
dotnet pack .\src\JsonApiDotNetCore.MongoDb -c Release -o .\artifacts --version-suffix=$versionSuffix
91+
}
92+
93+
CheckLastExitCode
94+
}
7995

8096
dotnet tool restore
8197
CheckLastExitCode
@@ -91,27 +107,4 @@ CheckLastExitCode
91107

92108
ReportCodeCoverage
93109

94-
Write-Output "APPVEYOR_REPO_TAG: $env:APPVEYOR_REPO_TAG"
95-
96-
if ($env:APPVEYOR_REPO_TAG -eq $true) {
97-
$revision = Get-Version-Suffix-From-Tag
98-
Write-Output "VERSION-SUFFIX: $revision"
99-
100-
if ([string]::IsNullOrWhitespace($revision)) {
101-
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore.MongoDb -c Release -o .\artifacts"
102-
dotnet pack .\src\JsonApiDotNetCore.MongoDb -c Release -o .\artifacts
103-
CheckLastExitCode
104-
}
105-
else {
106-
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore.MongoDb -c Release -o .\artifacts --version-suffix=$revision"
107-
dotnet pack .\src\JsonApiDotNetCore.MongoDb -c Release -o .\artifacts --version-suffix=$revision
108-
CheckLastExitCode
109-
}
110-
}
111-
else {
112-
$packageVersionSuffix="pre-$revision"
113-
Write-Output "VERSION-SUFFIX: $packageVersionSuffix"
114-
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore.MongoDb -c Release -o .\artifacts --version-suffix=$packageVersionSuffix"
115-
dotnet pack .\src\JsonApiDotNetCore.MongoDb -c Release -o .\artifacts --version-suffix=$packageVersionSuffix
116-
CheckLastExitCode
117-
}
110+
CreateNuGetPackage

appveyor.yml

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,51 @@
1-
version: '{build}'
2-
os: Visual Studio 2019
1+
image:
2+
- Ubuntu
3+
- Visual Studio 2019
34

4-
pull_requests:
5-
do_not_increment_build_number: true
5+
version: '{build}'
66

77
branches:
88
only:
99
- master
10+
- develop
11+
- unstable
1012
- /release\/.+/
1113

14+
pull_requests:
15+
do_not_increment_build_number: true
16+
1217
nuget:
1318
disable_publish_on_pr: true
1419

20+
matrix:
21+
fast_finish: true
22+
23+
for:
24+
-
25+
matrix:
26+
only:
27+
- image: Visual Studio 2019
28+
artifacts:
29+
- path: .\**\artifacts\**\*.nupkg
30+
name: NuGet
31+
deploy:
32+
- provider: NuGet
33+
skip_symbols: false
34+
api_key:
35+
secure: OBYPCgp3WCuwkDRMuZ9a4QcBdTja/lqlUwZ+Yl5VHqooSJRVTYKP5y15XK0fuHsZ
36+
on:
37+
branch: master
38+
appveyor_repo_tag: true
39+
- provider: NuGet
40+
skip_symbols: false
41+
api_key:
42+
secure: OBYPCgp3WCuwkDRMuZ9a4QcBdTja/lqlUwZ+Yl5VHqooSJRVTYKP5y15XK0fuHsZ
43+
on:
44+
branch: /release\/.+/
45+
appveyor_repo_tag: true
46+
1547
build_script:
1648
- pwsh: dotnet --version
1749
- pwsh: .\Build.ps1
1850

19-
test: off
20-
21-
artifacts:
22-
- path: .\**\artifacts\**\*.nupkg
23-
name: NuGet
24-
25-
deploy:
26-
- provider: NuGet
27-
name: production
28-
skip_symbols: false
29-
api_key:
30-
secure: ogA5YOVPy9v1Vd623/Jf79dzYlCb5NrXb1e7uHolnyVYTWVz7MporZ+KTVFpAQci
31-
on:
32-
branch: master
33-
appveyor_repo_tag: true
34-
35-
- provider: NuGet
36-
skip_symbols: false
37-
api_key:
38-
secure: ogA5YOVPy9v1Vd623/Jf79dzYlCb5NrXb1e7uHolnyVYTWVz7MporZ+KTVFpAQci
39-
on:
40-
branch: /release\/.+/
41-
appveyor_repo_tag: true
51+
test: off

inspectcode.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if ($LASTEXITCODE -ne 0) {
1616

1717
$outputPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.xml')
1818
$resultPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.html')
19-
dotnet jb inspectcode JsonApiDotNetCore.MongoDb.sln --output="$outputPath" --profile=JsonApiDotNetCore-WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=SolutionPersonal -dsl=ProjectPersonal
19+
dotnet jb inspectcode JsonApiDotNetCore.MongoDb.sln --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=SolutionPersonal -dsl=ProjectPersonal
2020

2121
if ($LASTEXITCODE -ne 0) {
2222
throw "Code inspection failed with exit code $LASTEXITCODE"

0 commit comments

Comments
 (0)