Skip to content

Commit

Permalink
ci: apply WSL hanging workaround to MSI builder
Browse files Browse the repository at this point in the history
This change refactors the WSL hanging workaround into a reusable GitHub
composite action and applies it to the MSI builder workflow.

Signed-off-by: Austin Vazquez <[email protected]>
  • Loading branch information
austinvazquez committed Jul 3, 2024
1 parent 12b6934 commit dbd3b7c
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 86 deletions.
46 changes: 46 additions & 0 deletions .github/actions/cleanup-windows-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Clean Up Windows Environment"
description: "Reusable action to clean up the virtual machine for Finch on Windows"
inputs:
deep-clean:
default: true
description: "Clean up Finch virtual machine and configuration files only"

runs:
using: composite
steps:
- name: Remove Finch VM
timeout: 3 minutes
run: |
wsl --list --verbose
wsl --shutdown
wsl --unregister lima-finch
wsl --list --verbose
# This is a workaround for https://github.com/microsoft/WSL/issues/8529
#
# If WSL is suspected of hanging for longer than 180 seconds, then
# kill the WSL service and retry the shutdown command.
- name: Force remove Finch VM
needs: remove-vm
if: failure()
timeout: 3 minutes
run: |
$ErrorActionPreference = 'Ignore'
taskkill /f /im wslservice.exe 2> nul || cmd /c "exit /b 0"
wsl --list --verbose
wsl --shutdown
Start-Sleep -s 10
wsl --unregister lima-finch
wsl --list --verbose
- name: Clean up Finch application data
run: |
Remove-Item C:\Users\Administrator\AppData\Local\.finch -Recurse -ErrorAction Ignore
exit 0 # Cleanup may set the exit code e.g. if a file doesn't exist; just ignore
- name: Clean up Finch configuration and artifacts
if: inputs.deep-clean
run: |
Remove-Item C:\Users\Administrator\.finch -Recurse -ErrorAction Ignore
make clean
exit 0 # Cleanup may set the exit code e.g. if a file doesn't exist; just ignore
73 changes: 12 additions & 61 deletions .github/workflows/build-and-test-msi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,14 @@ jobs:
fetch-depth: 0
persist-credentials: false
submodules: recursive
- name: Ensure runner environment is in clean state
uses: ${{ github.workspace }}/.github/actions/cleanup-windows-env
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
with:
role-to-assume: ${{ secrets.WINDOWS_ROLE }}
role-session-name: windows-msi
aws-region: ${{ secrets.WINDOWS_REGION }}
- name: Remove Finch VM
run: |
$ErrorActionPreference = 'Ignore'
taskkill /f /im wslservice.exe 2> nul || cmd /c "exit /b 0"
wsl --list --verbose
wsl --shutdown
wsl --unregister lima-finch
wsl --list --verbose
- name: Clean up previous files
run: |
takeown /F C:\actions-runner\_work\finch /R
Remove-Item C:\Users\Administrator\.finch -Recurse -ErrorAction Ignore
Remove-Item C:\Users\Administrator\AppData\Local\.finch -Recurse -ErrorAction Ignore
make clean
cd deps/finch-core && make clean
- name: Build project
run: |
make FINCH_OS_IMAGE_LOCATION_ROOT=__INSTALLFOLDER__
Expand Down Expand Up @@ -143,20 +130,9 @@ jobs:
run: |
$tag="${{ needs.get-tag-name.outputs.tag }}"
aws s3 cp "./msi-builder/build/signed/Finch-$tag.msi" "s3://${{ secrets.INSTALLER_PRIVATE_BUCKET_NAME }}/Finch-$tag.msi" --no-progress
- name: Remove Finch VM and Clean Up Previous Environment
- name: Clean up runner
if: ${{ always() }}
run: |
# We want these cleanup commands to always run, ignore errors so the step completes.
$ErrorActionPreference = 'Ignore'
taskkill /f /im wslservice.exe 2> nul || cmd /c "exit /b 0"
wsl --list --verbose
wsl --shutdown
wsl --unregister lima-finch
wsl --list --verbose
Remove-Item C:\Users\Administrator\AppData\Local\.finch -Recurse
make clean
cd deps/finch-core && make clean
exit 0 # Cleanup may set the exit code e.g. if a file doesn't exist; just ignore
uses: ${{ github.workspace }}/.github/actions/cleanup-windows-env

