Skip to content

Commit

Permalink
Review and clean the vagrant setup, add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitri committed Oct 20, 2013
1 parent fb818ee commit 208d10c
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 60 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
.vagrant
local-data
pgloader.1
pgloader.html
pgloader.pdf
build/
69 changes: 69 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# pgloader build tools

POMO_PATCH = $(realpath patches/postmodern-send-copy-done.patch)
ASDF_CONFD = ~/.config/common-lisp/source-registry.conf.d
ASDF_CONF = $(ASDF_CONFD)/projects.conf

docs:
pandoc pgloader.1.md -o pgloader.1
pandoc pgloader.1.md -o pgloader.html
pandoc pgloader.1.md -o pgloader.pdf

~/quicklisp/local-projects/Postmodern:
git clone https://github.com/marijnh/Postmodern.git $@
cd ~/quicklisp/local-projects/Postmodern/ && patch -p1 < $(POMO_PATCH)

postmodern: ~/quicklisp/local-projects/Postmodern ;

~/quicklisp/local-projects/cl-csv:
git clone -b empty-strings-and-nil https://github.com/dimitri/cl-csv.git $@

cl-csv: ~/quicklisp/local-projects/cl-csv ;

~/quicklisp/setup.lisp:
curl -o ~/quicklisp.lisp http://beta.quicklisp.org/quicklisp.lisp
sbcl --load ~/quicklisp.lisp \
--eval '(quicklisp-quickstart:install)' \
--eval '(quit)'

quicklisp: ~/quicklisp/setup.lisp ;

$(ASDF_CONF):
mkdir -p $(ASDF_CONFD)
echo '(:tree "/vagrant")' > $@

asdf-config: $(ASDF_CONF) ;

libs: quicklisp $(ASDF_CONF) postmodern cl-csv
# Quicklisp Install needed Common Lisp libs
sbcl --load ~/quicklisp/setup.lisp \
--eval '(ql:quickload "pgloader")' \
--eval '(quit)'

./build/manifest.ql: libs
sbcl --load ~/quicklisp/setup.lisp \
--eval '(ql:write-asdf-manifest-file "./build/manifest.ql")' \
--eval '(quit)'

./build/buildapp: quicklisp
sbcl --load ~/quicklisp/setup.lisp \
--eval '(ql:quickload "buildapp")' \
--eval '(buildapp:build-buildapp "./build/buildapp")' \
--eval '(quit)'

./build/pgloader.exe: ./build/buildapp ./build/manifest.ql
./build/buildapp --logfile /tmp/build.log \
--asdf-tree ~/quicklisp/local-projects \
--manifest-file ./build/manifest.ql \
--asdf-tree ~/quicklisp/dists \
--asdf-path . \
--load-system pgloader \
--entry pgloader:main \
--dynamic-space-size 4096 \
--compress-core \
--output build/pgloader.exe

test: ./build/pgloader.exe
$(MAKE) PGLOADER=build/pgloader.exe -C test all

check: test ;
5 changes: 4 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ VAGRANTFILE_API_VERSION = "2"
Vagrant.configure("2") do |config|
config.vm.box = "wheezy64"

config.vm.provision :shell, :path => "bootstrap.sh"
config.vm.provision "shell" do |s|
s.path = "bootstrap.sh"
s.privileged = false
end
end
72 changes: 13 additions & 59 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,70 +1,24 @@
#!/usr/bin/env bash

echo "deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main" > /etc/apt/sources.list.d/pgdg.list
pgdg=/etc/apt/sources.list.d/pgdg.list
pgdgkey=https://www.postgresql.org/media/keys/ACCC4CF8.asc
echo "deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main" | sudo tee $pgdg

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
wget --quiet -O - ${pgdgkey} | sudo apt-key add -

apt-get update
apt-get install -y postgresql-9.3 postgresql-contrib-9.3
apt-get install -y sbcl libmysqlclient-dev git patch unzip
sudo apt-get update
sudo apt-get install -y postgresql-9.3 postgresql-contrib-9.3 \
postgresql-9.3-ip4r \
sbcl \
git patch unzip \
libmysqlclient-dev

HBA=/etc/postgresql/9.3/main/pg_hba.conf
echo "local all all trust" | sudo tee $HBA
echo "host all all 127.0.0.1/32 trust" | sudo tee -a $HBA

sudo pg_ctlcluster 9.3 main reload
createuser -U postgres -SdR `whoami`
createdb pgloader
sudo createuser -U postgres -SdR `whoami`
sudo createdb -U postgres -O `whoami` pgloader

wget --quiet http://beta.quicklisp.org/quicklisp.lisp
sbcl --load quicklisp.lisp <<EOF
(quicklisp-quickstart:install)
(ql:add-to-init-file)
(ql:quickload "buildapp")
(buildapp:build-buildapp "/home/vagrant/buildapp")
(quit)
EOF

cd ~/quicklisp/local-projects/
git clone -b empty-strings-and-nil https://github.com/dimitri/cl-csv.git
git clone https://github.com/marijnh/Postmodern.git

cd ~/quicklisp/local-projects/Postmodern/
patch -p1 < /vagrant/patches/postmodern-send-copy-done.patch

cd ~

sbcl --load quicklisp/setup.lisp <<EOF
(pushnew #p"/vagrant/" asdf:*central-registry*)
(pushnew #p"/vagrant/lib/db3/" asdf:*central-registry*)
(pushnew #p"/vagrant/lib/abnf/" asdf:*central-registry*)
(ql:quickload "pgloader")
(quit)
EOF

REGISTRY=~/.config/common-lisp/source-registry.conf.d
mkdir -p $REGISTRY
echo "(:tree \"/vagrant/\")" > $REGISTRY/projects.conf

# echo "BUILDING PGLOADER SELF-CONTAINED BINARY"

# /home/vagrant/buildapp --logfile /tmp/build.log \
# --asdf-tree ~/quicklisp/dists \
# --asdf-tree /vagrant \
# --load-system pgloader \
# --entry pgloader:main \
# --dynamic-space-size 4096 \
# --output /home/vagrant/pgloader.exe

echo "TESTING"

/vagrant/pgloader.lisp --help

for test in /vagrant/test/*.load
do
echo "# TEST: $test"
echo
/vagrant/pgloader.lisp $test
echo
done
make -C /vagrant test
9 changes: 9 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
TESTS = $(wildcard *.load)
OUT = $(TESTS:.load=.out)

all: $(OUT)
echo $(OUT)

%.out: %.load
$(PGLOADER) --verbose $<
@echo

0 comments on commit 208d10c

Please sign in to comment.