summaryrefslogtreecommitdiff
path: root/tools/ci
diff options
context:
space:
mode:
authorPradyun Gedam <pradyunsg@users.noreply.github.com>2021-04-01 23:48:39 +0100
committerPradyun Gedam <pradyunsg@users.noreply.github.com>2021-04-02 01:26:26 +0100
commitc022615961b3b6fa5b1a5aa6b6f620c8eee7f7da (patch)
tree8c2a5f2f7bbf74cdfae974c5a052313774c577c6 /tools/ci
parent0cdf9d7260611155d8f8bf90e7403c1c7bbc611c (diff)
downloadpip-c022615961b3b6fa5b1a5aa6b6f620c8eee7f7da.tar.gz
Add a single GitHub Actions workflow for CI
Diffstat (limited to 'tools/ci')
-rw-r--r--tools/ci/New-RAMDisk.ps174
1 files changed, 74 insertions, 0 deletions
diff --git a/tools/ci/New-RAMDisk.ps1 b/tools/ci/New-RAMDisk.ps1
new file mode 100644
index 000000000..21b1a573a
--- /dev/null
+++ b/tools/ci/New-RAMDisk.ps1
@@ -0,0 +1,74 @@
+[CmdletBinding()]
+param(
+ [Parameter(Mandatory=$true,
+ HelpMessage="Drive letter to use for the RAMDisk")]
+ [String]$drive,
+ [Parameter(HelpMessage="Size to allocate to the RAMDisk")]
+ [UInt64]$size=1GB
+)
+
+$ErrorActionPreference = "Stop"
+Set-StrictMode -Version Latest
+
+Write-Output "Installing FS-iSCSITarget-Server"
+Install-WindowsFeature -Name FS-iSCSITarget-Server
+
+Write-Output "Starting MSiSCSI"
+Start-Service MSiSCSI
+$retry = 10
+do {
+ $service = Get-Service MSiSCSI
+ if ($service.Status -eq "Running") {
+ break;
+ }
+ $retry--
+ Start-Sleep -Milliseconds 500
+} until ($retry -eq 0)
+
+$service = Get-Service MSiSCSI
+if ($service.Status -ne "Running") {
+ throw "MSiSCSI is not running"
+}
+
+Write-Output "Configuring Firewall"
+Get-NetFirewallServiceFilter -Service MSiSCSI | Enable-NetFirewallRule
+
+Write-Output "Configuring RAMDisk"
+# Must use external-facing IP address, otherwise New-IscsiTargetPortal is
+# unable to connect.
+$ip = (
+ Get-NetIPAddress -AddressFamily IPv4 |
+ Where-Object {$_.IPAddress -ne "127.0.0.1"}
+)[0].IPAddress
+if (
+ -not (Get-IscsiServerTarget -ComputerName localhost | Where-Object {$_.TargetName -eq "ramdisks"})
+) {
+ New-IscsiServerTarget `
+ -ComputerName localhost `
+ -TargetName ramdisks `
+ -InitiatorId IPAddress:$ip
+}
+
+$newVirtualDisk = New-IscsiVirtualDisk `
+ -ComputerName localhost `
+ -Path ramdisk:local$drive.vhdx `
+ -Size $size
+Add-IscsiVirtualDiskTargetMapping `
+ -ComputerName localhost `
+ -TargetName ramdisks `
+ -Path ramdisk:local$drive.vhdx
+
+Write-Output "Connecting to iSCSI"
+New-IscsiTargetPortal -TargetPortalAddress $ip
+Get-IscsiTarget | Where-Object {!$_.IsConnected} | Connect-IscsiTarget
+
+Write-Output "Configuring disk"
+$newDisk = Get-IscsiConnection |
+ Get-Disk |
+ Where-Object {$_.SerialNumber -eq $newVirtualDisk.SerialNumber}
+
+Set-Disk -InputObject $newDisk -IsOffline $false
+Initialize-Disk -InputObject $newDisk -PartitionStyle MBR
+New-Partition -InputObject $newDisk -UseMaximumSize -DriveLetter $drive
+
+Format-Volume -DriveLetter $drive -NewFileSystemLabel Temp -FileSystem NTFS