Skip to content

Commit f6433ad

Browse files
corbobgep13
authored andcommitted
(maint) Update testing vagrant for granular runs
Update the vagrantfile to allow environment variables to update the provisioning specs of the vagrant VM. Also split the provision scripts to allow calling such as `vagrant provision --provision-with prep,test` which will copy new files to the VM, then run the tests. This saves the 10+ minute build if all you're doing is changing the tests.
1 parent 11d5ded commit f6433ad

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

tests/Vagrantfile

+22-15
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ Vagrant.configure("2") do |config|
2222
config.vm.network :forwarded_port, guest: 3389, host: 14389, id: 'rdp', auto_correct: true
2323

2424
config.vm.provider "virtualbox" do |vb|
25-
vb.gui = true
26-
vb.memory = 4096
27-
vb.cpus = 2
25+
vb.gui = ENV['VM_GUI'] ? ENV['VM_GUI'].to_s.downcase == 'true' : true
26+
vb.memory = ENV['VM_MEMORY'] ? ENV['VM_MEMORY'].to_i : 4096
27+
vb.cpus = ENV['VM_CPU'] ? ENV['VM_CPU'].to_i : 2
2828
vb.linked_clone = true
2929
vb.customize ['modifyvm', :id, '--vram', '128']
3030
end
@@ -37,32 +37,39 @@ Vagrant.configure("2") do |config|
3737

3838
config.vm.synced_folder '../', '/chocoRoot'
3939

40-
config.vm.provision "shell", inline: <<-SHELL
40+
config.vm.provision "shell", name: "prep", inline: <<-SHELL
4141
cscript c:/windows/system32/slmgr.vbs /rearm | Out-Null
4242
Set-ExecutionPolicy Bypass -Scope Process -Force
43-
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
44-
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
43+
iex (irm https://community.chocolatey.org/install.ps1)
4544
46-
Write-Host "We are going to install some prerequisites now. This could take some time"
45+
Write-Host "($(Get-Date -Format "dddd MM/dd/yyyy HH:mm:ss K")) We are going to install some prerequisites now. This could take some time"
4746
$null = choco install git pester visualstudio2022community visualstudio2022-workload-manageddesktop netfx-4.8-devpack -y
4847
Import-Module $env:ChocolateyInstall/helpers/chocolateyProfile.psm1
4948
Update-SessionEnvironment
50-
Write-Host "Done installing software, now copying files"
49+
Write-Host "($(Get-Date -Format "dddd MM/dd/yyyy HH:mm:ss K")) Done installing software, now copying files"
5150
# If you try to build on macOS, then run this, there are attributes on some files that cause the build to fail inside of the vagrant environment.
52-
$null = robocopy c:/chocoRoot c:/code/choco /mir /copy:dt
51+
$null = robocopy c:/chocoRoot c:/code/choco /e /copy:dt
52+
SHELL
53+
config.vm.provision "shell", name: "build", inline: <<-SHELL
54+
$null = robocopy c:/chocoRoot c:/code/choco /e /copy:dt /purge
5355
Push-Location c:/code/choco
54-
Write-Host "Files have been copied, beginning build process."
56+
Write-Host "($(Get-Date -Format "dddd MM/dd/yyyy HH:mm:ss K")) Files have been copied, beginning build process."
5557
$CakeOutput = ./build.bat 2>&1
58+
5659
if ($LastExitCode -ne 0) {
57-
Set-Content c:/vagrant/buildOutput.log -Value $CakeOutput
58-
Write-Host "The build has failed. Please see the buildOutput.log file for details"
59-
exit $LastExitCode
60+
Set-Content c:/vagrant/buildOutput.log -Value $CakeOutput
61+
Write-Host "The build has failed. Please see the buildOutput.log file for details"
62+
exit $LastExitCode
6063
}
6164
62-
Write-Host "Build complete. Executing tests."
65+
Write-Host "($(Get-Date -Format "dddd MM/dd/yyyy HH:mm:ss K")) Build complete."
66+
SHELL
67+
config.vm.provision "shell", name: "test", inline: <<-SHELL
68+
Write-Host "($(Get-Date -Format "dddd MM/dd/yyyy HH:mm:ss K")) Starting Test Execution"
69+
Push-Location c:/code/choco
6370
# $env:TEST_KITCHEN = 1
6471
$env:VM_RUNNING = 1
65-
./Invoke-Tests.ps1
72+
./Invoke-Tests.ps1 -SkipPackaging
6673
Copy-Item $env:ALLUSERSPROFILE/chocolatey/logs/testInvocations.log C:/vagrant
6774
SHELL
6875
end

0 commit comments

Comments
 (0)