From 3fe932d237e90a0beb8b1b5f1008d5cf0b9b4952 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Tue, 13 Mar 2018 20:22:51 +0100 Subject: travis: reworked test runner --- .travis.yml | 3 +- .travis/build.sh | 15 ------ .travis/deploy.sh | 80 ----------------------------- .travis/targets/dist-srpm.sh | 22 ++------ .travis/targets/distcheck.sh | 21 ++------ .travis/targets/github-lambda.sh | 42 +++++++-------- .travis/targets/make-embedded.sh | 16 ++---- .travis/targets/valgrind.sh | 16 ++---- .travis/targets/win32.sh | 33 +++++------- .travis/targets/win64.sh | 33 +++++------- .travis/test-run.sh | 107 +++++++++++++++++++++++++++++++++++++++ 11 files changed, 163 insertions(+), 225 deletions(-) delete mode 100755 .travis/build.sh delete mode 100755 .travis/deploy.sh create mode 100755 .travis/test-run.sh diff --git a/.travis.yml b/.travis.yml index 80136d3..23cfa55 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,5 +40,4 @@ before_script: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install xz; fi script: - - ./.travis/build.sh - - ./.travis/deploy.sh + - ./.travis/test-run.sh diff --git a/.travis/build.sh b/.travis/build.sh deleted file mode 100755 index ce9df01..0000000 --- a/.travis/build.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -set -ex - -if [[ -n "${TARGET}" ]] && [[ -e ".travis/targets/${TARGET}.sh" ]]; then - source ".travis/targets/${TARGET}.sh" -else - echo "Target not defined or invalid!" - exit 1 -fi - -rm -rf build -mkdir -p build - -build diff --git a/.travis/deploy.sh b/.travis/deploy.sh deleted file mode 100755 index f04468c..0000000 --- a/.travis/deploy.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash - -set -e - -if [[ "x${TRAVIS_PULL_REQUEST}" != "xfalse" ]]; then - echo "This is a pull request. skipping deploy ..." - exit 0 -fi - -if [[ "x${TRAVIS_BRANCH}" != "xmaster" ]] && [[ "x${TRAVIS_TAG}" != xv* ]]; then - echo "This isn't master branch nor a valid tag. skipping deploy ..." - exit 0 -fi - -if [[ ! -d build ]]; then - echo "Build directory not found." - exit 1 -fi - -FILES= -if [[ -n "${TARGET}" ]] && [[ -e ".travis/targets/${TARGET}.sh" ]]; then - source ".travis/targets/${TARGET}.sh" -else - echo "Target not defined or invalid!" - exit 1 -fi - -if [[ "x$(type -t deploy)" != "xfunction" ]] || [[ "x$(type -t deploy_cond)" != "xfunction" ]]; then - echo "Nothing to deploy. skipping ..." - exit 0 -fi - -if ! deploy_cond; then - echo "Deploy disabled. skipping ..." - exit 0 -fi - -deploy - -TARNAME="$(grep PACKAGE_TARNAME build/config.h | cut -d\" -f2)" -VERSION="$(grep PACKAGE_VERSION build/config.h | cut -d\" -f2)" - -do_sha512() { - pushd "$(dirname ${1})" > /dev/null - sha512sum "$(basename ${1})" - popd > /dev/null -} - -do_curl() { - curl \ - --silent \ - --form "project=${TARNAME}" \ - --form "version=${VERSION}" \ - --form "file=@${1}" \ - --form "sha512=$(do_sha512 ${1})" \ - "${DISTFILES_URL}" \ - &> /dev/null # make sure that we don't leak tokens -} - -echo " * Found files:" -for f in "${FILES[@]}"; do - echo " $(basename ${f})" -done -echo - -for f in "${FILES[@]}"; do - echo " * Processing file: $(basename ${f}):" - - echo -n " Uploading file ... " - do_curl "${f}" - echo "done" - - echo -done - -# this is a hack to allow failed tests to upload files. -# the target must write status code to build/.test_result, instead of exiting directly -if [[ -f build/.test_result ]]; then - exit $(cat build/.test_result) -fi diff --git a/.travis/targets/dist-srpm.sh b/.travis/targets/dist-srpm.sh index 732b768..aa4e9e8 100644 --- a/.travis/targets/dist-srpm.sh +++ b/.travis/targets/dist-srpm.sh @@ -1,23 +1,9 @@ build() { - pushd build > /dev/null - ../configure \ - CFLAGS="-Wall -g -O0" \ - --disable-silent-rules \ - --enable-ronn \ - --enable-tests \ - --enable-valgrind \ - --enable-git-receiver \ - --enable-make \ - --enable-runserver - popd > /dev/null - - make -C build dist-srpm -} - -deploy_cond() { - [[ "x${CC}" = "xgcc" ]] + default_configure + make dist-srpm } deploy() { - FILES=( build/*.src.rpm ) + FILES=( *.src.rpm ) + [[ ${RV} -eq 0 ]] && [[ "x${CC}" = "xgcc" ]] } diff --git a/.travis/targets/distcheck.sh b/.travis/targets/distcheck.sh index 3bf352d..e1cd9c5 100644 --- a/.travis/targets/distcheck.sh +++ b/.travis/targets/distcheck.sh @@ -1,22 +1,9 @@ build() { - pushd build > /dev/null - ../configure \ - CFLAGS="-Wall -g -O0" \ - --disable-silent-rules \ - --enable-ronn \ - --enable-tests \ - --enable-git-receiver \ - --enable-make \ - --enable-runserver - popd > /dev/null - - make -C build distcheck -} - -deploy_cond() { - [[ "x${CC}" = "xgcc" ]] + default_configure + make distcheck } deploy() { - FILES=( build/*.{*.tar.{gz,bz2,xz},zip} ) + FILES=( *.{*.tar.{gz,bz2,xz},zip} ) + [[ ${RV} -eq 0 ]] && [[ "x${CC}" = "xgcc" ]] } diff --git a/.travis/targets/github-lambda.sh b/.travis/targets/github-lambda.sh index 2a95ca5..d0bb42f 100644 --- a/.travis/targets/github-lambda.sh +++ b/.travis/targets/github-lambda.sh @@ -1,40 +1,32 @@ build() { - pushd build > /dev/null - ../configure \ - CFLAGS="-Wall -g -O0" \ - --enable-ronn \ - --disable-silent-rules \ + default_configure \ + CFLAGS="-Wall -g -O2" \ --disable-tests \ - --disable-valgrind \ --disable-git-receiver \ - --enable-make-embedded \ - --disable-runserver - popd > /dev/null + --disable-runserver \ + --enable-make-embedded - make -C build LDFLAGS="-all-static" blogc + make LDFLAGS="-all-static" blogc - rm -rf build/root - mkdir -p build/root + rm -rf root + mkdir -p root - PV="$(grep PACKAGE_VERSION build/config.h | cut -d\" -f2)" + PV="$(grep PACKAGE_VERSION config.h | cut -d\" -f2)" - install -m 755 build/blogc build/root/blogc - install -m 644 build/src/blogc-github-lambda/lambda_function.py build/root/lambda_function.py - install -m 644 LICENSE build/root/LICENSE - strip build/root/blogc + install -m 755 blogc root/blogc + install -m 644 src/blogc-github-lambda/lambda_function.py root/lambda_function.py + install -m 644 ../LICENSE root/LICENSE + strip root/blogc - pushd build/root/ > /dev/null + pushd root > /dev/null zip "../blogc-github-lambda-${PV}.zip" * popd > /dev/null - install -m 755 build/root/blogc "build/blogc-static-amd64-${PV}" - xz -z "build/blogc-static-amd64-${PV}" -} - -deploy_cond() { - [[ "x${CC}" = "xgcc" ]] + install -m 755 root/blogc "blogc-static-amd64-${PV}" + xz -z "blogc-static-amd64-${PV}" } deploy() { - FILES=( build/*.zip build/blogc-static-*.xz ) + FILES=( *.zip blogc-static-*.xz ) + [[ ${RV} -eq 0 ]] && [[ "x${CC}" = "xgcc" ]] } diff --git a/.travis/targets/make-embedded.sh b/.travis/targets/make-embedded.sh index b2d3f80..d83c88a 100644 --- a/.travis/targets/make-embedded.sh +++ b/.travis/targets/make-embedded.sh @@ -1,15 +1,5 @@ build() { - pushd build > /dev/null - ../configure \ - CFLAGS="-Wall -g -O0" \ - --enable-ronn \ - --disable-silent-rules \ - --enable-tests \ - --enable-valgrind \ - --enable-git-receiver \ - --enable-make-embedded \ - --enable-runserver - popd > /dev/null - - make -C build check + default_configure \ + --enable-make-embedded + make check } diff --git a/.travis/targets/valgrind.sh b/.travis/targets/valgrind.sh index 7870ec1..55d3faa 100644 --- a/.travis/targets/valgrind.sh +++ b/.travis/targets/valgrind.sh @@ -1,15 +1,5 @@ build() { - pushd build > /dev/null - ../configure \ - CFLAGS="-Wall -g -O0" \ - --disable-silent-rules \ - --enable-ronn \ - --enable-tests \ - --enable-valgrind \ - --enable-git-receiver \ - --enable-make \ - --enable-runserver - popd > /dev/null - - make -C build valgrind + default_configure \ + --enable-valgrind + make valgrind } diff --git a/.travis/targets/win32.sh b/.travis/targets/win32.sh index 1c64856..ec3ed03 100644 --- a/.travis/targets/win32.sh +++ b/.travis/targets/win32.sh @@ -1,39 +1,30 @@ build() { - unset CC - pushd build > /dev/null - ../configure \ + default_configure \ + CC= \ CFLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4" \ --host=i686-w64-mingw32 \ --target=i686-w64-mingw32 \ - --enable-ronn \ - --disable-silent-rules \ --disable-tests \ - --disable-valgrind \ --disable-git-receiver \ - --disable-make-embedded \ + --disable-make \ --disable-runserver - popd > /dev/null + make blogc.exe - make -C build blogc.exe - - PN="$(grep PACKAGE_TARNAME build/config.h | cut -d\" -f2)" - PV="$(grep PACKAGE_VERSION build/config.h | cut -d\" -f2)" + PN="$(grep PACKAGE_TARNAME config.h | cut -d\" -f2)" + PV="$(grep PACKAGE_VERSION config.h | cut -d\" -f2)" DEST_DIR="${PN}-${PV}-${TARGET}" rm -rf "${DEST_DIR}" mkdir -p "${DEST_DIR}" - cp build/.libs/blogc.exe "${DEST_DIR}/" - cp LICENSE "${DEST_DIR}/" - cp README.md "${DEST_DIR}/" - - zip "build/${DEST_DIR}.zip" "${DEST_DIR}"/* -} + cp .libs/blogc.exe "${DEST_DIR}/" + cp ../LICENSE "${DEST_DIR}/" + cp ../README.md "${DEST_DIR}/" -deploy_cond() { - [[ "x${CC}" = "xgcc" ]] + zip "${DEST_DIR}.zip" "${DEST_DIR}"/* } deploy() { - FILES=( build/*.zip ) + FILES=( *.zip ) + [[ ${RV} -eq 0 ]] && [[ "x${CC}" = "xgcc" ]] } diff --git a/.travis/targets/win64.sh b/.travis/targets/win64.sh index 47d82ee..e6c4199 100644 --- a/.travis/targets/win64.sh +++ b/.travis/targets/win64.sh @@ -1,39 +1,30 @@ build() { - unset CC - pushd build > /dev/null - ../configure \ + default_configure \ + CC= \ CFLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4" \ --host=x86_64-w64-mingw32 \ --target=x86_64-w64-mingw32 \ - --enable-ronn \ - --disable-silent-rules \ --disable-tests \ - --disable-valgrind \ --disable-git-receiver \ - --disable-make-embedded \ + --disable-make \ --disable-runserver - popd > /dev/null + make blogc.exe - make -C build blogc.exe - - PN="$(grep PACKAGE_TARNAME build/config.h | cut -d\" -f2)" - PV="$(grep PACKAGE_VERSION build/config.h | cut -d\" -f2)" + PN="$(grep PACKAGE_TARNAME config.h | cut -d\" -f2)" + PV="$(grep PACKAGE_VERSION config.h | cut -d\" -f2)" DEST_DIR="${PN}-${PV}-${TARGET}" rm -rf "${DEST_DIR}" mkdir -p "${DEST_DIR}" - cp build/.libs/blogc.exe "${DEST_DIR}/" - cp LICENSE "${DEST_DIR}/" - cp README.md "${DEST_DIR}/" - - zip "build/${DEST_DIR}.zip" "${DEST_DIR}"/* -} + cp .libs/blogc.exe "${DEST_DIR}/" + cp ../LICENSE "${DEST_DIR}/" + cp ../README.md "${DEST_DIR}/" -deploy_cond() { - [[ "x${CC}" = "xgcc" ]] + zip "${DEST_DIR}.zip" "${DEST_DIR}"/* } deploy() { - FILES=( build/*.zip ) + FILES=( *.zip ) + [[ ${RV} -eq 0 ]] && [[ "x${CC}" = "xgcc" ]] } 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 -- cgit v1.2.3-18-g5258