diff options
author | Stefan Auditor | 2017-03-15 09:16:02 +0100 |
---|---|---|
committer | Stefan Auditor | 2017-03-15 09:16:02 +0100 |
commit | fd42b310ea825f7dccc163c9d1954cc23d86ba7b (patch) | |
tree | b3470ded8bc19610434cf6b8acdb732614669015 | |
parent | 7c3b8b7291cf20caa42e0dc9d66bc98c2f346103 (diff) | |
download | aur-fd42b310ea825f7dccc163c9d1954cc23d86ba7b.tar.gz |
Add automated testing
-rw-r--r-- | .gitlab-ci.yml | 57 | ||||
-rwxr-xr-x | test.sh | 83 |
2 files changed, 140 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000000..b054fc4b6154 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,57 @@ +image: base/devel + +stages: + - test + - deploy + +test: + stage: test + only: + - master + before_script: + - pacman -Syyu --noconfirm + - pacman -S namcap --noconfirm + - useradd somebody + - echo "somebody ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + - mkdir -p /home/somebody/ + - chown -R somebody:somebody /home/somebody/ + script: + - sudo -u somebody ./test.sh + +github: + stage: deploy + before_script: + - pacman -Syyu git --noconfirm + - git checkout "$CI_BUILD_REF_NAME" + - git remote add github https://"$GITHUB_USERNAME":"$GITHUB_TOKEN"@github.com/sanduhrs/arch-aur-traefik-bin + script: + - echo "Deploy to Github" + - git push github + environment: + name: staging + url: https://github.com/sanduhrs/arch-aur-traefik + only: + - branches + +aur: + stage: deploy + before_script: + - pacman -Syyu git openssh --noconfirm + - eval $(ssh-agent -s) + - ssh-add <(echo "$SSH_PRIVATE_KEY") + # For Docker builds disable host key checking. Be aware that by adding that + # you are suspectible to man-in-the-middle attacks. + # WARNING: Use this only with the Docker executor, if you use it with shell + # you will overwrite your user's SSH config. + - mkdir -p ~/.ssh + - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' + - git checkout master + - git remote add aur ssh://aur@aur.archlinux.org/traefik-bin.git + script: + - echo "Deploy to Github" + - git push aur + environment: + name: production + url: https://aur.archlinux.org/packages/traefik-bin + only: + - master diff --git a/test.sh b/test.sh new file mode 100755 index 000000000000..e4ab0d9e0888 --- /dev/null +++ b/test.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +if [ ! -z ${1+x} ]; +then + if [[ $1 == *\/ ]]; + then + SRCINFO="$1.SRCINFO" + else + SRCINFO="$1/.SRCINFO" + fi +else + SRCINFO=".SRCINFO" +fi + +while getopts b:v:r:e:a: option +do + case "${option}" + in + b) PKGBASE=${OPTARG};; + v) PKGVER=${OPTARG};; + r) PKGREL=${OPTARG};; + e) EPOCH=$OPTARG;; + a) ARCH=$OPTARG;; + esac +done + +if [ -z ${PKGBASE+x} ]; +then + PKGBASE=$(egrep -o "pkgbase = (.*)" "${SRCINFO}" | cut -d= -sf2 | xargs) + echo "PKGBASE=${PKGBASE} detected" +fi + +if [ -z ${PKGVER+x} ]; +then + PKGVER=$(egrep -o "pkgver = (.*)" "${SRCINFO}" | cut -d= -sf2 | xargs) + echo "PKGVER=${PKGVER} detected" +fi + +if [ -z ${PKGREL+x} ]; +then + PKGREL=$(egrep -o "pkgrel = (.*)" "${SRCINFO}" | cut -d= -sf2 | xargs) + echo "PKGREL=${PKGREL} detected" +fi + +if [ -z ${EPOCH+x} ]; +then + EPOCH=$(egrep -o "epoch = (.*)" "${SRCINFO}" | cut -d= -sf2 | xargs) + echo "EPOCH=${EPOCH} detected" +fi + +if [ -z ${ARCH+x} ]; +then + ARCH=$(uname -m) + echo "ARCH=${ARCH} detected" +fi + +FILE="${PKGBASE}-${PKGVER}-${PKGREL}-${ARCH}.pkg.tar.xz" +if [ ! -z ${EPOCH} ]; +then + FILE="${PKGBASE}-${EPOCH}:${PKGVER}-${PKGREL}-${ARCH}.pkg.tar.xz" +fi + +echo "" +echo "makepkg --noconfirm -s" +echo "--" +makepkg --noconfirm -s + +echo "" +echo "namcap PKGBUILD" +echo "--" +namcap PKGBUILD + +echo "" +echo "namcap ${FILE}" +echo "--" +namcap "${FILE}" + +echo "" +echo "makepkg --noconfirm -i" +echo "--" +makepkg --noconfirm -i + +exit 0 |