diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml new file mode 100644 index 000000000..6a5259ecf --- /dev/null +++ b/.buildkite/pipeline.yml @@ -0,0 +1,4 @@ +steps: + - label: 'Tests' + command: "./run_tests_update_status.sh \"${UPDATE_STATUS_PATH}\" \"${BUILDKITE_PULL_REQUEST}\" \"${BUILDKITE_BUILD_URL}\"" + timeout_in_minutes: 30 \ No newline at end of file diff --git a/build.sh b/build.sh index d451bc9ad..8720c66fe 100755 --- a/build.sh +++ b/build.sh @@ -69,7 +69,7 @@ if type xcpretty-travis-formatter &> /dev/null; then FORMATTER="-s" fi -if [ "$MODE" = "tests" ]; then +if [ "$MODE" = "tests" -o "$MODE" = "all" ]; then echo "Building & testing AsyncDisplayKit." pod install set -o pipefail && xcodebuild \ @@ -78,8 +78,7 @@ if [ "$MODE" = "tests" ]; then -sdk "$SDK" \ -destination "$PLATFORM" \ build-for-testing test | xcpretty $FORMATTER - trap - EXIT - exit 0 + success="1" fi if [ "$MODE" = "tests_listkit" ]; then @@ -91,11 +90,10 @@ if [ "$MODE" = "tests_listkit" ]; then -sdk "$SDK" \ -destination "$PLATFORM" \ build-for-testing test | xcpretty $FORMATTER - trap - EXIT - exit 0 + success="1" fi -if [ "$MODE" = "examples" ]; then +if [ "$MODE" = "examples" -o "$MODE" = "all" ]; then echo "Verifying that all AsyncDisplayKit examples compile." #Update cocoapods repo pod repo update master @@ -105,8 +103,7 @@ if [ "$MODE" = "examples" ]; then build_example $example done - trap - EXIT - exit 0 + success="1" fi if [ "$MODE" = "examples-pt1" ]; then @@ -119,8 +116,7 @@ if [ "$MODE" = "examples-pt1" ]; then build_example $example done - trap - EXIT - exit 0 + success="1" fi if [ "$MODE" = "examples-pt2" ]; then @@ -133,8 +129,7 @@ if [ "$MODE" = "examples-pt2" ]; then build_example $example done - trap - EXIT - exit 0 + success="1" fi if [ "$MODE" = "examples-pt3" ]; then @@ -147,8 +142,7 @@ if [ "$MODE" = "examples-pt3" ]; then build_example $example done - trap - EXIT - exit 0 + success="1" fi if [ "$MODE" = "examples-extra" ]; then @@ -161,8 +155,7 @@ if [ "$MODE" = "examples-extra" ]; then build_example $example done - trap - EXIT - exit 0 + success="1" fi # Support building a specific example: sh build.sh example examples/ASDKLayoutTransition @@ -172,11 +165,10 @@ if [ "$MODE" = "example" ]; then pod repo update master build_example $2 - trap - EXIT - exit 0 + success="1" fi -if [ "$MODE" = "life-without-cocoapods" ]; then +if [ "$MODE" = "life-without-cocoapods" -o "$MODE" = "all" ]; then echo "Verifying that AsyncDisplayKit functions as a static library." set -o pipefail && xcodebuild \ @@ -185,11 +177,10 @@ if [ "$MODE" = "life-without-cocoapods" ]; then -sdk "$SDK" \ -destination "$PLATFORM" \ build | xcpretty $FORMATTER - trap - EXIT - exit 0 + success="1" fi -if [ "$MODE" = "framework" ]; then +if [ "$MODE" = "framework" -o "$MODE" = "all" ]; then echo "Verifying that AsyncDisplayKit functions as a dynamic framework (for Swift/Carthage users)." set -o pipefail && xcodebuild \ @@ -198,22 +189,25 @@ if [ "$MODE" = "framework" ]; then -sdk "$SDK" \ -destination "$PLATFORM" \ build | xcpretty $FORMATTER - trap - EXIT - exit 0 + success="1" fi -if [ "$MODE" = "cocoapods-lint" ]; then +if [ "$MODE" = "cocoapods-lint" -o "$MODE" = "all" ]; then echo "Verifying that podspec lints." set -o pipefail && pod env && pod lib lint - trap - EXIT - exit 0 + success="1" fi -if [ "$MODE" = "carthage" ]; then +if [ "$MODE" = "carthage" -o "$MODE" = "all" ]; then echo "Verifying carthage works." set -o pipefail && carthage update && carthage build --no-skip-current fi +if [ "$success" = "1" ]; then + trap - EXIT + exit 0 +fi + echo "Unrecognised mode '$MODE'." diff --git a/run_tests_update_status.sh b/run_tests_update_status.sh new file mode 100755 index 000000000..ac9731d71 --- /dev/null +++ b/run_tests_update_status.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +set -eo pipefail + +UPDATE_STATUS_PATH=$1 +BUILDKITE_PULL_REQUEST=$2 +BUILDKITE_BUILD_URL=$3 + +function updateStatus() { + if [ "${BUILDKITE_PULL_REQUEST}" != "false" ] ; then + ${UPDATE_STATUS_PATH} "TextureGroup" "Texture" ${BUILDKITE_PULL_REQUEST} "$1" ${BUILDKITE_BUILD_URL} "$2" "CI/Pinterest" "$3" + fi +} + +if [[ -z "${UPDATE_STATUS_PATH}" || -z "${BUILDKITE_PULL_REQUEST}" || -z "${BUILDKITE_BUILD_URL}" ]] ; then + echo "Update status path (${UPDATE_STATUS_PATH}), pull request (${BUILDKITE_BUILD_URL}) or build url (${BUILDKITE_PULL_REQUEST}) unset." + trap - EXIT + exit 255 +fi + +trapped="false" +function trap_handler() { + if [[ "$trapped" = "false" ]]; then + updateStatus "failure" "Tests failed…" `pwd`/log.txt + echo "Tests failed, updated status to failure" + rm `pwd`/log.txt + fi + trapped="true" +} +trap trap_handler INT TERM EXIT + +updateStatus "pending" "Starting build…" + +./build.sh all 2>&1|tee `pwd`/log.txt + +rm `pwd`/log.txt + +updateStatus "success" "Tests passed" + +echo "All tests succeeded, updated status to success" +trap - EXIT +exit 0 \ No newline at end of file