From c2d04d51b143bb045bc5b4ec3d4cf798a3baf540 Mon Sep 17 00:00:00 2001 From: Bryan Thornbury Date: Wed, 2 Dec 2015 19:52:19 +0000 Subject: [PATCH] Changes to propagate errors in package build. --- packaging/debian/package_tool/package_tool | 4 +- scripts/_common.sh | 9 +++++ scripts/docker/dockerbuild.sh | 2 + scripts/package/package-debian.sh | 45 ++++++++++++++++------ scripts/package/package.sh | 2 + scripts/test/e2e-test.sh | 1 - 6 files changed, 49 insertions(+), 14 deletions(-) diff --git a/packaging/debian/package_tool/package_tool b/packaging/debian/package_tool/package_tool index 1d12b171e..9747f6496 100755 --- a/packaging/debian/package_tool/package_tool +++ b/packaging/debian/package_tool/package_tool @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (c) .NET Foundation and contributors. All rights reserved. # Licensed under the MIT license. See LICENSE file in the project root for full license information. @@ -9,6 +9,8 @@ # $2 = Output Directory # $3 = Package Version +set -e + SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ## Load Functions ## diff --git a/scripts/_common.sh b/scripts/_common.sh index 854081c3b..27defa42e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,6 +5,14 @@ # Source this to add some fancy stuff to your scripts +COMMONSOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + COMMONDIR="$( cd -P "$( dirname "$COMMONSOURCE" )" && pwd )" + COMMONSOURCE="$(readlink "$COMMONSOURCE")" + [[ $COMMONSOURCE != /* ]] && COMMONSOURCE="$COMMONDIR/$COMMONSOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +COMMONDIR="$( cd -P "$( dirname "$COMMONSOURCE" )" && pwd )" + # Detect build servers if [[ ! -z "$JENKINS_URL" || ! -z "$BUILD_BUILDID" ]]; then # Jenkins or VSO build, disable colors because they make things gross. @@ -79,6 +87,7 @@ if [ -z "$RID" ]; then fi fi +export REPOROOT=$(cd $COMMONDIR/.. && pwd) export OUTPUT_ROOT=$REPOROOT/artifacts/$RID export DNX_DIR=$OUTPUT_ROOT/dnx export STAGE1_DIR=$OUTPUT_ROOT/stage1 diff --git a/scripts/docker/dockerbuild.sh b/scripts/docker/dockerbuild.sh index 85b802357..423231eb3 100755 --- a/scripts/docker/dockerbuild.sh +++ b/scripts/docker/dockerbuild.sh @@ -4,6 +4,8 @@ # Licensed under the MIT license. See LICENSE file in the project root for full license information. # +set -e + SOURCE="${BASH_SOURCE[0]}" while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" diff --git a/scripts/package/package-debian.sh b/scripts/package/package-debian.sh index 2995b1ee3..7aa9a5959 100755 --- a/scripts/package/package-debian.sh +++ b/scripts/package/package-debian.sh @@ -6,6 +6,8 @@ # Debian Packaging Script # Currently Intended to build on ubuntu14.04 +set -e + SOURCE="${BASH_SOURCE[0]}" while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" @@ -21,21 +23,25 @@ if [ "$UNAME" != "Linux" ]; then exit 1 fi -REPO_ROOT=$(readlink -f $DIR/../..) -PACKAGING_ROOT=$REPO_ROOT/packaging/debian +PACKAGING_ROOT=$REPOROOT/packaging/debian -OUTPUT_DIR="$REPO_ROOT/artifacts" +OUTPUT_DIR="$REPOROOT/artifacts" PACKAGE_LAYOUT_DIR="$OUTPUT_DIR/deb_intermediate" PACKAGE_OUTPUT_DIR="$OUTPUT_DIR/packages/debian" -REPO_BINARIES_DIR="$REPO_ROOT/artifacts/ubuntu.14.04-x64/stage2" +TEST_STAGE_DIR="$PACKAGE_OUTPUT_DIR/test" +REPO_BINARIES_DIR="$REPOROOT/artifacts/ubuntu.14.04-x64/stage2" -execute(){ +execute_build(){ create_empty_debian_layout copy_files_to_debian_layout create_debian_package test_debian_package } +execute_test(){ + test_debian_package +} + create_empty_debian_layout(){ header "Creating empty debian package layout" @@ -69,15 +75,30 @@ create_debian_package(){ test_debian_package(){ header "Testing debian package" - git clone https://github.com/sstephenson/bats.git /tmp/bats - pushd /tmp/bats - ./install.sh /usr/local - popd + git clone https://github.com/sstephenson/bats.git $TEST_STAGE_DIR + + $TEST_STAGE_DIR/bin/bats $PACKAGE_OUTPUT_DIR/test_package.bats - bats $PACKAGE_OUTPUT_DIR/test_package.bats + # E2E Testing of package surface area + run_e2e_test } -execute +run_e2e_test(){ + set +e + sudo dpkg -i $DEBIAN_FILE + $REPOROOT/scripts/test/e2e-test.sh + result=$? + sudo dpkg -r dotnet + set -e + + return result +} + +execute_build DEBIAN_FILE=$(find $PACKAGE_OUTPUT_DIR -iname "*.deb") -$DIR/../publish/publish.sh $DEBIAN_FILE + +execute_test + +# Publish +$REPOROOT/scripts/publish/publish.sh $DEBIAN_FILE diff --git a/scripts/package/package.sh b/scripts/package/package.sh index cf006ae34..fb703ab12 100755 --- a/scripts/package/package.sh +++ b/scripts/package/package.sh @@ -4,6 +4,8 @@ # Licensed under the MIT license. See LICENSE file in the project root for full license information. # +set -e + SOURCE="${BASH_SOURCE[0]}" while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" diff --git a/scripts/test/e2e-test.sh b/scripts/test/e2e-test.sh index b5dc8d295..51eadf190 100755 --- a/scripts/test/e2e-test.sh +++ b/scripts/test/e2e-test.sh @@ -13,7 +13,6 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located done DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" -REPOROOT="$( cd -P "$DIR/../.." && pwd )" source "$DIR/../_common.sh"