Skip to content
Snippets Groups Projects
Unverified Commit 1fc69d89 authored by Alessio Caiazza's avatar Alessio Caiazza
Browse files

Add vagrant config for testing on Windows

parent 17290488
Branches
No related tags found
Loading
...@@ -21,6 +21,8 @@ testsdefinitions.txt ...@@ -21,6 +21,8 @@ testsdefinitions.txt
/.testoutput/ /.testoutput/
/.cover/ /.cover/
/.vagrant/
codeclimate.json codeclimate.json
# Ignore the generated binary # Ignore the generated binary
......
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config|
config.vm.define 'win10' do |cfg|
cfg.vm.box = 'StefanScherer/windows_10'
cfg.vm.communicator = 'winrm'
cfg.vm.synced_folder '.', 'C:\Go\src\gitlab.com\gitlab-org\gitlab-runner'
cfg.vm.provision 'shell', path: 'ci/vagrant.ps1'
end
config.vm.provider 'virtualbox' do |vb|
vb.gui = false
vb.memory = '2048'
vb.cpus = 1
vb.linked_clone = true
end
end
$goVersion = "1.8"
$gitVersion = "2.18.0"
$srcFolder = "C:\Go\src\gitlab.com\gitlab-org\gitlab-runner"
function Main
{
[environment]::SetEnvironmentVariable("RUNNER_SRC", $srcFolder, "Machine")
Install-Go($goVersion)
Install-Git($gitVersion)
Install-SSH
}
function Install-Go([string]$version)
{
$file = 'go' + $version +'.windows-amd64.msi'
$url = 'https://storage.googleapis.com/golang/' + $file
$dest = Download -Url $url
Write-Host "installing go $version..."
$logFile = Log-File -App 'go'
$MSIArguments = @(
"/i"
('"{0}"' -f $dest)
"/qn"
"/norestart"
"/L*v"
$logFile
)
Start-Process "msiexec.exe" -ArgumentList $MSIArguments -Wait -NoNewWindow
Write-Host "done"
Remove-Item $dest
}
function Install-Git([string]$version)
{
$releaseVersion = 'v' + $version + '.windows.1'
$file = 'Git-' + $version +'-64-bit.exe'
$url = GitHubRelease -Project 'git-for-windows/git' -Version $releaseVersion -File $file
$dest = Download -Url $url
Write-Host "installing git $version..."
$logFile = Log-File -App 'git'
$InstallArguments = @(
"/VERYSILENT"
('/LOG="{0}"' -f $logFile)
)
Start-Process $dest -ArgumentList $InstallArguments -Wait -NoNewWindow
Write-Host "done"
Remove-Item $dest
}
function Install-SSH
{
Write-Host "Enable Developer Mode"
# Create AppModelUnlock if it doesn't exist, required for enabling Developer Mode
$RegistryKeyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock"
if (-not(Test-Path -Path $RegistryKeyPath)) {
New-Item -Path $RegistryKeyPath -ItemType Directory -Force
}
# Add registry value to enable Developer Mode
New-ItemProperty -Path $RegistryKeyPath -Name AllowDevelopmentWithoutDevLicense -PropertyType DWORD -Value 1
$cap = Get-WindowsCapability -Online | ? Name -like "OpenSSH.Server*"
if (($cap.count -ne 0) -and ($cap[0].State -ne "Installed")) {
Write-Host "Install OpenSSH Server"
# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
# Install the OpenSSHUtils helper module, which is needed to fix the ACL for ths host keys.
# Install-Module -Force OpenSSHUtils
Write-Host "Enable OpenSSH Server"
Start-Service sshd
Write-Host "Open OpenSSH Server port on firewall"
# Open firewall port
New-NetFirewallRule -Protocol TCP -LocalPort 22 -Direction Inbound -Action Allow -DisplayName SSH
}
}
function GitHubRelease([string]$Project, [string]$Version = 'latest', [string]$File) {
'https://github.com/' + $Project + '/releases/download/' + $Version + '/' + $File
}
function Download([string]$Url) {
$dest = [System.IO.Path]::GetTempFileName()
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11"
Write-Host "downloading $Url"
# Create client, set its info, and download
$wc = New-Object System.Net.WebClient
$wc.UseDefaultCredentials = $true
$wc.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")
$wc.DownloadFile($Url, $dest)
Write-Host "$url downloaded as $dest"
$dest
}
function Log-File($App)
{
$timestamp = get-date -Format yyyyMMddTHHmmss
$logFile = '{0}-{1}.log' -f $App,$timestamp
$vagrantFolder = Join-Path -Path $srcFolder -ChildPath ".vagrant"
Join-Path -Path $vagrantFolder -ChildPath $logFile
}
Main
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment