Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up CircleCI #1210

Closed
wants to merge 18 commits into from
Closed
69 changes: 69 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
version: 2.1
executors:
texture_exec:
macos:
xcode: 10.1.0
# working_directory: ~/project
commands:
buildsh:
parameters:
mode: {type: string}
steps:
# - {attach_workspace: {at: ~/project}}
- checkout
- {run: {name: 'Fetch cocoapods spec repo from cache', command: "curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf\n"}}
- {run: xcrun simctl list}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't, the simulator engine sometimes barfs when it comes time to run

- {run: './build-new.sh << parameters.mode >>'}
jobs:
fetch_deps:
executor: texture_exec
steps:
- checkout
# - {attach_workspace: {at: ~/project}}
# - {run: {name: 'Fetch cocoapods spec repo from cache', command: "curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf\n"}}
# - {persist_to_workspace: {root: ., paths: .}}
tests:
executor: texture_exec
steps:
- {buildsh: {mode: tests}}
framework:
executor: texture_exec
steps:
- {buildsh: {mode: framework}}
examples-pt1:
executor: texture_exec
steps:
- {buildsh: {mode: examples-pt1}}
examples-pt2:
executor: texture_exec
steps:
- {buildsh: {mode: examples-pt2}}
examples-pt3:
executor: texture_exec
steps:
- {buildsh: {mode: examples-pt3}}
life-without-cocoapods:
executor: texture_exec
steps:
- {buildsh: {mode: life-without-cocoapods}}
cocoapods-lint:
executor: texture_exec
steps:
- {buildsh: {mode: cocoapods-lint}}
carthage:
executor: texture_exec
steps:
- {buildsh: {mode: carthage}}
workflows:
version: 2.1
github_pr_check:
jobs:
- fetch_deps
- {tests: {requires: [fetch_deps]}}
- {framework: {requires: [tests]}}
- {examples-pt1: {requires: [tests]}}
- {examples-pt2: {requires: [tests]}}
- {examples-pt3: {requires: [tests]}}
- {life-without-cocoapods: {requires: [tests]}}
- {carthage: {requires: [tests]}}
- {cocoapods-lint: {requires: [tests], filters: {branches: {only: master}}}}
7 changes: 5 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ platform :ios, '9.0'

target :'AsyncDisplayKitTests' do
pod 'OCMock', '=3.4.1' # 3.4.2 currently has issues.
pod 'FBSnapshotTestCase/Core', '~> 2.1'
pod 'JGMethodSwizzler', :git => 'https://github.com/JonasGessner/JGMethodSwizzler', :branch => 'master'

# TODO Move to Uber iOSSnapshotTestCase
pod 'FBSnapshotTestCase/Core', :git => 'https://github.com/facebookarchive/ios-snapshot-test-case.git', :tag => '2.1.4'

pod 'JGMethodSwizzler', :git => 'https://github.com/JonasGessner/JGMethodSwizzler.git', :branch => 'master'

# Only for buck build
pod 'PINRemoteImage', '3.0.0-beta.13'
Expand Down
189 changes: 189 additions & 0 deletions build-new.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why to create a new .sh file instead of updating the existing one? It would be nice for people to still be able to invoke a build script via command line and not have it diverge over time from the one CI was running. I see the pod install is happening elsewhere now, maybe we can use another ENV var or argument to disable it and then keep just one file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a leftover from the development of the diff. If we want to do this I will replace the old build.sh before landing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No time like the present! Are you anticipating a lag between merging the PR and actually running CI on CircleCI?


PLATFORM="platform=iOS Simulator,OS=10.3.1,name=iPhone 7"
SDK="iphonesimulator12.1"


# It is pitch black.
set -e
function trap_handler {
echo -e "\n\nOh no! You walked directly into the slavering fangs of a lurking grue!"
echo "**** You have died ****"
exit 255
}
trap trap_handler INT TERM EXIT

# Build example
function build_example {
example="$1"

if [ -f "${example}/Podfile" ]; then
echo "Using CocoaPods"
if [ -f "${example}/Podfile.lock" ]; then
rm "$example/Podfile.lock"
fi
rm -rf "$example/Pods"
pod install --project-directory=$example --no-repo-update

set -o pipefail && xcodebuild \
-workspace "${example}/Sample.xcworkspace" \
-scheme Sample \
-sdk "$SDK" \
-destination "$PLATFORM" \
build | xcpretty $FORMATTER
elif [ -f "${example}/Cartfile" ]; then
echo "Using Carthage"
local_repo=`pwd`
current_branch=`git rev-parse --abbrev-ref HEAD`
cd $example

echo "git \"file://${local_repo}\" \"${current_branch}\"" > "Cartfile"
carthage update --platform iOS

set -o pipefail && xcodebuild \
-project "Sample.xcodeproj" \
-scheme Sample \
-sdk "$SDK" \
-destination "$PLATFORM" \
build | xcpretty $FORMATTER

cd ../..
fi
}

