From 39caf532e7f60ff21050221fda627bab02de2ce8 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Tue, 6 Feb 2024 18:27:21 -0800 Subject: [PATCH] Move inline PS scripts into files Signed-off-by: Maksym Pavlenko (cherry picked from commit 32bd8eff9effa0789ba933ede01a94c7a70512b3) Signed-off-by: Akhil Mohan --- .github/workflows/ci.yml | 49 +------------------ .../setup/upgrade_chocolaty_windows_2019.ps1 | 8 +++ script/setup/upgrade_mingw_windows_2019.ps1 | 38 ++++++++++++++ 3 files changed, 48 insertions(+), 47 deletions(-) create mode 100644 script/setup/upgrade_chocolaty_windows_2019.ps1 create mode 100644 script/setup/upgrade_mingw_windows_2019.ps1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d78cf3057f3..a6f431e95583 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -249,57 +249,12 @@ jobs: - name: Upgrade Chocolaty on Windows 2019 if: matrix.os == 'windows-2019' shell: powershell - run: | - Write-Output '::group::Update chocolaty' - choco upgrade -y chocolatey - Write-Output '::endgroup::' - - if ( $LASTEXITCODE ) { - Write-Output '::error::Could not update chocolatey.' - exit $LASTEXITCODE - } + run: .\script\setup\upgrade_chocolaty_windows_2019.ps1 - name: Upgrade MinGW on Windows 2019 if: matrix.os == 'windows-2019' shell: powershell - run: | - # Add retry and backoff - foreach ( $i in 1..3 ) { - Write-Output "::group::Attempt $i" - if ( $i -gt 1 ) { - # remove any left-over state - choco uninstall -y --no-progress --force mingw - - Write-Output 'Sleeping for 60 seconds' - Sleep -Seconds 60 - } - - Write-Output 'manually force remove C:\mingw64' - Remove-Item -Path "C:\mingw64" -Recurse -Force -ErrorAction Ignore - - choco install -y --no-progress --stop-on-first-failure --force mingw --allow-downgrade --version 12.2.0.3042023 - Write-Output '::endgroup::' - if ( -not $LASTEXITCODE ) { - Write-Output "Attempt $i succeeded (exit code: $LASTEXITCODE)" - break - } - Write-Output "::warning title=mingw::Attempt $i failed (exit code: $LASTEXITCODE)" - } - - if ( $LASTEXITCODE ) { - Write-Output "::error::Could not install mingw after $i attempts." - exit $LASTEXITCODE - } - - # Copy to default path - Copy-Item -Path "C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64" -Destination "C:\mingw64" -Recurse -Force - - # Copy as make.exe - $path = "C:\mingw64\bin\mingw32-make.exe" | Get-Item - Copy-Item -Path $path.FullName -Destination (Join-Path $path.Directory.FullName 'make.exe') -Force - - # verify mingw32-make was installed - Get-Command -CommandType Application -ErrorAction Stop mingw32-make.exe + run: .\script\setup\upgrade_mingw_windows_2019.ps1 - name: Binaries shell: bash diff --git a/script/setup/upgrade_chocolaty_windows_2019.ps1 b/script/setup/upgrade_chocolaty_windows_2019.ps1 new file mode 100644 index 000000000000..272be331b22e --- /dev/null +++ b/script/setup/upgrade_chocolaty_windows_2019.ps1 @@ -0,0 +1,8 @@ +Write-Output '::group::Update chocolaty' +choco upgrade -y chocolatey +Write-Output '::endgroup::' + +if ( $LASTEXITCODE ) { + Write-Output '::error::Could not update chocolatey.' + exit $LASTEXITCODE +} diff --git a/script/setup/upgrade_mingw_windows_2019.ps1 b/script/setup/upgrade_mingw_windows_2019.ps1 new file mode 100644 index 000000000000..ea1554e376fe --- /dev/null +++ b/script/setup/upgrade_mingw_windows_2019.ps1 @@ -0,0 +1,38 @@ +# Add retry and backoff +foreach ( $i in 1..3 ) { + Write-Output "::group::Attempt $i" + if ( $i -gt 1 ) { + # remove any left-over state + choco uninstall -y --no-progress --force mingw + + Write-Output 'Sleeping for 60 seconds' + Sleep -Seconds 60 + } + + Write-Output 'manually force remove C:\mingw64' + Remove-Item -Path "C:\mingw64" -Recurse -Force -ErrorAction Ignore + + choco install -y --no-progress --stop-on-first-failure --force mingw --allow-downgrade --version 12.2.0.3042023 + Write-Output '::endgroup::' + if ( -not $LASTEXITCODE ) { + Write-Output "Attempt $i succeeded (exit code: $LASTEXITCODE)" + break + } + + Write-Output "::warning title=mingw::Attempt $i failed (exit code: $LASTEXITCODE)" +} + +if ( $LASTEXITCODE ) { + Write-Output "::error::Could not install mingw after $i attempts." + exit $LASTEXITCODE +} + +# Copy to default path +Copy-Item -Path "C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64" -Destination "C:\mingw64" -Recurse -Force + +# Copy as make.exe +$path = "C:\mingw64\bin\mingw32-make.exe" | Get-Item +Copy-Item -Path $path.FullName -Destination (Join-Path $path.Directory.FullName 'make.exe') -Force + +# verify mingw32-make was installed +Get-Command -CommandType Application -ErrorAction Stop mingw32-make.exe