mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-27 21:26:38 +00:00
patch: setup virtual drive on windows
This commit is contained in:
parent
de7c0953fb
commit
144590abc8
71
.github/actions/test/action.yml
vendored
71
.github/actions/test/action.yml
vendored
@ -55,6 +55,57 @@ runs:
|
|||||||
echo "TARGET_DRIVE=${virtual_path}" >> $GITHUB_ENV
|
echo "TARGET_DRIVE=${virtual_path}" >> $GITHUB_ENV
|
||||||
echo "ETCHER_INCLUDE_VIRTUAL_DRIVES=1" >> $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
|
- name: Test release
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@ -67,25 +118,25 @@ runs:
|
|||||||
|
|
||||||
npm ci
|
npm ci
|
||||||
npm run lint
|
npm run lint
|
||||||
npm run package
|
|
||||||
|
|
||||||
# tests requires the app to already be built
|
|
||||||
|
|
||||||
# # only run e2e tests on Mac as it's the only supported platform atm
|
# tests requires the app to already be built
|
||||||
if [[ '${{ runner.os }}' == 'macOS' ]]; then
|
npm run package
|
||||||
# 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 }}
|
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 \
|
sudo \
|
||||||
TARGET_DRIVE=${{ env.TARGET_DRIVE }} \
|
TARGET_DRIVE=${{ env.TARGET_DRIVE }} \
|
||||||
ETCHER_INCLUDE_VIRTUAL_DRIVES=1 \
|
ETCHER_INCLUDE_VIRTUAL_DRIVES=1 \
|
||||||
TEST_SOURCE_FILE: $(pwd)/${{ env.TEST_SOURCE_FILE }} \
|
TEST_SOURCE_FILE: $(pwd)/${{ env.TEST_SOURCE_FILE }} \
|
||||||
TEST_SOURCE_URL: ${{ env.TEST_SOURCE_URL }} \
|
TEST_SOURCE_URL: ${{ env.TEST_SOURCE_URL }} \
|
||||||
npm run wdio:ci
|
npm run wdio:ci
|
||||||
else
|
|
||||||
npm run wdio:unit
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
env:
|
env:
|
||||||
# https://www.electronjs.org/docs/latest/api/environment-variables
|
# https://www.electronjs.org/docs/latest/api/environment-variables
|
||||||
ELECTRON_NO_ATTACH_CONSOLE: 'true'
|
ELECTRON_NO_ATTACH_CONSOLE: 'true'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user