msi-e2e-tests:
needs:
Expand Down Expand Up @@ -185,6 +161,8 @@ jobs:
fetch-depth: 0
persist-credentials: false
submodules: recursive
- name: Ensure runner environment is in clean state
uses: ${{ github.workspace }}/.github/actions/cleanup-windows-env
- name: Set output variables
id: vars
run: |
Expand All @@ -197,18 +175,6 @@ jobs:
role-to-assume: ${{ secrets.ROLE }}
role-session-name: msi-test
aws-region: ${{ secrets.REGION }}
- name: Remove Finch VM
run: |
wsl --list --verbose
wsl --shutdown
wsl --unregister lima-finch
wsl --list --verbose
- name: Clean up previous files
run: |
Remove-Item C:\Users\Administrator\.finch -Recurse -ErrorAction Ignore
Remove-Item C:\Users\Administrator\AppData\Local\.finch -Recurse -ErrorAction Ignore
make clean
cd deps/finch-core && make clean
- name: Uninstall Finch silently
run: |
$productCode = (Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -like "*Finch*" } | Select-Object -ExpandProperty IdentifyingNumber)
Expand Down Expand Up @@ -239,14 +205,10 @@ jobs:
git clean -f -d
$env:INSTALLED="true"
make test-e2e-vm
- name: Remove Finch VM
run: |
wsl --list --verbose
wsl --shutdown
Start-Sleep -s 10
wsl --unregister lima-finch
Remove-Item C:\Users\Administrator\AppData\Local\.finch -Recurse
wsl --list --verbose
- name: Remove Finch VM and application data
uses: ${{ github.workspace }}/.github/actions/cleanup-windows-env
with:
deep-clean: false
- name: Run container e2e tests
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
with:
Expand All @@ -270,17 +232,6 @@ jobs:
} else {
Write-Output "Finch not found or it wasn't installed using MSI."
}
- name: Remove Finch VM and Clean Up Previous Environment
- name: Clean up runner
if: ${{ always() }}
run: |
# We want these cleanup commands to always run, ignore errors so the step completes.
$ErrorActionPreference = 'Ignore'
taskkill /f /im wslservice.exe 2> nul || cmd /c "exit /b 0"
wsl --list --verbose
wsl --shutdown
wsl --unregister lima-finch
wsl --list --verbose
Remove-Item C:\Users\Administrator\AppData\Local\.finch -Recurse
make clean
cd deps/finch-core && make clean
exit 0 # Cleanup may set the exit code e.g. if a file doesn't exist; just ignore
uses: ${{ github.workspace }}/.github/actions/cleanup-windows-env
29 changes: 4 additions & 25 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ jobs:
fetch-depth: 0
persist-credentials: false
submodules: recursive
- name: Ensure runner environment is in clean state
uses: ${{ github.workspace }}/.github/actions/cleanup-windows-env
- name: Set output variables
id: vars
run: |
Expand All @@ -238,18 +240,6 @@ jobs:
role-to-assume: ${{ secrets.ROLE }}
role-session-name: credhelper-test
aws-region: ${{ secrets.REGION }}
- name: Remove Finch VM
run: |
wsl --list --verbose
wsl --shutdown
wsl --unregister lima-finch
wsl --list --verbose
- name: Clean up previous files
run: |
Remove-Item C:\Users\Administrator\.finch -Recurse -ErrorAction Ignore
Remove-Item C:\Users\Administrator\AppData\Local\.finch -Recurse -ErrorAction Ignore
make clean
cd deps/finch-core && make clean
- name: Build project
run: |
git status
Expand All @@ -266,20 +256,9 @@ jobs:
git status
git clean -f -d
make ${{ matrix.test-command }}
- name: Remove Finch VM and Clean Up Previous Environment
- name: Clean up runner
if: ${{ always() }}
run: |
# We want these cleanup commands to always run, ignore errors so the step completes.
$ErrorActionPreference = 'Ignore'
taskkill /f /im wslservice.exe 2> nul || cmd /c "exit /b 0"
wsl --list --verbose
wsl --shutdown
wsl --unregister lima-finch
wsl --list --verbose
Remove-Item C:\Users\Administrator\AppData\Local\.finch -Recurse
make clean
cd deps/finch-core && make clean
exit 0 # Cleanup may set the exit code e.g. if a file doesn't exist; just ignore
uses: ${{ github.workspace }}/.github/actions/cleanup-windows-env
mdlint:
runs-on: ubuntu-latest
steps:
Expand Down

0 comments on commit dbd3b7c

Please sign in to comment.