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

Migrate Travis over to Circle #16354

Closed
wants to merge 15 commits into from
198 changes: 138 additions & 60 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,42 @@
aliases:
- &restore-cache
- &restore-node-cache
keys:
- v1-dependencies-{{ .Branch }}-{{ checksum "package.json" }}
- v1-dependencies-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }}
# Fallback in case checksum fails
- v1-dependencies-{{ .Branch }}-
- &save-cache
- v1-dependencies-{{ arch }}-{{ .Branch }}-

- &save-node-cache
paths:
- node_modules
key: v1-dependencies-{{ .Branch }}-{{ checksum "package.json" }}
key: v1-dependencies-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }}

- &restore-cache-website
keys:
- v1-website-dependencies-{{ .Branch }}-{{ checksum "website/package.json" }}
- v1-website-dependencies-{{ arch }}-{{ .Branch }}-{{ checksum "website/package.json" }}
# Fallback in case checksum fails
- v1-website-dependencies-{{ .Branch }}-
- v1-website-dependencies-{{ arch }}-{{ .Branch }}-

- &save-cache-website
paths:
- website/node_modules
key: v1-website-dependencies-{{ .Branch }}-{{ checksum "website/package.json" }}
key: v1-website-dependencies-{{ arch }}-{{ .Branch }}-{{ checksum "website/package.json" }}

- &restore-cache-danger
keys:
- v1-danger-dependencies-{{ .Branch }}-{{ checksum "danger/package.json" }}
- v1-danger-dependencies-{{ arch }}-{{ .Branch }}-{{ checksum "danger/package.json" }}
# Fallback in case checksum fails
- v1-danger-dependencies-{{ .Branch }}-
- v1-danger-dependencies-{{ arch }}-{{ .Branch }}-

- &save-cache-danger
paths:
- danger/node_modules
key: v1-danger-dependencies-{{ .Branch }}-{{ checksum "danger/package.json" }}
key: v1-danger-dependencies-{{ arch }}-{{ .Branch }}-{{ checksum "danger/package.json" }}

- &restore-cache-android-packages
keys:
- v1-android-sdkmanager-packages-{{ checksum "scripts/circle-ci-android-setup.sh" }}
- v1-android-sdkmanager-packages-{{ arch }}-{{ checksum "scripts/circle-ci-android-setup.sh" }}
# Fallback in case checksum fails
- v1-android-sdkmanager-packages-
- v1-android-sdkmanager-packages-{{ arch }}-
- &save-cache-android-packages
paths:
- /opt/android/sdk/system-images/android-23
Expand All @@ -43,92 +46,151 @@ aliases:
- /opt/android/sdk/platforms/android-19
- /opt/android/sdk/build-tools/23.0.1
- /opt/android/sdk/add-ons/addon-google_apis-google-23
key: v1-android-sdkmanager-packages-{{ checksum "scripts/circle-ci-android-setup.sh" }}
key: v1-android-sdkmanager-packages-{{ arch }}-{{ checksum "scripts/circle-ci-android-setup.sh" }}

- &restore-cache-ndk
keys:
- v1-android-ndk-r10e-32-64
- v1-android-ndk-{{ arch }}-r10e-32-64

- &save-cache-ndk
paths:
- /opt/ndk
key: v1-android-ndk-r10e-32-64
key: v1-android-ndk-{{ arch }}-r10e-32-64

- &restore-cache-buck-downloads
keys:
- v1-buck-downloads-{{ .Branch }}-{{ checksum "ReactAndroid/build.gradle" }}
- v1-buck-downloads-{{ arch }}-{{ .Branch }}-{{ checksum "ReactAndroid/build.gradle" }}
# Fallback in case checksum fails
- v1-buck-downloads-{{ .Branch }}-
- v1-buck-downloads-{{ arch }}-{{ .Branch }}-
- &save-cache-buck-downloads
paths:
- "ReactAndroid/build/downloads"
key: v1-buck-downloads-{{ .Branch }}-{{ checksum "ReactAndroid/build.gradle" }}
key: v1-buck-downloads-{{ arch }}-{{ .Branch }}-{{ checksum "ReactAndroid/build.gradle" }}

