react-native/circle.yml

114 lines
5.2 KiB
YAML
Raw Normal View History

general:
branches:
ignore:
- gh-pages # list of branches to ignore
machine:
node:
version: 6.2.0
environment:
PATH: "~/$CIRCLE_PROJECT_REPONAME/gradle-2.9/bin:/home/ubuntu/buck/bin:$PATH"
TERM: "dumb"
ADB_INSTALL_TIMEOUT: 10
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx512m -XX:+HeapDumpOnOutOfMemoryError"'
java:
version: 'oraclejdk8'
dependencies:
override:
# BUCK and android
- if [[ ! -e /home/ubuntu/buck ]]; then git clone https://github.com/facebook/buck.git /home/ubuntu/buck; fi
- cd /home/ubuntu/buck && ant
- buck --version
- source scripts/circle-ci-android-setup.sh && getAndroidSDK
- buck fetch ReactAndroid/src/test/java/com/facebook/react/modules
- buck fetch ReactAndroid/src/main/java/com/facebook/react
- buck fetch ReactAndroid/src/main/java/com/facebook/react/shell
- buck fetch ReactAndroid/src/test/...
- buck fetch ReactAndroid/src/androidTest/...
- ./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion :ReactAndroid:downloadFolly :ReactAndroid:downloadGlog :ReactAndroid:downloadJSCHeaders
# CIRCLE_NPM_TOKEN is in React Native project settings in Circle CI.
# It was generated for bestander user, easy to replace with anyone's else
- echo "//registry.npmjs.org/:_authToken=${CIRCLE_NPM_TOKEN}" > ~/.npmrc
- npm config set spin=false
- npm config set progress=false
- npm install
# for eslint bot
- npm install github@0.2.4
- cd website && npm install
cache_directories:
- "ReactAndroid/build/downloads"
- "/home/ubuntu/buck"
- "website/node_modules"
- "node_modules"
test:
pre:
# starting emulator in advance because it takes very long to boot
- $ANDROID_HOME/tools/emulator -avd testAVD -no-skin -no-audio -no-window:
background: true
- source scripts/circle-ci-android-setup.sh && waitForAVD
override:
# eslint bot. This GitHub token grants public_repo access scope.
- 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
- npm run lint
# JS tests for dependencies installed with npm3
- npm run flow -- check
- npm test -- --maxWorkers=1
# build app
- buck build ReactAndroid/src/main/java/com/facebook/react
- buck build ReactAndroid/src/main/java/com/facebook/react/shell
# compile native libs with Gradle script, we need bridge for unit and
# integration tests
- ./gradlew :ReactAndroid:packageReactNdkLibsForBuck -Pjobs=1 -Pcom.android.build.threadPoolSize=1:
timeout: 360
# unit tests
- buck test ReactAndroid/src/test/... --config build.threads=1
# integration tests
# build JS bundle for instrumentation tests
Add --maxWorkers flag and allow transformers to run in-band. Summary: This diff cleans up some cruft and adds some features: * It removes the usage of an env variable to control workers. * It removes the lazy and handwavy calculation on how many workers to use for jest-haste-map. Jest itself uses the maximum amount of workers available and it has never been reported as an issue – especially since it is a one-time startup cost of about 3 seconds on a cold cache only. * It adds a `--max-workers` flag to replace the env variable. This one is able to control both the number of workers for `jest-haste-map` as well as the transformers. * It makes the transformers run in the parent process if 1 or fewer workers are are specified. This should help with debugging. Once you approve this diff, I will publish a new version of metro to npm and update the version used in RN and remove the use of the env variable altogether: https://our.intern.facebook.com/intern/biggrep/?corpus=xplat&filename=&case=false&view=default&extre=&s=REACT_NATIVE_MAX_WORKERS&engine=apr_strmatch&context=false&filter[uninteresting]=false&filter[intern]=false&filter[test]=false&grep_regex= Note: the process of adding a CLI option is really broken. Commander also has a weird API. We should consider building a better public API for Metro and then consider how to build a new CLI on top of it and simplify our internal integration. I really don't like how Metro is integrated across pieces of the RN cli in ways that is hard to manage. But that is a larger task for another time :) Reviewed By: jeanlauliac Differential Revision: D5217726 fbshipit-source-id: 74efddbb87755a9e744c816fbc62efa21f6a79bf
2017-06-13 16:11:57 +00:00
- node local-cli/cli.js bundle --max-workers 1 --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
# build test APK
- buck install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=1
# run installed apk with tests
# - node ./scripts/run-android-ci-instrumentation-tests.js --retries 3 --path ./ReactAndroid/src/androidTest/java/com/facebook/react/tests --package com.facebook.react.tests
# Android e2e test
# disabled pending on https://our.intern.facebook.com/intern/tasks?t=16912142
# - source scripts/circle-ci-android-setup.sh && retry3 node ./scripts/run-ci-e2e-tests.js --android --js --retries 2
# testing docs generation
- cd website && npm test
- cd website && node ./server/generate.js
Deploy the website even if other tests fail Summary: Circle only runs the commands under "deployment" if all tests pass. As a result, website deploys tend to get blocked unnecessarily when Circle is red, even when the website has no issues. As every command under "overrride" is run independently even if other commands fail, the result of this PR is that the website will be deployed on every Circle run on `master` or any of the `-stable` branches. Note that the "deployment" section is only executed when Circle is run against the master/-stable branch, and Circle is configured to not run deployments on forks. Since "override" does not have these protections in place, I've added some guards to ensure that a web deploy only occurs on runs triggered by commits to master/-stable on the main `facebook/react-native` repo. This PR assumes the following are correct: - `CI_PULL_REQUEST` and `CIRCLE_PR_USERNAME` are only set when [run on a fork](https://circleci.com/docs/1.0/environment-variables/#building-pull-requests-that-come-from-forks). - `CIRCLE_PROJECT_USERNAME ` is only set to "facebook" when the run is triggered by a commit on the main `facebook/react-native` repo, and not a fork. * Configuring circle.yml: https://circleci.com/docs/1.0/configuration/ * Environment Variables: https://circleci.com/docs/1.0/environment-variables/ None, aside from checking that bash can handle these conditionals. We need to trial this on Circle. Great attention needs to be paid to the conditionals, to ensure we do not allow forks to deploy the official website. We also need to make sure we are not leaking the GitHub access token accidentally. Closes https://github.com/facebook/react-native/pull/14310 Differential Revision: D5179748 Pulled By: hramos fbshipit-source-id: 405963f7e3bf2c1969e3e9a282781ce72c04e2d7
2017-06-03 21:01:42 +00:00
# if website can be built, deploy regardless of test failures
- if [[ ($CIRCLE_BRANCH =~ .*-stable || $CIRCLE_BRANCH == "master") && $CIRCLE_PROJECT_USERNAME == "facebook" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then git config --global user.email "reactjs-bot@users.noreply.github.com" && git config --global user.name "Website Deployment Script" && echo "machine github.com login reactjs-bot password $GITHUB_TOKEN" > ~/.netrc && cd website && GIT_USER=reactjs-bot npm run gh-pages; fi
post:
# copy test report for Circle CI to display
- mkdir -p $CIRCLE_TEST_REPORTS/junit/
- find . -type f -regex ".*/build/test-results/debug/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
- find . -type f -regex ".*/outputs/androidTest-results/connected/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
# 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 {} $CIRCLE_TEST_REPORTS/junit/ \;
deployment:
stable:
branch: [/.*-stable/, /master/]
Deploy the website even if other tests fail Summary: Circle only runs the commands under "deployment" if all tests pass. As a result, website deploys tend to get blocked unnecessarily when Circle is red, even when the website has no issues. As every command under "overrride" is run independently even if other commands fail, the result of this PR is that the website will be deployed on every Circle run on `master` or any of the `-stable` branches. Note that the "deployment" section is only executed when Circle is run against the master/-stable branch, and Circle is configured to not run deployments on forks. Since "override" does not have these protections in place, I've added some guards to ensure that a web deploy only occurs on runs triggered by commits to master/-stable on the main `facebook/react-native` repo. This PR assumes the following are correct: - `CI_PULL_REQUEST` and `CIRCLE_PR_USERNAME` are only set when [run on a fork](https://circleci.com/docs/1.0/environment-variables/#building-pull-requests-that-come-from-forks). - `CIRCLE_PROJECT_USERNAME ` is only set to "facebook" when the run is triggered by a commit on the main `facebook/react-native` repo, and not a fork. * Configuring circle.yml: https://circleci.com/docs/1.0/configuration/ * Environment Variables: https://circleci.com/docs/1.0/environment-variables/ None, aside from checking that bash can handle these conditionals. We need to trial this on Circle. Great attention needs to be paid to the conditionals, to ensure we do not allow forks to deploy the official website. We also need to make sure we are not leaking the GitHub access token accidentally. Closes https://github.com/facebook/react-native/pull/14310 Differential Revision: D5179748 Pulled By: hramos fbshipit-source-id: 405963f7e3bf2c1969e3e9a282781ce72c04e2d7
2017-06-03 21:01:42 +00:00
owner: facebook
commands:
- git config --global user.email "reactjs-bot@users.noreply.github.com"
- git config --global user.name "Website Deployment Script"
- echo "machine github.com login reactjs-bot password $GITHUB_TOKEN" > ~/.netrc
Deploy the website even if other tests fail Summary: Circle only runs the commands under "deployment" if all tests pass. As a result, website deploys tend to get blocked unnecessarily when Circle is red, even when the website has no issues. As every command under "overrride" is run independently even if other commands fail, the result of this PR is that the website will be deployed on every Circle run on `master` or any of the `-stable` branches. Note that the "deployment" section is only executed when Circle is run against the master/-stable branch, and Circle is configured to not run deployments on forks. Since "override" does not have these protections in place, I've added some guards to ensure that a web deploy only occurs on runs triggered by commits to master/-stable on the main `facebook/react-native` repo. This PR assumes the following are correct: - `CI_PULL_REQUEST` and `CIRCLE_PR_USERNAME` are only set when [run on a fork](https://circleci.com/docs/1.0/environment-variables/#building-pull-requests-that-come-from-forks). - `CIRCLE_PROJECT_USERNAME ` is only set to "facebook" when the run is triggered by a commit on the main `facebook/react-native` repo, and not a fork. * Configuring circle.yml: https://circleci.com/docs/1.0/configuration/ * Environment Variables: https://circleci.com/docs/1.0/environment-variables/ None, aside from checking that bash can handle these conditionals. We need to trial this on Circle. Great attention needs to be paid to the conditionals, to ensure we do not allow forks to deploy the official website. We also need to make sure we are not leaking the GitHub access token accidentally. Closes https://github.com/facebook/react-native/pull/14310 Differential Revision: D5179748 Pulled By: hramos fbshipit-source-id: 405963f7e3bf2c1969e3e9a282781ce72c04e2d7
2017-06-03 21:01:42 +00:00
# publish to npm
- node ./scripts/publish-npm.js
experimental:
notify:
branches:
only:
- master
- /.*-stable/