Commit 95cf1247 authored by Antonio Terceiro's avatar Antonio Terceiro

Automate development environment with vagrant

Previously the vagrant setup assumed you would install the .deb's, but
that is mostly pointless.
parent 13a07b82
...@@ -5,9 +5,13 @@ ...@@ -5,9 +5,13 @@
VAGRANTFILE_API_VERSION = "2" VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "debian-jessie" config.vm.box = "debian/stretch64"
config.vm.network "forwarded_port", guest: 80, host: 8080 config.vm.network "forwarded_port", guest: 8080, host: 8080
config.vm.provision :shell do |shell| config.vm.provision :shell do |shell|
shell.path = 'tools/vagrant-provision' shell.path = 'tools/vagrant-provision'
end end
config.vm.provider :libvirt do |libvirt|
config.vm.synced_folder './', '/vagrant', type: '9p', disabled: false
end
end end
...@@ -8,11 +8,14 @@ Build-Depends: amqp-tools, ...@@ -8,11 +8,14 @@ Build-Depends: amqp-tools,
devscripts, devscripts,
dh-systemd (>= 1.5), dh-systemd (>= 1.5),
fonts-font-awesome (>= 4.0.3~), fonts-font-awesome (>= 4.0.3~),
inotify-tools,
jq, jq,
moreutils, moreutils,
patchutils, patchutils,
rabbitmq-server, rabbitmq-server,
rerun,
ruby, ruby,
ruby-foreman,
ruby-rspec (>= 2.14), ruby-rspec (>= 2.14),
shellcheck, shellcheck,
shunit2, shunit2,
...@@ -62,7 +65,7 @@ Architecture: all ...@@ -62,7 +65,7 @@ Architecture: all
Depends: debci (= ${binary:Version}), Depends: debci (= ${binary:Version}),
autodep8 (>= 0.2~), autodep8 (>= 0.2~),
autopkgtest (>= 3.20), autopkgtest (>= 3.20),
schroot | lxc, lxc | schroot,
${misc:Depends}, ${misc:Depends},
${shlibs:Depends} ${shlibs:Depends}
Description: continuous integration system for Debian (worker daemon) Description: continuous integration system for Debian (worker daemon)
......
...@@ -174,21 +174,21 @@ following: ...@@ -174,21 +174,21 @@ following:
If your code passed the appropriate tests, you will see that there If your code passed the appropriate tests, you will see that there
are no failures reported by rspec. are no failures reported by rspec.
# testing Debian packages with vagrant # Development environment with vagrant
First build the packages locally: Bring up the vagrant virtual machine:
$ make deb $ vagrant up
Then bring up the vagrant virtual machine: After that, the system should be properly setup. To run the tests, enter the VM
(`vagrant ssh`), and from there:
$ cd /vagrant
$ make test
$ vagrant up
This will install the locally-built packages into the vagrant box, and setup To run the system:
lighttpd to serve the web UI at http://localhost:8080/ from your host machine.
If you make changes to the packages and want to update them in the virtual $ foreman start
machine, just do:
$ make deb The web UI will be available at http://localhost:8080/ from your host machine.
$ vagrant provision
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
set -eu set -eu
configdir=$(dirname $0)/../config configdir=`$(dirname $0)/../bin/debci config --values-only config_dir`
if [ ! -f $configdir/whitelist ]; then if [ ! -f $configdir/whitelist ]; then
for pkg in ruby-defaults rubygems-integration autodep8 pristine-tar; do for pkg in ruby-defaults rubygems-integration autodep8 pristine-tar; do
......
#!/bin/sh #!/bin/sh
mkdir -p data/autopkgtest-incoming/ incoming=`$(dirname $0)/../bin/debci config --values-only autopkgtest_incoming_dir`
rerun -x \ mkdir -p "$incoming"
--name debci-update \
--dir data/autopkgtest-incoming/ \ while true; do
--pattern '**/duration' \ inotifywait \
--background \ --event modify \
-- ./bin/debci update --timeout 1 \
--recursive \
--quiet --quiet \
"$incoming"
./bin/debci update
done
...@@ -14,39 +14,7 @@ esac ...@@ -14,39 +14,7 @@ esac
document_root="$(dirname $0)/../public" document_root="$(dirname $0)/../public"
conffile=$(mktemp)
cleanup() {
rm -rf "$conffile"
}
trap cleanup INT TERM EXIT
cat > "$conffile" <<-EOF
server.document-root = "$document_root"
server.port = $port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
mimetype.assign += (".log" => "text/plain; charset=utf-8")
dir-listing.encoding = "utf-8"
server.dir-listing = "enable"
index-file.names = ("index.html", "index.htm")
server.modules += ("mod_setenv")
\$HTTP["url"] =~ "\.log\.gz" {
server.error-handler-404 = "/notfound.log.gz"
setenv.add-response-header = (
"Content-Encoding" => "gzip",
"Content-Type" => "text/plain; charset=utf-8"
)
}
server.modules += ("mod_rewrite")
url.rewrite-if-not-file = (
"^(.*\.log)\$" => "\$1.moved"
)
server.modules += ("mod_redirect")
url.redirect = (
"^(.*\.log)\.moved\$" => "\$1.gz"
)
EOF
echo "I: Go to: http://localhost:$port/" echo "I: Go to: http://localhost:$port/"
echo "I: Hit Control+C to stop" echo "I: Hit Control+C to stop"
echo "" echo ""
exec /usr/sbin/lighttpd -f "$conffile" -D cd "$document_root" && python3 -m http.server "$port"
...@@ -2,60 +2,18 @@ ...@@ -2,60 +2,18 @@
set -ex set -ex
cd /vagrant
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
# enable backports # enable backports in jessie
if [ ! -f /etc/apt/sources.list.d/backports.list ]; then if grep -q jessie /etc/apt/sources.list && [ ! -f /etc/apt/sources.list.d/backports.list ]; then
sed -e 's/\bjessie\b/jessie-backports/' /etc/apt/sources.list > \ sed -e 's/\bjessie\b/jessie-backports/' /etc/apt/sources.list > \
/etc/apt/sources.list.d/backports.list /etc/apt/sources.list.d/backports.list
fi fi
# serve debci data apt-get update
apt-get install -qy apache2 apt-get install -qy grep-dctrl
a2enmod headers
cat > /etc/apache2/sites-enabled/debci.conf <<EOF
<VirtualHost *:80>
ServerName localhost
ServerAlias debci.local
DocumentRoot /usr/share/debci/public
ErrorLog \${APACHE_LOG_DIR}/debci.error.log
CustomLog \${APACHE_LOG_DIR}/debci.access.log combined
<Directory /usr/share/debci/public>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModule mod_headers.c>
<FilesMatch "log$">
Header set Content-Type "text/plain; charset=utf-8"
</FilesMatch>
<FilesMatch "log\.gz$">
# Serve correct encoding type.
Header append Content-Encoding gzip
Header set Content-Type "text/plain; charset=utf-8"
</FilesMatch>
</IfModule>
</VirtualHost>
EOF
service apache2 reload
# install AMQP server grep-dctrl -n -s Build-Depends,Depends '' debian/control \
apt-get install -qy rabbitmq-server | sed -e 's/\s(.*)//; s/,$//; /\$/d; s/|.*//; /debci/d' \
| xargs apt-get install -qy
for base in /vagrant /debci; do
if [ -d $base ]; then break; fi
done
# install debci from locally built packages
if test -d $base/tmp/deb; then
dpkg --unpack $base/tmp/deb/*.deb
apt-get install -qyf
else
echo
set +x
echo "To install locally-built packages into the vagrant box for testing,"
echo "run on the host:"
echo
echo ' $ make deb'
echo ' $ vagrant provision'
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment