diff --git a/.gitignore b/.gitignore index 652fc3da..69880923 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *egg* env/ +env-windows/ var/ log/ dist diff --git a/Makefile b/Makefile index 49f84639..69e36a34 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,9 @@ dev: test: comply python -m pytest -v --cov=cement --cov-report=term --cov-report=html:coverage-report tests/ +test-core: comply + python -m pytest -v --cov=cement.core --cov-report=term --cov-report=html:coverage-report tests/core + comply: flake8 cement/ tests/ diff --git a/README.md b/README.md index 10854eba..3c251d74 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,14 @@ $ docker-compose exec cement /bin/ash An alternative option is included to run Vagrant for development. This is partially supported, primarily for the purpose of developing/testing on Windows as well as testing specific issues on target operating systems. +To see a list of configured systems: + +``` +$ vagrant status +``` + +#### Linux + ``` $ vagrant up linux @@ -78,9 +86,39 @@ $ vagrant ssh linux vagrant@linux $ cd /vagrant +vagrant@linux $ bash scripts/vagrant/bootstrap.sh + vagrant@linux $ source env/bin/activate -|> cement >| $ +|> cement >| $ pip install -r requirements-dev.txt + +|> cement >| $ python setup.py develop +``` + +#### Windows + +*Note that Windows development and support is not 100% complete. Cement is known to run and work on Windows, however it is not a primary target for development and as such the setup is not as streamlined and currently has several known errors.* + +The following assumes you're running these two initial commands from a unix based system: + +``` +$ make clean + +$ vagrant up windows +``` + +RDP or Login to Desktop/Console, and open a PowerShell terminal: + +``` +C:\> cd C:\Vagrant + +C:\Vagrant> powershell.exe scripts\vagrant\bootstrap.ps1 + +C:\Vagrant> .\env-windows\Scripts\activate.ps1 + +C:\Vagrant> pip install -r requirements-dev.txt + +C:\Vagrant> python setup.py develop ``` diff --git a/Vagrantfile b/Vagrantfile index 456fded8..35755be6 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,12 +1,6 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -targets = [ - 'centos-7', - 'ubuntu-16.04', - 'windows-server-2012-r2' -] - vagrantDir = File.expand_path("scripts/vagrant", File.dirname(__FILE__)) + "/" Vagrant.configure("2") do |config| @@ -15,27 +9,37 @@ Vagrant.configure("2") do |config| config.vm.define "linux" do |this| this.vm.box = "trueability/ubuntu-16.04" this.vm.hostname = "linux" - this.vm.provision "shell", path: "scripts/vagrant/bootstrap.sh" + # this.vm.provision "shell", path: "scripts/vagrant/bootstrap.sh" + end + + config.vm.define "ubuntu-16.04" do |this| + this.vm.box = "trueability/ubuntu-16.04" + this.vm.hostname = "ubuntu-1604" + # this.vm.provision "shell", path: "scripts/vagrant/bootstrap.sh" + end + + config.vm.define "centos-7" do |this| + this.vm.box = "trueability/centos-7" + this.vm.hostname = "centos-7" + # this.vm.provision "shell", path: "scripts/vagrant/bootstrap.sh" end config.vm.define "windows" do |this| - this.vm.box = "trueability/windows-server-2012-r2" + this.vm.box = "senglin/win-10-enterprise-vs2015community" this.vm.hostname = "windows" - this.vm.provision "shell", path: "scripts/vagrant/bootstrap.ps1" + # this.vm.provision "shell", path: "scripts/vagrant/bootstrap.ps1" end - targets.each do |name| - config.vm.define name do |this| - this.vm.box = "trueability/#{name}" - this.vm.hostname = name + config.vm.define "windows-10-enterprise" do |this| + this.vm.box = "senglin/win-10-enterprise-vs2015community" + this.vm.hostname = "windows" + # this.vm.provision "shell", path: "scripts/vagrant/bootstrap.ps1" + end - if name.start_with?('windows') - this.vm.provision "shell", path: "scripts/vagrant/bootstrap.ps1" - else - this.vm.provision "shell", path: "scripts/vagrant/bootstrap.sh" - end - - end + config.vm.define "windows-server-2012-r2" do |this| + this.vm.box = "opentable/win-2012r2-standard-amd64-nocm" + this.vm.hostname = "windows" + # this.vm.provision "shell", path: "scripts/vagrant/bootstrap.ps1" end config.vm.provider "virtualbox" do |v| diff --git a/scripts/vagrant/bootstrap.ps1 b/scripts/vagrant/bootstrap.ps1 index 2e7cf4d9..b63acba1 100644 --- a/scripts/vagrant/bootstrap.ps1 +++ b/scripts/vagrant/bootstrap.ps1 @@ -1,75 +1,167 @@ -function Do-IEESC { - $AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" - $UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" - Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 - Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 - Stop-Process -Name Explorer - Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." ` - -ForegroundColor Green -} -function Do-WinRM { - # Not sure if this can be improved? It's taken from - # https://learn.chef.io/manage-a-node/windows/bootstrap-your-node/ +$ErrorActionPreference = "Stop" - winrm quickconfig -q - winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}' - winrm set winrm/config '@{MaxTimeoutms="1800000"}' - winrm set winrm/config/service '@{AllowUnencrypted="true"}' - winrm set winrm/config/service/auth '@{Basic="true"}' +$Env:Path = "$Env:Path;C:\ProgramData\chocolatey\bin;C:\Python36\Scripts" - netsh advfirewall firewall add rule ` - name="WinRM 5985" ` - protocol=TCP ` - dir=in ` - localport=5985 ` - action=allow - netsh advfirewall firewall add rule ` - name="WinRM 5986" ` - protocol=TCP ` - dir=in ` - localport=5986 ` - action=allow - - net stop winrm - sc.exe config winrm start= auto - net start winrm - - Write-Host "WinRM setup complete" -ForegroundColor Green -} - -# function Do-Python2 { -# Invoke-WebRequest ` -# -Uri https://www.python.org/ftp/python/2.7.11/python-2.7.11.amd64.msi ` -# -OutFile python2-installer.msi +# Function Do-IEESC { +# $AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" +# $UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" +# Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 +# Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 +# Stop-Process -Name Explorer -Force -ErrorAction "Ignore" +# Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." ` +# -ForegroundColor Green +# } # -# msiexec /i python2-installer.msi /passive ALLUSERS=1 TARGETDIR=C:\Python27 +# Function Do-WinRM { +# # Not sure if this can be improved? It's taken from +# # https://learn.chef.io/manage-a-node/windows/bootstrap-your-node/ # -# Start-Sleep -s 10 +# winrm quickconfig -q +# winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}' +# winrm set winrm/config '@{MaxTimeoutms="1800000"}' +# winrm set winrm/config/service '@{AllowUnencrypted="true"}' +# winrm set winrm/config/service/auth '@{Basic="true"}' # -# C:\Python27\Scripts\pip.exe install virtualenv +# netsh advfirewall firewall add rule ` +# name="WinRM 5985" ` +# protocol=TCP ` +# dir=in ` +# localport=5985 ` +# action=allow +# netsh advfirewall firewall add rule ` +# name="WinRM 5986" ` +# protocol=TCP ` +# dir=in ` +# localport=5986 ` +# action=allow # -# Write-Host "Python2 setup complete" -ForegroundColor Green +# net stop winrm +# sc.exe config winrm start= auto +# net start winrm # +# Write-Host "WinRM setup complete" -ForegroundColor Green # } -function Do-Python3 { - Invoke-WebRequest ` - -Uri https://www.python.org/ftp/python/3.5.1/python-3.5.1-amd64.exe ` - -OutFile python3-installer.exe - - .\python3-installer.exe - - Start-Sleep -s 10 - - C:\Python35\Scripts\pip.exe install virtualenv - - Write-Host "Python3 setup complete" -ForegroundColor Green - +Function Do-Chocolatey { + If ( Test-Path('C:\ProgramData\chocolatey\bin\choco.exe') ) { + Write-Host 'Chocolatey Already Installed' + } Else { + Write-Host 'Installing Chocolatey' + iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) + } } -Do-IEESC -Do-WinRM -# Do-Python2 -Do-Python3 +Function Do-Google-Chrome { + Write-Host 'Installing Google Chrome' + + # temporarily ignore checksums due to upstream issue! Please try to remove + # this asap + choco install -y google-chrome-x64 --ignore-checksum + If (Test-Path('C:\Program Files (x86)\Google\Chrome\Application\chrome.exe')) { + Write-Host "Google Chrome setup complete" -ForegroundColor Green + } Else { + Write-Host "Google Chrome setup failed" -ForegroundColor Red + Exit 1 + } +} + +Function Do-Python { + Write-Host 'Installing Python' + choco install -y python3 pip + + If (Test-Path('C:\Python36\python.exe')) { + Write-Host "Python setup complete" -ForegroundColor Green + } Else { + Write-Host "Python setup failed" -ForegroundColor Red + Exit 1 + } + + C:\Python36\Scripts\pip.exe install virtualenv + C:\Python36\Scripts\virtualenv.exe .env-windows +} + +Function Do-Misc { + Write-Host 'Installing Make' + choco install -y make + + Write-Host 'Installing Redis' + choco install -y redis + + Write-Host 'Installing Memcached' + choco install -y memcached +} + + +# Function Test-RegistryValue { +# param( +# [Alias("RegistryPath")] +# [Parameter(Position = 0)] +# [String]$Path +# , +# [Alias("KeyName")] +# [Parameter(Position = 1)] +# [String]$Name +# ) +# +# process +# { +# If (Test-Path $Path) +# { +# $Key = Get-Item -LiteralPath $Path +# If ($Key.GetValue($Name, $null) -ne $null) +# { +# If ($PassThru) +# { +# Get-ItemProperty $Path $Name +# } +# Else +# { +# $true +# } +# } +# Else +# { +# $false +# } +# } +# Else +# { +# $false +# } +# } +# } + +# Function Do-UAC { +# Write-Host "Disabling UAC" +# $EnableUACRegistryPath = "REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System" +# $EnableUACRegistryKeyName = "EnableLUA" +# $UACKeyExists = Test-RegistryValue -RegistryPath $EnableUACRegistryPath ` +# -KeyName $EnableUACRegistryKeyName +# +# If ($UACKeyExists) +# { +# Set-ItemProperty -Path $EnableUACRegistryPath ` +# -Name $EnableUACRegistryKeyName ` +# -Value 0 +# } +# Else +# { +# New-ItemProperty -Path $EnableUACRegistryPath ` +# -Name $EnableUACRegistryKeyName ` +# -Value 0 ` +# -PropertyType "DWord" +# } +# } + + +# Do-IEESC +# Do-WinRM +Do-Chocolatey +Do-Google-Chrome +Do-Python +Do-Misc +# Do-UAC Clear-History + +Exit 0