diff options
author | Christopher A. Snapp <csnapp@chef.io> | 2020-05-15 15:30:10 -0600 |
---|---|---|
committer | Christopher A. Snapp <csnapp@chef.io> | 2020-05-22 09:07:56 -0600 |
commit | e2bc843096e4c91415751a5ad46d0bf07c82c89c (patch) | |
tree | 71acf191678f8201a5601e4f837f07e5c900a216 /scripts | |
parent | 261e0cfc7624be926d13afeeecf18d0f391bb073 (diff) | |
download | chef-e2bc843096e4c91415751a5ad46d0bf07c82c89c.tar.gz |
Refactor verify pipeline to use Ruby 2.7 in Windows
Signed-off-by: Christopher A. Snapp <csnapp@chef.io>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/bk_tests/bk_win_functional.ps1 | 97 | ||||
-rw-r--r-- | scripts/bk_tests/bk_win_integration.ps1 | 2 |
2 files changed, 15 insertions, 84 deletions
diff --git a/scripts/bk_tests/bk_win_functional.ps1 b/scripts/bk_tests/bk_win_functional.ps1 index b16dd3c1f7..8d1f5acb2d 100644 --- a/scripts/bk_tests/bk_win_functional.ps1 +++ b/scripts/bk_tests/bk_win_functional.ps1 @@ -1,112 +1,43 @@ -# The filename of the Ruby installer -$RubyFilename = "rubyinstaller-devkit-2.7.1-1-x64.exe" - -# The sha256 of the Ruby installer (capitalized?) -$RubySHA256 = "B22C5C1C819A53A1676CCA3410E3FF1BB39A9510C0CFD1E7BA19A728AE4FE86F" - -# Where on disk to download Ruby to -$RubyPath = "$env:temp\$RubyFilename" - -# Where to download Ruby from: -$RubyS3Path = "s3://public-cd-buildkite-cache/$RubyFilename" - -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 - - 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 - } - - # 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 - } - } - - echo "Moving file installer into place" - Rename-Item -Path "$RubyPath.$RandDigits" -NewName $RubyFilename -} - -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 "No Ruby found at $RubyPath, downloading" - DownloadRuby - } - - echo "Installing Ruby + DevKit" - Start-Process $RubyPath -ArgumentList '/verysilent /dir=C:\\ruby26' -Wait - - echo "Cleaning up installation" - Remove-Item $RubyPath -Force -ErrorAction SilentlyContinue -} - -echo "--- system details" +Write-Output "--- system details" $Properties = 'Caption', 'CSName', 'Version', 'BuildType', 'OSArchitecture' Get-CimInstance Win32_OperatingSystem | Select-Object $Properties | Format-Table -AutoSize # chocolatey functional tests fail so delete the chocolatey binary to avoid triggering them Remove-Item -Path C:\ProgramData\chocolatey\bin\choco.exe -ErrorAction SilentlyContinue -echo "--- install ruby + devkit" $ErrorActionPreference = 'Stop' -InstallRuby +Write-Output "--- Enable Ruby 2.7" +Write-Output "Add Uru to Environment PATH" +$env:PATH = "C:\Program Files (x86)\Uru;" + $env:PATH +[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine) -# Set-Item -Path Env:Path -Value to include ruby26 -$Env:Path+=";C:\ruby26\bin" +Write-Output "Register Installed Ruby Version 2.7 With Uru" +Start-Process "C:\Program Files (x86)\Uru\uru_rt.exe" -ArgumentList 'admin add C:\ruby27\bin' -Wait +uru 271 +if (-not $?) { throw "Can't Activate Ruby. Did Uru Registration Succeed?" } -echo "--- configure winrm" +Write-Output "--- configure winrm" winrm quickconfig -q -echo "--- update bundler" +Write-Output "--- update bundler" ruby -v if (-not $?) { throw "Can't run Ruby. Is it installed?" } $env:BUNDLER_VERSION=$(findstr bundler omnibus_overrides.rb | %{ $_.split(" ")[3] }) $env:BUNDLER_VERSION=($env:BUNDLER_VERSION -replace '"', "") -echo $env:BUNDLER_VERSION +Write-Output $env:BUNDLER_VERSION gem install bundler -v $env:BUNDLER_VERSION --force --no-document --quiet if (-not $?) { throw "Unable to update Bundler" } bundle --version -echo "--- bundle install" +Write-Output "--- bundle install" bundle install --jobs=3 --retry=3 --without omnibus_package docgen chefstyle if (-not $?) { throw "Unable to install gem dependencies" } -echo "+++ bundle exec rake spec:functional" +Write-Output "+++ bundle exec rake spec:functional" bundle exec rake spec:functional if (-not $?) { throw "Chef functional specs failing." } diff --git a/scripts/bk_tests/bk_win_integration.ps1 b/scripts/bk_tests/bk_win_integration.ps1 index 6337e460b7..6b0debc790 100644 --- a/scripts/bk_tests/bk_win_integration.ps1 +++ b/scripts/bk_tests/bk_win_integration.ps1 @@ -3,7 +3,7 @@ $PrepScript = Join-Path $CurrentDirectory "bk_win_prep.ps1" Invoke-Expression $PrepScript # 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" +$Env:Path="C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\ruby27\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" winrm quickconfig -q |