Skip to content

Commit

Permalink
Adding buildkite support (#1)
Browse files Browse the repository at this point in the history
* Adding buildkite support

* Update build.sh to support all flag
  • Loading branch information
garrettmoon committed Apr 11, 2017
1 parent ae1e299 commit 1996b57
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 28 deletions.
4 changes: 4 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -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
50 changes: 22 additions & 28 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
Expand All @@ -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
Expand All @@ -105,8 +103,7 @@ if [ "$MODE" = "examples" ]; then

build_example $example
done
trap - EXIT
exit 0
success="1"
fi

if [ "$MODE" = "examples-pt1" ]; then
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 \
Expand All @@ -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 \
Expand All @@ -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'."
41 changes: 41 additions & 0 deletions run_tests_update_status.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1996b57

Please sign in to comment.