-
Notifications
You must be signed in to change notification settings - Fork 4
/
Vagrantfile
185 lines (154 loc) · 7.27 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
XCODE_XIP_FILE=ENV['XCODE_XIP_FILE']
GITLAB_URL=ENV['GITLAB_URL'] || "https://gitlab.com/"
GITLAB_REGISTRATION_TOKEN=ENV['GITLAB_REGISTRATION_TOKEN']
GITLAB_RUNNER_NAME=ENV['GITLAB_RUNNER_NAME']
GITLAB_RUNNER_TAGS=ENV['GITLAB_RUNNER_TAGS']
CPU_COUNT=ENV['CPU_COUNT'] || 2
RAM_SIZE=ENV['RAM_SIZE'] || 4096
Vagrant.configure("2") do |config|
# Get box
config.vm.box = "leav3/macos_mojave"
# Configuration
config.vm.provider 'virtualbox' do |vb|
vb.customize ["modifyvm", :id, "--ostype", "MacOS_64"]
vb.customize ["modifyvm", :id, "--ioapic", "on"]
vb.customize ["modifyvm", :id, "--nestedpaging", "off"]
vb.gui = false
vb.name = 'mojave-xcode'
vb.cpus = "#{CPU_COUNT}"
vb.memory = "#{RAM_SIZE}"
config.vm.synced_folder ".", "/vagrant", disabled: true
end
# Set boot timeout to 600 seconds
config.vm.boot_timeout = 600
# Copy Xcode install package
config.vm.provision "file", source: "#{XCODE_XIP_FILE}", destination: "/tmp/Xcode.xip"
# Copy scripts
config.vm.provision "file", source: "./scripts", destination: "/tmp/scripts"
# Environment variables
config.vm.provision "shell", privileged: true, name: 'environment variables', inline: <<-SHELL
echo export BINARIES_DIRECTORY='/opt/local/bin' >> /etc/profile
echo export BUILD_TOOLS_REPOSITORY=build-ios-simple-shell >> /etc/profile
echo export USERNAME='vagrant' >> /etc/profile
echo export LANG='en_US.UTF-8' >> /etc/profile
echo export LANGUAGE='en_US.UTF-8' >> /etc/profile
echo export LC_ALL='en_US.UTF-8' >> /etc/profile
echo export 'PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' >> /etc/profile
SHELL
# Disable sleep mode
config.vm.provision "shell", privileged: false, name: 'disable sleep mode', inline: <<-SHELL
sudo systemsetup -setcomputersleep Never
SHELL
# Developer mode activation
config.vm.provision "shell", privileged: false, name: 'developer mode activation', inline: <<-SHELL
sudo /usr/sbin/DevToolsSecurity -enable
sudo /usr/sbin/dseditgroup -o edit -t group -a staff _developer
SHELL
# Install scripts
config.vm.provision "shell", privileged: true, name: 'scripts', inline: <<-SHELL
mkdir -p /usr/local/opt
mv /tmp/scripts/ /usr/local/opt
chmod +x /usr/local/opt/scripts/*.sh
echo export PATH=/usr/local/opt/scripts:\$PATH >> /etc/profile
SHELL
# Install brew
config.vm.provision "shell", privileged: false, name: 'homebrew with command line tools', inline: <<-SHELL
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
SHELL
# Install command line tools with brew
config.vm.provision "shell", privileged: false, name: 'brew tools', inline: <<-SHELL
/usr/local/bin/brew tap oclint/formulae
/usr/local/bin/brew install xz ruby wget gcovr doxygen graphviz sonar-scanner carthage python@2 imagemagick ghostscript oclint
SHELL
# Install brew tools path
config.vm.provision "shell", privileged: true, name: 'brew tools path', inline: <<-SHELL
echo export PATH=/usr/local/opt/python@2/libexec/bin:\$PATH >> /etc/profile
SHELL
# Install Lizard
config.vm.provision "shell", privileged: true, name: 'pip tools', inline: <<-SHELL
pip install lizard
SHELL
# Install gem tools
config.vm.provision "shell", privileged: false, name: 'gem tools', inline: <<-SHELL
/usr/local/opt/ruby/bin/gem install xcpretty slather cocoapods jazzy
/usr/local/opt/ruby/bin/gem install bundler --force
/usr/local/opt/ruby/bin/gem install xcodeproj
/usr/local/opt/ruby/bin/gem install fileutils
sudo /usr/local/opt/ruby/bin/gem install fastlane -NV
SHELL
# Install gem tools path
config.vm.provision "shell", privileged: true, name: 'gem tools path', inline: <<-SHELL
GEM_TOOL_BIN_PATH=`/usr/local/opt/ruby/bin/gem environment | awk -F ' *: *' '$1 ~ /EXECUTABLE DIRECTORY/{print $2}'`
echo export PATH=\$GEM_TOOL_BIN_PATH:\$PATH >> /etc/profile
SHELL
# sonar-swift script
config.vm.provision "shell", privileged: true, name: 'sonar-swift script', env: {"SONAR_PUBLIC_REPOSITORY" => "sonar-swift"}, inline: <<-SHELL
git clone -b master https://github.com/insideapp-oss/$SONAR_PUBLIC_REPOSITORY.git ~/$SONAR_PUBLIC_REPOSITORY
cd ~/$SONAR_PUBLIC_REPOSITORY
git checkout develop
mv ~/$SONAR_PUBLIC_REPOSITORY/sonar-swift-plugin/src/main/shell/ /usr/local/opt/$SONAR_PUBLIC_REPOSITORY
rm -rf ~/$SONAR_PUBLIC_REPOSITORY
chmod +x /usr/local/opt/$SONAR_PUBLIC_REPOSITORY/run-sonar-swift.sh
echo export PATH=/usr/local/opt/$SONAR_PUBLIC_REPOSITORY:\$PATH >> /etc/profile
SHELL
# Install java
config.vm.provision "shell", privileged: false, name: 'java', inline: <<-SHELL
/usr/local/bin/brew tap caskroom/versions
/usr/local/bin/brew cask install java
SHELL
# Enable auto login
config.vm.provision "shell", privileged: false, name: 'enable auto login', inline: <<-SHELL
/usr/local/bin/brew tap xfreebird/utils
/usr/local/bin/brew install kcpassword
enable_autologin "${USERNAME}" "${USERNAME}"
SHELL
# Reboot (to enable auto login)
#config.vm.provision :reload
# Xcode
config.vm.provision "shell", privileged: false, name: 'xcode installation', inline: <<-SHELL
open -FWga "Archive Utility" --args /tmp/Xcode.xip
# Move Xcode to Applications directory
sudo mv ~/Downloads/Xcode.app /Applications/
# Clean Xcode installation file
rm /tmp/Xcode.xip
# Accept Xcode licence
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license accept
# Install XCode additional required components
for pkg in /Applications/Xcode.app/Contents/Resources/Packages/*.pkg; do sudo installer -pkg "$pkg" -target /; done
SHELL
# Simulator tools (require Xcode to be installed)
config.vm.provision "shell", privileged: false, name: 'ios simulator tools', inline: <<-SHELL
/usr/local/bin/brew tap wix/brew
/usr/local/bin/brew install applesimutils
/usr/local/bin/brew tap facebook/fb
SHELL
# swiftlint (require Xcode to be installed)
config.vm.provision "shell", privileged: false, name: 'swiftlint installation', inline: <<-SHELL
/usr/local/bin/brew install swiftlint
SHELL
# flutter (require Xcode to be installed)
config.vm.provision "shell", privileged: false, name: 'flutter installation', inline: <<-SHELL
/usr/local/bin/brew tap MiderWong/flutter
/usr/local/bin/brew install flutter
SHELL
# Cocoapods repository setup
config.vm.provision "shell", privileged: false, name: 'pod repository setup', inline: <<-SHELL
pod setup
SHELL
# GitLab runner install
config.vm.provision "shell", privileged: false, name: 'gitlab-runner installation', inline: <<-SHELL
/usr/local/bin/brew install gitlab-runner
/usr/local/bin/brew services start gitlab-runner
# Registration
gitlab-runner register --non-interactive --url "#{GITLAB_URL}" --registration-token "#{GITLAB_REGISTRATION_TOKEN}" --executor "shell" --name "#{GITLAB_RUNNER_NAME}" --tag-list "#{GITLAB_RUNNER_TAGS}"
SHELL
# Reboot
config.vm.provision :reload
end