Skip to content
This repository has been archived by the owner on May 31, 2018. It is now read-only.

Commit

Permalink
Add Travis CI and some tests
Browse files Browse the repository at this point in the history
* Travis CI configuration
* Add arch-pacaur Docker image.
* Add basic package tests.
  • Loading branch information
ismaelgv committed Dec 12, 2017
1 parent 63096e4 commit 9ff3c70
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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"
19 changes: 19 additions & 0 deletions tests/image/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions tests/test_packages.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9ff3c70

Please sign in to comment.