- &restore-cache-buck
keys:
- v1-buck-v2017.09.04.02
- v1-buck-{{ arch }}-v2017.09.04.02
- &save-cache-buck
paths:
- ~/buck
key: v1-buck-v2017.09.04.02
key: v1-buck-{{ arch }}-v2017.09.04.02

- &restore-cache-watchman
keys:
- v1-watchman-v4.9.0
- v1-watchman-{{ arch }}-v4.9.0
- &save-cache-watchman
paths:
- ~/watchman
key: v1-watchman-v4.9.0
key: v1-watchman-{{ arch }}-v4.9.0

- &install-node-dependencies
|
npm install --no-package-lock --no-spin --no-progress

- &run-node-tests
|
npm test -- --maxWorkers=2
npm run lint
npm run flow -- check

defaults: &defaults
working_directory: ~/react-native

version: 2
jobs:
test-node-8:

# Runs unit tests on Node 8
test-js-node-8:
<<: *defaults
docker:
- image: circleci/node:8
steps:
- checkout
- run: npm install --no-package-lock
- run: |
npm test -- --maxWorkers=2
npm run lint
npm run flow -- check
# eslint - doesn't run on non-PR builds
- run:
name: Analyze Code
command: |
if [ -n "$CIRCLE_PR_NUMBER" ]; then
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is re-added in @hramos PR as a separate job.

npm install github@0.2.4
cat <(echo eslint; npm run lint --silent -- --format=json; echo flow; npm run flow --silent -- check --json) | GITHUB_TOKEN="af6ef0d15709bc91d""06a6217a5a826a226fb57b7" CI_USER=$CIRCLE_PROJECT_USERNAME CI_REPO=$CIRCLE_PROJECT_REPONAME PULL_REQUEST_NUMBER=$CIRCLE_PR_NUMBER node bots/code-analysis-bot.js
else
echo "Skipping code analysis."
fi
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run: *run-node-tests

test-node-6:
# Runs unit tests on Node 6
test-js-node-6:
<<: *defaults
docker:
- image: circleci/node:6.11.0
steps:
- checkout
- run: npm install
- run: |
npm test -- --maxWorkers=2
npm run lint
npm run flow -- check
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
Copy link
Contributor

Choose a reason for hiding this comment

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

--no-package-lock is new to npm@5, which is not used in the Node 6 and Node 4 tests. It's why I initially didn't set up a npm install alias to use everywhere. I do think it's alright to use it here, because earlier npm versions will silently ignore the flag.

- save-cache: *save-node-cache
- run: *run-node-tests

test-node-4:
# Runs unit tests on Node 4
test-js-node-4:
<<: *defaults
docker:
- image: circleci/node:4.8.4
steps:
- checkout
- run: npm install
- run: |
npm test -- --maxWorkers=2
npm run lint
npm run flow -- check
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run: *run-node-tests

# Runs unit tests on iOS devices
test-objc-ios:
<<: *defaults
macos:
xcode: "9.0"
dependencies:
pre:
- xcrun instruments -w "iPhone 5s (10.3.1)" || true
Copy link
Contributor

Choose a reason for hiding this comment

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

We can do this separately from this PR, but at some point we should switch over to iOS 11.0 here, and tvOS 11.0 in test-objc-tvos. This would match what we're testing internally.

steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run: ./scripts/objc-test-ios.sh

# Runs unit tests on tvOS devices
test-objc-tvos:
<<: *defaults
macos:
xcode: "9.0"
dependencies:
pre:
- xcrun instruments -w "Apple TV 1080p (10.0)" || true
steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run: ./scripts/objc-test-tvos.sh

# Runs end to end tests
test-objc-e2e:
<<: *defaults
macos:
xcode: "9.0"
dependencies:
pre:
- xcrun instruments -w "iPhone 5s (10.3.1)" || true
steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run: node ./scripts/run-ci-e2e-tests.js --ios --js --retries 3;

