Skip to content

Commit 3b3e537

Browse files
kiashokakhilerm
authored andcommitted
Uninstall mingw before attempting upgrade
Signed-off-by: Kirtana Ashok <[email protected]> (cherry picked from commit 21640c5) Signed-off-by: Akhil Mohan <[email protected]>
1 parent 9e24388 commit 3b3e537

1 file changed

Lines changed: 54 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,6 @@ jobs:
196196
- uses: actions/checkout@v4
197197
- uses: ./.github/actions/install-go
198198

199-
# NOTE(aznashwan): starting with Golang 1.21, the windows-2019 GitHub runner's
200-
# builtin MinGW version leads to DLL loading errors during runtime.
201-
- name: Upgrade MinGW on Windows 2019
202-
if: matrix.os == 'windows-2019'
203-
run: choco upgrade mingw
204-
205199
- name: Make
206200
run: |
207201
make build
@@ -251,13 +245,64 @@ jobs:
251245
252246
- run: script/setup/install-dev-tools
253247

254-
# NOTE(aznashwan): starting with Golang 1.21, the windows-2019 GitHub runner's
255-
# builtin MinGW version leads to DLL loading errors during runtime.
248+
# needs to be a separate step since terminal reload is required to bring in new env variables and PATH
249+
- name: Upgrade Chocolaty on Windows 2019
250+
if: matrix.os == 'windows-2019'
251+
shell: powershell
252+
run: |
253+
Write-Output '::group::Update chocolaty'
254+
choco upgrade -y chocolatey
255+
Write-Output '::endgroup::'
256+
257+
if ( $LASTEXITCODE ) {
258+
Write-Output '::error::Could not update chocolatey.'
259+
exit $LASTEXITCODE
260+
}
261+
256262
- name: Upgrade MinGW on Windows 2019
257263
if: matrix.os == 'windows-2019'
258-
run: choco upgrade mingw
264+
shell: powershell
265+
run: |
266+
# Add retry and backoff
267+
foreach ( $i in 1..3 ) {
268+
Write-Output "::group::Attempt $i"
269+
if ( $i -gt 1 ) {
270+
# remove any left-over state
271+
choco uninstall -y --no-progress --force mingw
272+
273+
Write-Output 'Sleeping for 60 seconds'
274+
Sleep -Seconds 60
275+
}
276+
277+
Write-Output 'manually force remove C:\mingw64'
278+
Remove-Item -Path "C:\mingw64" -Recurse -Force -ErrorAction Ignore
279+
280+
choco install -y --no-progress --stop-on-first-failure --force mingw --allow-downgrade --version 12.2.0.3042023
281+
Write-Output '::endgroup::'
282+
if ( -not $LASTEXITCODE ) {
283+
Write-Output "Attempt $i succeeded (exit code: $LASTEXITCODE)"
284+
break
285+
}
286+
Write-Output "::warning title=mingw::Attempt $i failed (exit code: $LASTEXITCODE)"
287+
}
288+
289+
if ( $LASTEXITCODE ) {
290+
Write-Output "::error::Could not install mingw after $i attempts."
291+
exit $LASTEXITCODE
292+
}
293+
294+
# Copy to default path
295+
Copy-Item -Path "C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64" -Destination "C:\mingw64" -Recurse -Force
296+
297+
# Copy as make.exe
298+
$path = "C:\mingw64\bin\mingw32-make.exe" | Get-Item
299+
Copy-Item -Path $path.FullName -Destination (Join-Path $path.Directory.FullName 'make.exe') -Force
300+
301+
# verify mingw32-make was installed
302+
Get-Command -CommandType Application -ErrorAction Stop mingw32-make.exe
259303
260304
- name: Binaries
305+
shell: bash
261306
env:
262307
CGO_ENABLED: 1
263308
run: |

0 commit comments

Comments
 (0)