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 @@
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "debian-jessie"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.box = "debian/stretch64"
config.vm.network "forwarded_port", guest: 8080, host: 8080
config.vm.provision :shell do |shell|
shell.path = 'tools/vagrant-provision'
end
config.vm.provider :libvirt do |libvirt|
config.vm.synced_folder './', '/vagrant', type: '9p', disabled: false
end
end
......@@ -8,11 +8,14 @@ Build-Depends: amqp-tools,
devscripts,
dh-systemd (>= 1.5),
fonts-font-awesome (>= 4.0.3~),
inotify-tools,
jq,
moreutils,
patchutils,
rabbitmq-server,
rerun,
ruby,
ruby-foreman,
ruby-rspec (>= 2.14),
shellcheck,
shunit2,
......@@ -62,7 +65,7 @@ Architecture: all
Depends: debci (= ${binary:Version}),
autodep8 (>= 0.2~),
autopkgtest (>= 3.20),
schroot | lxc,
lxc | schroot,
${misc:Depends},
${shlibs:Depends}
Description: continuous integration system for Debian (worker daemon)
......
......@@ -174,21 +174,21 @@ following:
If your code passed the appropriate tests, you will see that there
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
lighttpd to serve the web UI at http://localhost:8080/ from your host machine.
To run the system:
If you make changes to the packages and want to update them in the virtual
machine, just do:
$ foreman start
$ make deb
$ vagrant provision
The web UI will be available at http://localhost:8080/ from your host machine.
......@@ -2,7 +2,7 @@
set -eu
configdir=$(dirname $0)/../config
configdir=`$(dirname $0)/../bin/debci config --values-only config_dir`
if [ ! -f $configdir/whitelist ]; then
for pkg in ruby-defaults rubygems-integration autodep8 pristine-tar; do
......
#!/bin/sh
mkdir -p data/autopkgtest-incoming/
incoming=`$(dirname $0)/../bin/debci config --values-only autopkgtest_incoming_dir`
rerun -x \
--name debci-update \
--dir data/autopkgtest-incoming/ \
--pattern '**/duration' \
--background \
-- ./bin/debci update
mkdir -p "$incoming"
while true; do
inotifywait \
--event modify \
--timeout 1 \
--recursive \
--quiet --quiet \
"$incoming"
./bin/debci update
done
......@@ -14,39 +14,7 @@ esac
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: Hit Control+C to stop"
echo ""
exec /usr/sbin/lighttpd -f "$conffile" -D
cd "$document_root" && python3 -m http.server "$port"
......@@ -2,60 +2,18 @@
set -ex
cd /vagrant
export DEBIAN_FRONTEND=noninteractive
# enable backports
if [ ! -f /etc/apt/sources.list.d/backports.list ]; then
# enable backports in jessie
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 > \
/etc/apt/sources.list.d/backports.list
fi
# serve debci data
apt-get install -qy apache2
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
apt-get update
apt-get install -qy grep-dctrl
# install AMQP server
apt-get install -qy rabbitmq-server
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
grep-dctrl -n -s Build-Depends,Depends '' debian/control \
| sed -e 's/\s(.*)//; s/,$//; /\$/d; s/|.*//; /debci/d' \
| xargs apt-get install -qy
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