-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun-benchmarks.ps1
60 lines (47 loc) · 1.62 KB
/
run-benchmarks.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
param (
[string]$CurrentBranch = $Env:BUILD_SOURCEBRANCH
)
# Utils
function EnsureLastExitCode($message){
if ($LASTEXITCODE -ne 0) {
throw $message
}
}
# Git Information
if ($CurrentBranch -eq '') {
$CurrentBranch = git branch --show-current | Out-String
EnsureLastExitCode("git branch --show-current failed")
}
$CurrentBranch = $CurrentBranch.Trim()
"----------------------------------------"
"CurrentBranch: $CurrentBranch"
if ($CurrentBranch -eq '') {
Write-Error "Not branch or tag"
return
}
# Install tools
"----------------------------------------"
"Restoring dotnet tools"
dotnet tool restore
EnsureLastExitCode("Restore failed")
# Get GitVersion
"----------------------------------------"
"Getting GitVersion"
$Version = dotnet gitversion /output json /showvariable SemVer | Out-String -NoNewline
EnsureLastExitCode("Could not get SemVer from gitversion")
$Version = $Version.Trim()
"Git version: '$Version'"
"##vso[build.updatebuildnumber]$Version"
$PreReleaseTag = dotnet gitversion /output json /showvariable PreReleaseTag | Out-String -NoNewline
EnsureLastExitCode("Could not get PrReleaseTag from gitversion")
$PreReleaseTag = $PreReleaseTag.Trim()
$IsPreRelease = $PreReleaseTag -ne ''
"PreReleaseTag: $PreReleaseTag, IsPreRelease: $IsPreRelease"
"----------------------------------------"
"Benchmarks"
$BechmarkCmd = "dotnet run --project ./benchmarks/GraphQL.Benchmarks/GraphQL.Benchmarks.csproj -c Release --framework net8.0 -- -i -m --filter *execution*"
if ($IsPreRelease) {
$BechmarkCmd += " --job short"
}
Invoke-Expression $BechmarkCmd
EnsureLastExitCode("dotnet benchmarks failed")