-
Notifications
You must be signed in to change notification settings - Fork 72
/
Vagrantfile
88 lines (66 loc) · 2.11 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
VAGRANTFILE_API_VERSION = "2"
BOX_NAME = ENV['BOX_NAME'] || "ubuntu/xenial64"
module OS
def OS.windows?
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
end
end
script = <<SCRIPT
#!/bin/bash -e
if [ ! -e /vagrant/blockade ]; then
echo "/vagrant/blockade not found. are we in a vagrant blockade environment??" >&2
exit 1
fi
if [ ! -f /etc/default/docker ]; then
echo "/etc/default/docker not found -- is docker installed?" >&2
exit 1
fi
apt-get update
apt-get -y install python-pip python-virtualenv python-dev python3-dev
cd /vagrant
export PIP_DOWNLOAD_CACHE=/vagrant/.pip_download_cache
# install into system python for manual testing
python setup.py develop
# apt version of tox is still too old in trusty
pip install tox
SCRIPT
run_tox_from_windows = <<SCRIPT
#!/bin/bash -e
# We have to copy the working folder onto vagrant home. Tox won't start from inside mounted /vagrant folder in Windows
# See links below:
# https://github.com/gratipay/gratipay.com/issues/2327
# http://stackoverflow.com/questions/24640819/protocol-error-setting-up-virtualenvironment-through-vagrant-on-ubuntu
cp -R /vagrant/* ~
cd ~
tox
SCRIPT
run_tox_default = <<SCRIPT
#!/bin/bash -e
cd /vagrant
tox
SCRIPT
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = BOX_NAME
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
end
config.vm.provider :virtualbox do |vb, override|
end
# there are obviously vagrant versions with a
# broken 'docker' provisioner that can be fixed
# by invoking an 'apt-get update' *before* docker itself
config.vm.provision "shell", inline: "apt-get update"
# fetch the ubuntu:latest image that is required for
# the test suite
config.vm.provision "docker",
images: ["krallin/ubuntu-tini:trusty"]
# kick off the tests automatically
config.vm.provision "shell", inline: script
if OS.windows?
config.vm.provision "shell", inline: run_tox_from_windows
else
config.vm.provision "shell", inline: run_tox_default
end
# clean up after the tests
config.vm.provision "shell", inline: "rm -rf /tmp/.blockade"
end