diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..2dbdaa125 --- /dev/null +++ b/.circleci/config.yml @@ -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} + - {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}}}} diff --git a/Podfile b/Podfile index dfb2350e8..0a8214909 100644 --- a/Podfile +++ b/Podfile @@ -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' diff --git a/build-new.sh b/build-new.sh new file mode 100755 index 000000000..5d4739675 --- /dev/null +++ b/build-new.sh @@ -0,0 +1,189 @@ +#!/bin/bash + +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'."