This repository was archived by the owner on Jul 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathci.rb
More file actions
209 lines (177 loc) · 5.25 KB
/
ci.rb
File metadata and controls
209 lines (177 loc) · 5.25 KB
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
dep "provision ci", :keys, :host, :user, :buildkite_token do
keys.default!((dependency.load_path.parent / "config/authorized_keys").read)
user.default!("buildkite-agent")
requires_when_unmet "public key in place".with(host, keys)
requires_when_unmet "babushka bootstrapped".with(host)
met? { false }
meet do
ssh("root@#{host}") do |h|
h.babushka(
"conversation:ci provisioned",
keys: keys,
user: user,
buildkite_token: buildkite_token
)
end
end
end
dep "ci prepared" do
requires [
"common:set.locale".with(locale_name: "en_AU"),
"ruby.src".with(version: "2.4.2", patchlevel: "p198"),
]
end
dep "ci provisioned", :user, :keys, :buildkite_token do
requires [
"ci prepared",
"localhost hosts entry",
"lax host key checking",
"tc common packages",
"sharejs common packages",
"counter common packages",
"jobs common packages",
"ci packages",
"ci firewall rules",
"buildkite-agent installed".with(buildkite_token: buildkite_token),
"postgres access".with(username: user, flags: "-sdrw"),
"docker-gc"
]
end
dep "ci packages" do
requires [
"ack-grep.bin",
"silversearcher.bin",
"chromedriver",
"chromium-browser.bin",
"docker.bin",
"docker-compose",
"firefox.bin",
"geckodriver",
"nodejs.bin",
"phantomjs",
"python.bin",
"redis-server.bin",
"sasl.lib",
"slack-cli.npm",
"terraform",
"tmux.bin",
"ufw.bin",
"xvfb.bin"
]
end
dep "ci firewall rules" do
met? do
shell? %q(ufw status | grep "Status: active")
end
meet do
shell "ufw allow ssh/tcp"
shell "ufw allow postgresql/tcp"
shell "ufw --force enable"
end
end
dep "phantomjs", :version do
version.default!("2.1.1")
def phantomjs_uri
if Babushka.host.linux?
"https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-#{version}-linux-x86_64.tar.bz2"
elsif Babushka.host.osx?
"https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-#{version}-macosx.zip"
else
unmeetable! "Not sure where to download a phantomjs binary for #{Babushka.base.host}."
end
end
met? do
in_path? "phantomjs >= #{version}"
end
meet do
Babushka::Resource.extract phantomjs_uri do |_archive|
shell "cp -r . /usr/local/phantomjs"
shell "ln -fs /usr/local/phantomjs/bin/phantomjs /usr/local/bin"
end
end
end
dep "ack-grep.bin" do
provides "ack"
end
dep "python.bin" do
provides "python"
end
dep "xvfb.bin" do
provides "Xvfb"
end
dep "firefox.bin", :version do
version.default!("58.0")
met? do
in_path? "firefox >= #{version}"
end
end
dep "geckodriver", :version do
version.default!("0.19.1")
def geckodriver_uri
if Babushka.host.linux?
"https://github.com/mozilla/geckodriver/releases/download/v#{version}/geckodriver-v#{version}-linux64.tar.gz"
elsif Babushka.host.osx?
"https://github.com/mozilla/geckodriver/releases/download/v#{version}/geckodriver-v#{version}-macos.tar.gz"
else
unmeetable! "Not sure where to download a geckodriver binary for #{Babushka.base.host}."
end
end
def temp_archive
"/tmp/geckodriver.tar.gz"
end
met? do
in_path? "geckodriver >= #{version}"
end
meet do
# Babushka::Resource.extract -> .get -> .download method uses curl to download and recursive calls
# to follow redirects, ending with a invalid filename and a big URL. Calling wget and Babushka::Asset is simpler.
# https://github.com/benhoskings/babushka/blob/937ed6fd117baa1ba2eda1a59d9e580fe6841097/lib/babushka/resource.rb#L30-L51
shell "wget #{geckodriver_uri} -O #{temp_archive}"
Babushka::Asset.for(temp_archive).extract do |_archive|
shell "mv ./geckodriver /usr/local/bin"
end
end
end
dep "chromedriver", :version do
version.default!("2.36")
def chromedriver_uri
if Babushka.host.linux?
"https://chromedriver.storage.googleapis.com/#{version}/chromedriver_linux64.zip"
elsif Babushka.host.osx?
"https://chromedriver.storage.googleapis.com/#{version}/chromedriver_mac64.zip"
else
unmeetable! "Not sure where to download a chromedriver binary for #{Babushka.base.host}."
end
end
met? do
in_path? "chromedriver >= #{version}"
end
meet do
Babushka::Resource.extract chromedriver_uri do |_archive|
shell "mv ./chromedriver /usr/local/bin"
end
end
end
dep "chromium-browser.bin", :version do
version.default!("65")
met? do
in_path? "chromium-browser >= #{version}"
end
meet {
log_shell "Guarantee we have add-apt-repository command", "apt-get --yes install software-properties-common", spinner: true, sudo: true
log_shell "Adding Chromium apt-repository", "add-apt-repository \"ppa:canonical-chromium-builds/stage\"", spinner: true, sudo: true
log_shell "Updating apt lists to load Chromium.", "apt-get update", sudo: true
log_shell "Download latest chromium", "apt-get --yes install chromium-browser", sudo: true
}
end
dep "terraform", :version do
version.default!("0.11.7")
met? do
in_path? "terraform >= #{version}"
end
meet do
Babushka::Resource.extract "https://releases.hashicorp.com/terraform/#{version}/terraform_#{version}_linux_amd64.zip" do
shell "cp -r terraform /usr/local/bin/terraform"
end
end
end