Skip to content

Commit 09f329a

Browse files
authored
fix: vagrantfile subenv and max path size
1 parent fca79d3 commit 09f329a

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
PAT=<Replace with your personal access token>
22
ORGANIZATION_URL=<Organization url>
3+
RUNNER=2
34
# Vagrant image settings
45
MEMORY=8000 # 8GB
56
CPU=4

Vagrantfile

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@ Vagrant.configure("2") do |config|
55
config.vm.network "forwarded_port", guest: 445, host: 445
66
config.vm.provision "shell", inline: "Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False"
77
config.vm.provider "libvirt" do |libvirt|
8-
libvirt.memory = $MEMORY
9-
libvirt.cpus = $CPU
10-
libvirt.machine_virtual_size = $DISK_SIZE
8+
libvirt.memory = ${MEMORY}
9+
libvirt.cpus = ${CPU}
10+
libvirt.machine_virtual_size = ${DISK_SIZE}
1111
end
1212
config.winrm.max_tries = 300 # default is 20
1313
config.winrm.retry_delay = 5 #seconds. This is the defaul value and just here for documentation.
1414
config.vm.provision "shell", powershell_elevated_interactive: false, privileged: false, inline: <<-SHELL
1515
# Install Chocolatey - Also Grabs 7Zip
1616
Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-powershell.ps1') } -AddToPath"
1717
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
18-
choco install 7zip.install -y
19-
choco install git.install -y
20-
choco install jq -y
18+
choco install 7zip.install git.install jq -y
2119
# c:/ default location
2220
Set-Location /
2321
# Install build tools
@@ -26,19 +24,27 @@ Vagrant.configure("2") do |config|
2624
# Install rtools40
2725
Invoke-WebRequest -Uri "https://cran.r-project.org/bin/windows/Rtools/rtools40-x86_64.exe" -OutFile "rtools.exe"
2826
Start-Process "./rtools.exe" -Argument "/Silent" -PassThru -Wait
29-
[Environment]::SetEnvironmentVariable("PATH", ${DOLLAR}Env:Path + ";C:\\rtools40\\usr\\bin;C:\\rtools40\\mingw64\\bin", [EnvironmentVariableTarget]::Machine)
30-
${DOLLAR}env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
27+
[Environment]::SetEnvironmentVariable("PATH", $env:Path + ";C:\\rtools40\\usr\\bin;C:\\rtools40\\mingw64\\bin", [EnvironmentVariableTarget]::Machine)
28+
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
3129
C:\\rtools40\\msys2.exe pacman -Sy --noconfirm mingw-w64-x86_64-make
3230
Remove-Item -Path ./rtools.exe
3331
# Resize disk
34-
Resize-Partition -DriveLetter "C" -Size (Get-PartitionSupportedSize -DriveLetter "C").SizeMax
32+
Resize-Partition -DriveLetter "C" -Size (Get-PartitionSupportedSize -DriveLetter "C").SizeMax
33+
# Enable too long paths
34+
New-ItemProperty -Path "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
3535
# github actions
36-
mkdir actions-runner
37-
Set-Location actions-runner
38-
Invoke-WebRequest -Uri $GITHUB_RUNNER_URL -OutFile $GITHUB_RUNNER_FILE
39-
Expand-Archive $GITHUB_RUNNER_FILE -DestinationPath .
40-
./config.cmd --name ${GITHUB_RUNNER_NAME}_${RANDOM_STR} --replace --unattended --url $ORGANIZATION_URL --labels $GITHUB_RUNNER_LABELS --pat $PAT
41-
./run.cmd
36+
Invoke-WebRequest -Uri ${GITHUB_RUNNER_URL} -OutFile ${GITHUB_RUNNER_FILE}
37+
Expand-Archive -LiteralPath ${GITHUB_RUNNER_FILE} -DestinationPath runner -Force;
38+
C:\\runner\\config.cmd --name ${GITHUB_RUNNER_NAME} --replace --unattended --url ${ORGANIZATION_URL} --labels ${GITHUB_RUNNER_LABELS} --pat ${PAT}
39+
C:\\runner\\run.cmd
40+
# Remove-Item -Path C:\\runner-* -Recurse -Force
41+
# for ($runner = 1 ; $runner -le ${RUNNERS} ; $runner++){
42+
# Write-Host "Running $runner";
43+
# $random = -join ((48..57) + (97..122) | Get-Random -Count 8 | % {[char]$_});
44+
# Expand-Archive -LiteralPath ${GITHUB_RUNNER_FILE} -DestinationPath runner-$random -Force;
45+
# Invoke-Expression -Command "C:\\runner-$random\\config.cmd --name ${GITHUB_RUNNER_NAME}_$random --replace --unattended --url ${ORGANIZATION_URL} --labels ${GITHUB_RUNNER_LABELS} --pat ${PAT}";
46+
# Start-Process -NoNewWindow "C:\\runner-$random\\run.cmd";
47+
# }
4248
SHELL
4349
end
4450

startup.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
set -eou pipefail
55
# Replace environmental variable to Vagrandfile
66
export RANDOM_STR=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1)
7-
envsubst < Vagrantfile > exported.txt && mv exported.txt Vagrantfile
7+
envsubst \
8+
'${MEMORY},${CPU},${DISK_SIZE},${GITHUB_RUNNER_FILE},${GITHUB_RUNNER_NAME},${RANDOM_STR},${RUNNERS},${GITHUB_RUNNER_LABELS},${ORGANIZATION_URL},${PAT},${GITHUB_RUNNER_URL}' \
9+
< Vagrantfile > exported.txt && mv exported.txt Vagrantfile
810

911
chown root:kvm /dev/kvm
1012

0 commit comments

Comments
 (0)