diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..aa886a01 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ +sudo: required +language: bash + +services: + - docker + +before_install: docker build -t arch-pacaur tests/image + +env: + - TEST="make && sudo make install" + - TEST="tests/test_packages.sh" + +script: docker run -v $(pwd):/home/pacaur/pacaur arch-pacaur /bin/bash -lc "sudo chown -R pacaur .; $TEST" diff --git a/tests/image/Dockerfile b/tests/image/Dockerfile new file mode 100644 index 00000000..7025bea5 --- /dev/null +++ b/tests/image/Dockerfile @@ -0,0 +1,19 @@ +FROM base/devel +# update the image and install pacaur dependencies +RUN pacman -Syu --noconfirm +RUN pacman -S --noconfirm git expac + +# prepare the pacaur environment +RUN useradd -m pacaur +RUN echo 'pacaur ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers + +# build cower +USER pacaur +WORKDIR /home/pacaur +RUN git clone https://aur.archlinux.org/cower.git +WORKDIR /home/pacaur/cower +RUN gpg --recv-keys --keyserver hkp://pgp.mit.edu 1EB2638FF56C0C53 +RUN makepkg -sri --noconfirm + +RUN mkdir -p /home/pacaur/pacaur +WORKDIR /home/pacaur/pacaur diff --git a/tests/test_packages.sh b/tests/test_packages.sh new file mode 100755 index 00000000..61143b07 --- /dev/null +++ b/tests/test_packages.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +## +# Test command given as argument. +# +# $1 = command +## +test_command() +{ + COMMAND="$1 &> /dev/null" + if eval $COMMAND;then + echo OK + else + echo FAILED + ANY_FAILED=true + fi +} + +SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" +# Use this repository pacaur script by default +if [ -z ${PACAUR} ]; then PACAUR="${SCRIPTPATH::-5}pacaur"; fi +# Track any error +ANY_FAILED=false +# Packages to be processed +PACKAGES="shellcheck-static" + +echo "Testing operation with packages:" +echo -n "Update system..." +test_command "${PACAUR} -Syu --noconfirm" +echo -n "Install packages..." +test_command "${PACAUR} -S --noconfirm --noedit ${PACKAGES}" +echo -n "Uninstall packages..." +test_command "${PACAUR} -R --noconfirm ${PACKAGES}" + +if ${ANY_FAILED}; then exit 1; else exit 0; fi