diff options
author | Robb Kidd <robb@thekidds.org> | 2020-04-28 17:37:28 -0400 |
---|---|---|
committer | Robb Kidd <robb@thekidds.org> | 2020-04-28 17:37:28 -0400 |
commit | 9a3132f07b694fe78480298487f5f63566a4f8b2 (patch) | |
tree | 1e7e50fc742ca0799464fa06c3f442ed18e904da | |
parent | f99f7463f2aa5cd6373ce25188853f003c147682 (diff) | |
download | chef-robb/refactor-pr-verify-testing.tar.gz |
only perform system setup if running in buildkiterobb/refactor-pr-verify-testing
Signed-off-by: Robb Kidd <robb@thekidds.org>
-rw-r--r-- | scripts/bk_tests/bk_run_choco.ps1 | 6 | ||||
-rw-r--r-- | scripts/bk_tests/bk_win_functional.ps1 | 125 | ||||
-rw-r--r-- | scripts/bk_tests/bk_win_integration.ps1 | 11 | ||||
-rw-r--r-- | scripts/bk_tests/bk_win_unit.ps1 | 6 |
4 files changed, 79 insertions, 69 deletions
diff --git a/scripts/bk_tests/bk_run_choco.ps1 b/scripts/bk_tests/bk_run_choco.ps1 index 01d0a75a0d..c3ad8016d4 100644 --- a/scripts/bk_tests/bk_run_choco.ps1 +++ b/scripts/bk_tests/bk_run_choco.ps1 @@ -1,5 +1,7 @@ -$BKScriptDir = Split-Path $script:MyInvocation.MyCommand.Path -& "$BKScriptDir\win_setup.ps1" +if (Test-Path env:BUILDKITE) { + $BKScriptDir = Split-Path $script:MyInvocation.MyCommand.Path + & "$BKScriptDir\win_setup.ps1" +} echo "+++ Chocolatey version +++" choco --version diff --git a/scripts/bk_tests/bk_win_functional.ps1 b/scripts/bk_tests/bk_win_functional.ps1 index c77aaab8f7..0ebf0ac59c 100644 --- a/scripts/bk_tests/bk_win_functional.ps1 +++ b/scripts/bk_tests/bk_win_functional.ps1 @@ -1,86 +1,89 @@ -# The filename of the Ruby installer -$RubyFilename = "rubyinstaller-devkit-2.6.5-1-x64.exe" +if (Test-Path env:BUILDKITE) { + # The filename of the Ruby installer + $RubyFilename = "rubyinstaller-devkit-2.6.5-1-x64.exe" -# The sha256 of the Ruby installer (capitalized?) -$RubySHA256 = "BD2050496A149C7258ED4E2E44103756CA3A05C7328A939F0FDC97AE9616A96D" + # The sha256 of the Ruby installer (capitalized?) + $RubySHA256 = "BD2050496A149C7258ED4E2E44103756CA3A05C7328A939F0FDC97AE9616A96D" -# Where on disk to download Ruby to -$RubyPath = "$env:temp\$RubyFilename" + # Where on disk to download Ruby to + $RubyPath = "$env:temp\$RubyFilename" -# Where to download Ruby from: -$RubyS3Path = "s3://public-cd-buildkite-cache/$RubyFilename" + # Where to download Ruby from: + $RubyS3Path = "s3://public-cd-buildkite-cache/$RubyFilename" -Function DownloadRuby -{ - $RandDigits = Get-Random - echo "Downloading Ruby + DevKit" + Function DownloadRuby + { + $RandDigits = Get-Random + echo "Downloading Ruby + DevKit" - aws s3 cp "$RubyS3Path" "$RubyPath.$RandDigits" | Out-Null # Out-Null is a hack to wait for the process to complete + aws s3 cp "$RubyS3Path" "$RubyPath.$RandDigits" | Out-Null # Out-Null is a hack to wait for the process to complete - if ($LASTEXITCODE -ne 0) { - echo "aws s3 download failed: $LASTEXITCODE" - exit $LASTEXITCODE - } - - $FileHash = (Get-FileHash "$RubyPath.$RandDigits" -Algorithm SHA256).Hash - If ($FileHash -eq $RubySHA256) { - echo "Downloaded SHA256 matches: $FileHash" - } Else { - echo "Downloaded file hash $FileHash does not match desired $RubySHA256" - exit 1 - } + if ($LASTEXITCODE -ne 0) { + echo "aws s3 download failed: $LASTEXITCODE" + exit $LASTEXITCODE + } - # On a shared filesystem, sometimes a good file appears while we are downloading - If (Test-Path $RubyPath) { - $FileHash = (Get-FileHash "$RubyPath" -Algorithm SHA256).Hash + $FileHash = (Get-FileHash "$RubyPath.$RandDigits" -Algorithm SHA256).Hash If ($FileHash -eq $RubySHA256) { - echo "A matching file appeared while downloading, using it." - Remove-Item "$RubyPath.$RandDigits" -Force - Return + echo "Downloaded SHA256 matches: $FileHash" } Else { - echo "Existing file does not match, bad hash: $FileHash" - Remove-Item $RubyPath -Force + echo "Downloaded file hash $FileHash does not match desired $RubySHA256" + exit 1 } - } - echo "Moving file installer into place" - Rename-Item -Path "$RubyPath.$RandDigits" -NewName $RubyFilename -} + # On a shared filesystem, sometimes a good file appears while we are downloading + If (Test-Path $RubyPath) { + $FileHash = (Get-FileHash "$RubyPath" -Algorithm SHA256).Hash + If ($FileHash -eq $RubySHA256) { + echo "A matching file appeared while downloading, using it." + Remove-Item "$RubyPath.$RandDigits" -Force + Return + } Else { + echo "Existing file does not match, bad hash: $FileHash" + Remove-Item $RubyPath -Force + } + } -Function InstallRuby -{ - If (Test-Path $RubyPath) { - echo "$RubyPath already exists" + echo "Moving file installer into place" + Rename-Item -Path "$RubyPath.$RandDigits" -NewName $RubyFilename + } - $FileHash = (Get-FileHash "$RubyPath" -Algorithm SHA256).Hash - If ($FileHash -eq $RubySHA256) { - echo "Found matching Ruby + DevKit on disk" + Function InstallRuby + { + If (Test-Path $RubyPath) { + echo "$RubyPath already exists" + + $FileHash = (Get-FileHash "$RubyPath" -Algorithm SHA256).Hash + If ($FileHash -eq $RubySHA256) { + echo "Found matching Ruby + DevKit on disk" + } Else { + echo "SHA256 hash mismatch, re-downloading" + DownloadRuby + } } Else { - echo "SHA256 hash mismatch, re-downloading" + echo "No Ruby found at $RubyPath, downloading" DownloadRuby } - } Else { - echo "No Ruby found at $RubyPath, downloading" - DownloadRuby - } - echo "Installing Ruby + DevKit" - Start-Process $RubyPath -ArgumentList '/verysilent /dir=C:\\ruby26' -Wait + echo "Installing Ruby + DevKit" + Start-Process $RubyPath -ArgumentList '/verysilent /dir=C:\\ruby26' -Wait - echo "Cleaning up installation" - Remove-Item $RubyPath -Force -ErrorAction SilentlyContinue -} + echo "Cleaning up installation" + Remove-Item $RubyPath -Force -ErrorAction SilentlyContinue + } + + echo "--- install ruby + devkit" + $ErrorActionPreference = 'Stop' -echo "--- install ruby + devkit" -$ErrorActionPreference = 'Stop' + InstallRuby -InstallRuby + # Set-Item -Path Env:Path -Value to include ruby26 + $Env:Path+=";C:\ruby26\bin" -# Set-Item -Path Env:Path -Value to include ruby26 -$Env:Path+=";C:\ruby26\bin" -$BKScriptDir = Split-Path $script:MyInvocation.MyCommand.Path -& "$BKScriptDir\win_setup.ps1" + $BKScriptDir = Split-Path $script:MyInvocation.MyCommand.Path + & "$BKScriptDir\win_setup.ps1" +} echo "+++ bundle exec rake spec:functional (minus chocolatey tests)" # chocolatey functional tests are shakey so exclude them from this function test run diff --git a/scripts/bk_tests/bk_win_integration.ps1 b/scripts/bk_tests/bk_win_integration.ps1 index a2652759c1..79152d7558 100644 --- a/scripts/bk_tests/bk_win_integration.ps1 +++ b/scripts/bk_tests/bk_win_integration.ps1 @@ -1,8 +1,11 @@ -$BKScriptDir = Split-Path $script:MyInvocation.MyCommand.Path -& "$BKScriptDir\win_setup.ps1" +if (Test-Path env:BUILDKITE) { + $BKScriptDir = Split-Path $script:MyInvocation.MyCommand.Path + & "$BKScriptDir\win_setup.ps1" + + # Set-Item -Path Env:Path -Value ($Env:Path + ";C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin") + $Env:Path="C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\ruby26\bin;C:\ci-studio-common\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Users\ContainerAdministrator\AppData\Local\Microsoft\WindowsApps;C:\Go\bin;C:\Users\ContainerAdministrator\go\bin" +} -# Set-Item -Path Env:Path -Value ($Env:Path + ";C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin") -$Env:Path="C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\ruby26\bin;C:\ci-studio-common\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Users\ContainerAdministrator\AppData\Local\Microsoft\WindowsApps;C:\Go\bin;C:\Users\ContainerAdministrator\go\bin" echo "+++ bundle exec rake spec:integration" bundle exec rake spec:integration diff --git a/scripts/bk_tests/bk_win_unit.ps1 b/scripts/bk_tests/bk_win_unit.ps1 index 437cad9e49..c77c4a97e8 100644 --- a/scripts/bk_tests/bk_win_unit.ps1 +++ b/scripts/bk_tests/bk_win_unit.ps1 @@ -1,5 +1,7 @@ -$BKScriptDir = Split-Path $script:MyInvocation.MyCommand.Path -& "$BKScriptDir\win_setup.ps1" +if (Test-Path env:BUILDKITE) { + $BKScriptDir = Split-Path $script:MyInvocation.MyCommand.Path + & "$BKScriptDir\win_setup.ps1" +} echo "+++ bundle exec rake" bundle exec rake spec:unit |