MODE="$1"

if type xcpretty-travis-formatter &> /dev/null; then
FORMATTER="-f $(xcpretty-travis-formatter)"
else
FORMATTER="-s"
fi

if [ "$MODE" = "tests" -o "$MODE" = "all" ]; then
echo "Building & testing AsyncDisplayKit."
pod install --no-repo-update
set -o pipefail && xcodebuild \
-workspace AsyncDisplayKit.xcworkspace \
-scheme AsyncDisplayKit \
-sdk "$SDK" \
-destination "$PLATFORM" \
build-for-testing test | xcpretty $FORMATTER
success="1"
fi

if [ "$MODE" = "tests_listkit" ]; then
echo "Building & testing AsyncDisplayKit+IGListKit."
pod install --project-directory=SubspecWorkspaces/ASDKListKit --no-repo-update
set -o pipefail && xcodebuild \
-workspace SubspecWorkspaces/ASDKListKit/ASDKListKit.xcworkspace \
-scheme ASDKListKitTests \
-sdk "$SDK" \
-destination "$PLATFORM" \
build-for-testing test | xcpretty $FORMATTER
success="1"
fi

if [ "$MODE" = "examples" -o "$MODE" = "all" ]; then
echo "Verifying that all AsyncDisplayKit examples compile."

for example in examples/*/; do
echo "Building (examples) $example."

build_example $example
done
success="1"
fi

if [ "$MODE" = "examples-pt1" ]; then
echo "Verifying that all AsyncDisplayKit examples compile."

for example in $((find ./examples -type d -maxdepth 1 \( ! -iname ".*" \)) | head -6 | head); do
echo "Building (examples-pt1) $example."

build_example $example
done
success="1"
fi

if [ "$MODE" = "examples-pt2" ]; then
echo "Verifying that all AsyncDisplayKit examples compile."

for example in $((find ./examples -type d -maxdepth 1 \( ! -iname ".*" \)) | head -12 | tail -6 | head); do
echo "Building $example (examples-pt2)."

build_example $example
done
success="1"
fi

if [ "$MODE" = "examples-pt3" ]; then
echo "Verifying that all AsyncDisplayKit examples compile."
for example in $((find ./examples -type d -maxdepth 1 \( ! -iname ".*" \)) | head -7 | head); do
echo "Building $example (examples-pt3)."

build_example $example
done
success="1"
fi

if [ "$MODE" = "examples-extra" ]; then
echo "Verifying that all AsyncDisplayKit examples compile."
for example in $((find ./examples_extra -type d -maxdepth 1 \( ! -iname ".*" \)) | head -7 | head); do
echo "Building $example (examples-extra)."

build_example $example
done
success="1"
fi

# Support building a specific example: sh build.sh example examples/ASDKLayoutTransition
if [ "$MODE" = "example" ]; then
echo "Verifying that all AsyncDisplayKit examples compile."
build_example $2
success="1"
fi

if [ "$MODE" = "life-without-cocoapods" -o "$MODE" = "all" ]; then
echo "Verifying that AsyncDisplayKit functions as a static library."

set -o pipefail && xcodebuild \
-workspace "smoke-tests/Life Without CocoaPods/Life Without CocoaPods.xcworkspace" \
-scheme "Life Without CocoaPods" \
-sdk "$SDK" \
-destination "$PLATFORM" \
build | xcpretty $FORMATTER
success="1"
fi

if [ "$MODE" = "framework" -o "$MODE" = "all" ]; then
echo "Verifying that AsyncDisplayKit functions as a dynamic framework (for Swift/Carthage users)."

set -o pipefail && xcodebuild \
-project "smoke-tests/Framework/Sample.xcodeproj" \
-scheme Sample \
-sdk "$SDK" \
-destination "$PLATFORM" \
build | xcpretty $FORMATTER
success="1"
fi

if [ "$MODE" = "cocoapods-lint" -o "$MODE" = "all" ]; then
echo "Verifying that podspec lints."

set -o pipefail && pod env && pod lib lint --allow-warnings
success="1"
fi

if [ "$MODE" = "carthage" -o "$MODE" = "all" ]; then
echo "Verifying carthage works."

set -o pipefail && carthage update && carthage build --no-skip-current
success="1"
fi

if [ "$success" = "1" ]; then
trap - EXIT
exit 0
fi

echo "Unrecognised mode '$MODE'."