# Checks podspec
test-podspec:
<<: *defaults
macos:
xcode: "9.0"
steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run: ./scripts/process-podspecs.sh

test-website:
<<: *defaults
Expand Down Expand Up @@ -181,7 +243,9 @@ jobs:
- image: circleci/node:8
steps:
- checkout
- run: npm install --no-package-lock
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run:
name: Build JavaScript Bundle
command: node local-cli/cli.js bundle --max-workers 2 --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
Expand Down Expand Up @@ -258,7 +322,10 @@ jobs:
command: |
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
- run: npm install
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
# TODO: Install and use watchman to speed up builds
# - restore-cache: *restore-cache-watchman
# - run:
# name: Install Watchman Dependencies
Expand Down Expand Up @@ -322,11 +389,11 @@ jobs:
- run:
name: Build and Install Test APK
command: source scripts/circle-ci-android-setup.sh && NO_BUCKD=1 retry3 buck install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=$BUILD_THREADS
# Failing test is expected
# TODO: Uncomment, test was already failing on Circle 1.0
# - run:
# name: Run Installed APK with Tests
# command: node ./scripts/run-android-ci-instrumentation-tests.js --retries 3 --path ./ReactAndroid/src/androidTest/java/com/facebook/react/tests --package com.facebook.react.tests
# Should be disabled pending on https://our.intern.facebook.com/intern/tasks?t=16912142
# TODO: Should be disabled, pending on https://our.intern.facebook.com/intern/tasks?t=16912142
# - run:
# name: Run Android End to End Tests
# command: source scripts/circle-ci-android-setup.sh && retry3 node ./scripts/run-ci-e2e-tests.js --android --js --retries 2
Expand All @@ -338,7 +405,7 @@ jobs:
mkdir -p ~/junit/
find . -type f -regex ".*/build/test-results/debug/.*xml" -exec cp {} ~/junit/ \;
find . -type f -regex ".*/outputs/androidTest-results/connected/.*xml" -exec cp {} ~/junit/ \;
# TODO circle does not understand Buck's report, maybe need to transform xml slightly
# TODO: Circle does not understand Buck's report, maybe need to transform xml slightly
# find . -type f -regex ".*/buck-out/gen/ReactAndroid/src/test/.*/.*xml" -exec cp {} ~/junit/ \;
when: always
- store_test_results:
Expand All @@ -349,12 +416,14 @@ jobs:
# Workflows enables us to run multiple jobs in parallel
workflows:
version: 2

test_node:
jobs:
- test-node-8
- test-node-6
# Node 4 tests are already failing on Circle 1.0
# - test-node-4
- test-js-node-8
- test-js-node-6
# TODO: Node 4 tests are already failing on Circle 1.0
# - test-js-node-4

website:
jobs:
- test-website
Expand All @@ -366,6 +435,7 @@ workflows:
only:
- /.*-stable/
- master

test_android:
jobs:
- build-js-bundle:
Expand All @@ -375,3 +445,11 @@ workflows:
- test-android:
requires:
- build-js-bundle

test_ios:
jobs:
- test-objc-ios
- test-objc-tvos
# TODO: Podspec tests are already failing on Travis
# - test-podspec
- test-objc-e2e
49 changes: 0 additions & 49 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/run-ci-e2e-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ try {
if (argv.tvos) {
return exec('xcodebuild -destination "platform=tvOS Simulator,name=Apple TV 1080p,OS=10.0" -scheme EndToEndTest-tvOS -sdk appletvsimulator test | xcpretty && exit ${PIPESTATUS[0]}').code;
} else {
return exec('xcodebuild -destination "platform=iOS Simulator,name=iPhone 5s,OS=10.0" -scheme EndToEndTest -sdk iphonesimulator test | xcpretty && exit ${PIPESTATUS[0]}').code;
return exec('xcodebuild -destination "platform=iOS Simulator,name=iPhone 5s,OS=10.3.1" -scheme EndToEndTest -sdk iphonesimulator test | xcpretty && exit ${PIPESTATUS[0]}').code;
}
},
numberOfRetries)) {
Expand Down