X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/4d3faccfe98c1f00987d7bc1ab6509ef347cc2ac..1aa0a5407d6a4e6b861d1fcf52d8268d62b9d6d4:/jenkins/run-build-packages-one-target.sh diff --git a/jenkins/run-build-packages-one-target.sh b/jenkins/run-build-packages-one-target.sh index 5451a4ece3..95977030fc 100755 --- a/jenkins/run-build-packages-one-target.sh +++ b/jenkins/run-build-packages-one-target.sh @@ -10,11 +10,19 @@ Syntax: Distribution to build packages for (default: debian7) --command Build command to execute (default: use built-in Docker image command) +--test-packages + Run package install test script "test-packages-$target.sh" +--debug + Output debug information (default: false) +--only-test + Test only a specific package WORKSPACE=path Path to the Arvados source tree to build packages from EOF +set -e + if ! [[ -n "$WORKSPACE" ]]; then echo >&2 "$helpmessage" echo >&2 @@ -32,7 +40,7 @@ if ! [[ -d "$WORKSPACE" ]]; then fi PARSEDOPTS=$(getopt --name "$0" --longoptions \ - help,target:,command: \ + help,debug,test-packages,target:,command:,only-test: \ -- "" "$@") if [ $? -ne 0 ]; then exit 1 @@ -40,6 +48,7 @@ fi TARGET=debian7 COMMAND= +DEBUG= eval set -- "$PARSEDOPTS" while [ $# -gt 0 ]; do @@ -52,9 +61,18 @@ while [ $# -gt 0 ]; do --target) TARGET="$2"; shift ;; + --only-test) + packages="$2"; shift + ;; + --debug) + DEBUG=" --debug" + ;; --command) COMMAND="$2"; shift ;; + --test-packages) + test_packages=1 + ;; --) if [ $# -gt 1 ]; then echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help" @@ -67,34 +85,98 @@ done set -e -if [[ "$COMMAND" != "" ]]; then - COMMAND="/usr/local/rvm/bin/rvm-exec default bash /jenkins/$COMMAND --target $TARGET" +if [[ -n "$test_packages" ]]; then + if [[ -n "$(find $WORKSPACE/packages/$TARGET -name *.rpm)" ]] ; then + createrepo $WORKSPACE/packages/$TARGET + fi + + if [[ -n "$(find $WORKSPACE/packages/$TARGET -name *.deb)" ]] ; then + (cd $WORKSPACE/packages/$TARGET + dpkg-scanpackages . 2> >(grep -v 'warning' 1>&2) | gzip -c > Packages.gz + ) + fi + + COMMAND="/jenkins/package-testing/test-packages-$TARGET.sh" + IMAGE="arvados/package-test:$TARGET" +else + IMAGE="arvados/build:$TARGET" + if [[ "$COMMAND" != "" ]]; then + COMMAND="/usr/local/rvm/bin/rvm-exec default bash /jenkins/$COMMAND --target $TARGET$DEBUG" + fi fi -FINAL_EXITCODE=0 JENKINS_DIR=$(dirname "$(readlink -e "$0")") -run_docker() { - local tag=$1; shift - if docker run -v "$JENKINS_DIR:/jenkins" -v "$WORKSPACE:/arvados" \ - --env ARVADOS_DEBUG=1 "arvados/build:$tag" $COMMAND; then - # Success - nothing more to do. - true +if [[ -n "$test_packages" ]]; then + pushd "$JENKINS_DIR/package-test-dockerfiles" +else + pushd "$JENKINS_DIR/package-build-dockerfiles" + make "$TARGET/generated" +fi + +echo $TARGET +cd $TARGET +time docker build --tag=$IMAGE . +popd + +if test -z "$packages" ; then + packages="arvados-api-server + arvados-data-manager + arvados-docker-cleaner + arvados-git-httpd + arvados-node-manager + arvados-src + arvados-workbench + crunchstat + keepproxy + keep-rsync + keepstore + keep-web + libarvados-perl" + + case "$TARGET" in + centos6) + packages="$packages python27-python-arvados-fuse + python27-python-arvados-python-client" + ;; + *) + packages="$packages python-arvados-fuse + python-arvados-python-client" + ;; + esac +fi + +FINAL_EXITCODE=0 + +package_fails="" + +if [[ -n "$test_packages" ]]; then + for p in $packages ; do + if docker run --rm -v "$JENKINS_DIR:/jenkins" -v "$WORKSPACE:/arvados" \ + --env ARVADOS_DEBUG=1 \ + --env "TARGET=$TARGET" \ + --env "WORKSPACE=/arvados" \ + "$IMAGE" $COMMAND $p ; then + true + else + FINAL_EXITCODE=$? + package_fails="$package_fails $p" + echo "ERROR: $tag test failed with exit status $FINAL_EXITCODE." >&2 + fi + done +else + if docker run --rm -v "$JENKINS_DIR:/jenkins" -v "$WORKSPACE:/arvados" \ + --env ARVADOS_DEBUG=1 "$IMAGE" $COMMAND ; then + echo + echo "Build packages for $TARGET succeeded." >&2 else FINAL_EXITCODE=$? echo "ERROR: $tag build failed with exit status $FINAL_EXITCODE." >&2 fi -} - -# In case it's needed, build the container. This costs just a few -# seconds when the container already exist, so it's not a big deal to -# do it on each run. -cd "$JENKINS_DIR/dockerfiles" -echo $TARGET -cd $TARGET -time docker build -t arvados/build:$TARGET . -cd .. +fi -run_docker $TARGET +if test -n "$package_fails" ; then + echo "Failed package tests:$package_fails" >&2 +fi exit $FINAL_EXITCODE