aboutsummaryrefslogtreecommitdiffstats
path: root/.travis/test-run.sh
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2018-03-13 20:22:51 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2018-03-13 20:22:51 +0100
commit3fe932d237e90a0beb8b1b5f1008d5cf0b9b4952 (patch)
tree3398a5147c0793054a72dcb81475c0e880708f7c /.travis/test-run.sh
parentbc1c0a563edbaaa639ebd5741d3c0f8144e5bb8f (diff)
downloadblogc-3fe932d237e90a0beb8b1b5f1008d5cf0b9b4952.tar.gz
blogc-3fe932d237e90a0beb8b1b5f1008d5cf0b9b4952.tar.bz2
blogc-3fe932d237e90a0beb8b1b5f1008d5cf0b9b4952.zip
travis: reworked test runner
Diffstat (limited to '.travis/test-run.sh')
-rwxr-xr-x.travis/test-run.sh107
1 files changed, 107 insertions, 0 deletions
diff --git a/.travis/test-run.sh b/.travis/test-run.sh
new file mode 100755
index 0000000..ffff639
--- /dev/null
+++ b/.travis/test-run.sh
@@ -0,0 +1,107 @@
+#!/bin/bash
+
+set -e
+
+SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
+TARGET_SCRIPT="${SCRIPT_DIR}/targets/${TARGET}.sh"
+
+if [[ -n "${TARGET}" ]] && [[ -e "${TARGET_SCRIPT}" ]]; then
+ source "${TARGET_SCRIPT}"
+else
+ echo "Target not defined or invalid!"
+ exit 1
+fi
+
+set -x
+
+BUILD=0
+[[ "x$(type -t build)" = "xfunction" ]] && BUILD=1
+
+DEPLOY=0
+[[ "x$(type -t deploy)" = "xfunction" ]] && DEPLOY=1
+
+SOURCE_DIR="$(dirname "${SCRIPT_DIR}")"
+BUILD_DIR="${SOURCE_DIR}/build"
+
+default_configure() {
+ pushd "${BUILD_DIR}" > /dev/null
+ "${SOURCE_DIR}/configure" \
+ CFLAGS="-Wall -g -O0" \
+ --disable-silent-rules \
+ --disable-valgrind \
+ --enable-ronn \
+ --enable-tests \
+ --enable-git-receiver \
+ --enable-make \
+ --enable-runserver \
+ "$@"
+ popd > /dev/null
+}
+
+rm -rf "${BUILD_DIR}"
+mkdir -p "${BUILD_DIR}"
+
+RV=0
+
+if [[ ${BUILD} -eq 1 ]]; then
+ pushd "${BUILD_DIR}" > /dev/null
+ set +e
+ build
+ RV=$?
+ set -e
+ popd > /dev/null
+fi
+
+[[ ${DEPLOY} -eq 1 ]] || exit ${RV}
+
+[[ "x${TRAVIS_PULL_REQUEST}" != "xfalse" ]] && exit ${RV}
+[[ "x${TRAVIS_BRANCH}" != "xmaster" ]] && [[ "x${TRAVIS_TAG}" != xv* ]] && exit ${RV}
+
+[[ -d "${BUILD_DIR}" ]] || exit ${RV}
+
+FILES=
+pushd "${BUILD_DIR}" > /dev/null
+deploy || exit ${RV}
+popd > /dev/null
+
+set +x
+
+PN="$(grep PACKAGE_TARNAME "${BUILD_DIR}/config.h" | cut -d\" -f2)"
+PV="$(grep PACKAGE_VERSION "${BUILD_DIR}/config.h" | cut -d\" -f2)"
+
+do_sha512() {
+ pushd "$(dirname ${1})" > /dev/null
+ sha512sum "$(basename ${1})"
+ popd > /dev/null
+}
+
+do_curl() {
+ curl \
+ --silent \
+ --form "project=${PN}" \
+ --form "version=${PV}" \
+ --form "file=@${1}" \
+ --form "sha512=$(do_sha512 ${1})" \
+ "${DISTFILES_URL}" \
+ &> /dev/null # make sure that we don't leak tokens
+}
+
+echo
+echo " * Found files:"
+for f in "${FILES[@]}"; do
+ echo " ${f}"
+done
+echo
+
+for f in "${FILES[@]}"; do
+ echo " * Processing file: $(basename ${f}):"
+
+ echo -n " Uploading file ... "
+ if do_curl "${BUILD_DIR}/${f}"; then
+ echo "done"
+ else
+ echo "fail"
+ fi
+
+ echo
+done