Skip to content

Commit dd7f7bd

Browse files
authored
Merge pull request containerd#9288 from kiashok/updateCI-main
Uninstall mingw before attempting upgrade
2 parents 46bca49 + 21640c5 commit dd7f7bd

File tree

1 file changed

+54
-11
lines changed

1 file changed

+54
-11
lines changed

.github/workflows/ci.yml

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,6 @@ jobs:
218218

219219
- uses: actions/checkout@v4
220220

221-
# NOTE(aznashwan): starting with Golang 1.21, the windows-2019 GitHub runner's
222-
# builtin MinGW version leads to DLL loading errors during runtime.
223-
- name: Upgrade MinGW on Windows 2019
224-
if: matrix.os == 'windows-2019'
225-
run: |
226-
choco upgrade mingw --version=12.2.0.3042023
227-
228221
- name: Make
229222
run: |
230223
make build
@@ -244,7 +237,7 @@ jobs:
244237
strategy:
245238
fail-fast: false
246239
matrix:
247-
os: [windows-2022] # windows-2019 is temporarily removed until mingw issue fixed
240+
os: [windows-2022, windows-2019]
248241

249242
defaults:
250243
run:
@@ -275,14 +268,64 @@ jobs:
275268
276269
- run: script/setup/install-dev-tools
277270

278-
# NOTE(aznashwan): starting with Golang 1.21, the windows-2019 GitHub runner's
279-
# builtin MinGW version leads to DLL loading errors during runtime.
271+
# needs to be a separate step since terminal reload is required to bring in new env variables and PATH
272+
- name: Upgrade Chocolaty on Windows 2019
273+
if: matrix.os == 'windows-2019'
274+
shell: powershell
275+
run: |
276+
Write-Output '::group::Update chocolaty'
277+
choco upgrade -y chocolatey
278+
Write-Output '::endgroup::'
279+
280+
if ( $LASTEXITCODE ) {
281+
Write-Output '::error::Could not update chocolatey.'
282+
exit $LASTEXITCODE
283+
}
284+
280285
- name: Upgrade MinGW on Windows 2019
281286
if: matrix.os == 'windows-2019'
287+
shell: powershell
282288
run: |
283-
choco upgrade mingw --version=12.2.0.3042023
289+
# Add retry and backoff
290+
foreach ( $i in 1..3 ) {
291+
Write-Output "::group::Attempt $i"
292+
if ( $i -gt 1 ) {
293+
# remove any left-over state
294+
choco uninstall -y --no-progress --force mingw
295+
296+
Write-Output 'Sleeping for 60 seconds'
297+
Sleep -Seconds 60
298+
}
299+
300+
Write-Output 'manually force remove C:\mingw64'
301+
Remove-Item -Path "C:\mingw64" -Recurse -Force -ErrorAction Ignore
302+
303+
choco install -y --no-progress --stop-on-first-failure --force mingw --allow-downgrade --version 12.2.0.3042023
304+
Write-Output '::endgroup::'
305+
if ( -not $LASTEXITCODE ) {
306+
Write-Output "Attempt $i succeeded (exit code: $LASTEXITCODE)"
307+
break
308+
}
309+
Write-Output "::warning title=mingw::Attempt $i failed (exit code: $LASTEXITCODE)"
310+
}
311+
312+
if ( $LASTEXITCODE ) {
313+
Write-Output "::error::Could not install mingw after $i attempts."
314+
exit $LASTEXITCODE
315+
}
316+
317+
# Copy to default path
318+
Copy-Item -Path "C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64" -Destination "C:\mingw64" -Recurse -Force
319+
320+
# Copy as make.exe
321+
$path = "C:\mingw64\bin\mingw32-make.exe" | Get-Item
322+
Copy-Item -Path $path.FullName -Destination (Join-Path $path.Directory.FullName 'make.exe') -Force
323+
324+
# verify mingw32-make was installed
325+
Get-Command -CommandType Application -ErrorAction Stop mingw32-make.exe
284326
285327
- name: Binaries
328+
shell: bash
286329
env:
287330
CGO_ENABLED: 1
288331
run: |

0 commit comments

Comments
 (0)