Skip to content

Commit

Permalink
patch: setup virtual drive on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
aethernet committed May 13, 2024
1 parent de7c095 commit 144590a
Showing 1 changed file with 60 additions and 9 deletions.
69 changes: 60 additions & 9 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,57 @@ runs:
echo "TARGET_DRIVE=${virtual_path}" >> $GITHUB_ENV
echo "ETCHER_INCLUDE_VIRTUAL_DRIVES=1" >> $GITHUB_ENV
- name: Setup Virtual Drive on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
# Get the current directory
$currentDirectory = Get-Location
# Define the filename of the virtual disk
$vdiskFilename = "virtual_test_disk.vhd"
# Create the full path for the virtual disk
$vdiskPath = Join-Path -Path $currentDirectory -ChildPath $vdiskFilename
$vdiskSize = 4096 # Size in MB
# Create and attach the virtual disk using DiskPart
$diskpartScript = @"
create vdisk file="$vdiskPath" maximum=$vdiskSize type=fixed
select vdisk file="$vdiskPath"
attach vdisk
exit
"@
Invoke-Expression "echo '$diskpartScript' | diskpart"
# Refresh the disk information
Update-HostStorageCache
# Get the number of the new disk based on the vdisk path and size
$disk = Get-Disk | Where-Object {
$_.OperationalStatus -eq 'Online' -and
$_.Size -eq ($vdiskSize * 1MB)
}
# If multiple disks match, further filter by VHD path if possible (requires PowerShell 5.1 or later)
if ($disk.Count -gt 1) {
$disk = $disk | Where-Object { $_.Path -eq $vdiskPath }
}
$diskNumber = $disk.Number
# Initialize the disk and create a single partition that uses the entire disk, assign drive letter Z
Initialize-Disk -Number $diskNumber -PartitionStyle MBR
New-Partition -DiskNumber $diskNumber -UseMaximumSize -AssignDriveLetter
Get-Partition -DiskNumber $diskNumber | Set-Partition -NewDriveLetter Z
# Output the details of the new drive
Write-Output "New virtual disk created and accessible at drive letter: Z"
echo "TARGET_DRIVE=Microsoft Virtual Disk" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Test release
shell: bash
run: |
Expand All @@ -67,25 +118,25 @@ runs:
npm ci
npm run lint
npm run package
# tests requires the app to already be built
npm run package
# # only run e2e tests on Mac as it's the only supported platform atm
if [[ '${{ runner.os }}' == 'macOS' ]]; then
# run all tests on macOS including E2E
# E2E tests can't input the administrative password, therefore the tests need to run as root
if [[ '${{ runner.os }}' == 'Linux' ]]; then
# linux doesn't support e2e tests yet
npm run wdio:unit
else
# download the test source
wget -q -O ${{ env.TEST_SOURCE_FILE }} ${{ env.TEST_SOURCE_URL }}
# E2E tests can't input the administrative password, therefore the tests need to run as root
sudo \
TARGET_DRIVE=${{ env.TARGET_DRIVE }} \
ETCHER_INCLUDE_VIRTUAL_DRIVES=1 \
TEST_SOURCE_FILE: $(pwd)/${{ env.TEST_SOURCE_FILE }} \
TEST_SOURCE_URL: ${{ env.TEST_SOURCE_URL }} \
npm run wdio:ci
else
npm run wdio:unit
fi
env:
# https://www.electronjs.org/docs/latest/api/environment-variables
ELECTRON_NO_ATTACH_CONSOLE: 'true'
Expand Down

0 comments on commit 144590a

Please sign in to comment.