-
Notifications
You must be signed in to change notification settings - Fork 2
/
benchmark-crank.ps1
executable file
·64 lines (52 loc) · 1.62 KB
/
benchmark-crank.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
61
62
63
64
#! /usr/bin/env pwsh
#Requires -PSEdition Core
#Requires -Version 7
param(
[Parameter(Mandatory = $true)][string] $PullRequestId,
[Parameter(Mandatory = $false)][string] $AccessToken,
[Parameter(Mandatory = $false)][string] $Benchmark = "root",
[Parameter(Mandatory = $false)][string] $CrankPath = "",
[Parameter(Mandatory = $false)][string] $Repository = "https://github.com/martincostello/api",
[Parameter(Mandatory = $false)][switch] $PublishResults
)
$crankAgent = "crank-agent"
$crankPR = "crank-pr"
if (-Not [string]::IsNullOrEmpty($CrankPath)) {
$crankAgent = Join-Path $CrankPath $crankAgent
$crankPR = Join-Path $CrankPath $crankPR
}
if ($IsWindows) {
$agent = Start-Process -FilePath $crankAgent -WindowStyle Hidden -PassThru
} else {
$agent = Start-Process -FilePath $crankAgent -PassThru
}
Start-Sleep -Seconds 2
$repoPath = $PSScriptRoot
$components = "api"
$config = Join-Path $repoPath "benchmark.yml"
$profiles = "local"
$additionalArgs = @()
if (-Not [string]::IsNullOrEmpty($AccessToken)) {
$additionalArgs += "--access-token"
$additionalArgs += $AccessToken
if ($PublishResults) {
$additionalArgs += "--publish-results"
$additionalArgs += "true"
}
}
try {
& $crankPR `
--benchmarks $Benchmark `
--components $components `
--config $config `
--profiles $profiles `
--pull-request $PullRequestId `
--repository $Repository `
$additionalArgs
}
finally {
Stop-Process -InputObject $agent -Force | Out-Null
}
if ($LASTEXITCODE -ne 0) {
throw "crank-pr failed with exit code $LASTEXITCODE"
}