Improved OSS flow and lint reporting

Summary:- lint bot is now managed by Circle CI
- checked that flow and lint errors are caught both by bot and CI
- flow fix for npm 3
- Travis is now using npm 2 and Circle CI npm 3
- Refactored Travis script to be able to be able to fail on multiple lines
Closes https://github.com/facebook/react-native/pull/6508

Differential Revision: D3069500

Pulled By: davidaurelio

fb-gh-sync-id: 02772bf1eae5f2c44489c2e3a01899428a9640cb
shipit-source-id: 02772bf1eae5f2c44489c2e3a01899428a9640cb
This commit is contained in:
Konstantin Raev 2016-03-18 08:09:20 -07:00 committed by Facebook Github Bot 8
parent 31c9a2f003
commit 84183ffc30
9 changed files with 92 additions and 89 deletions

View File

@ -56,6 +56,8 @@
.*/node_modules/binary-extensions/binary-extensions.json
.*/node_modules/url-regex/tlds.json
.*/node_modules/joi/.*\.json
.*/node_modules/isemail/.*\.json
.*/node_modules/tr46/.*\.json
.*/build/.*\.json
.*/\.buckd/.*

View File

@ -7,45 +7,20 @@ install:
- mkdir -p .nvm
- export NVM_DIR="$PWD/.nvm"
- source $(brew --prefix nvm)/nvm.sh
- nvm install 5
# testing with npm@2 for diversity, Circle tests with npm@3
- nvm install 4.4.0
- rm -Rf "${TMPDIR}/jest_preprocess_cache"
- npm config set spin=false
- npm config set progress=false
- npm install
script:
- |
if [ "$TEST_TYPE" = objc ]
then
travis_retry ./scripts/objc-test.sh
elif [ "$TEST_TYPE" = js ]
then
npm install github@0.2.4
cat <(echo eslint; npm run lint --silent -- --format=json; echo flow; npm run flow --silent -- --json) | GITHUB_TOKEN="af6ef0d15709bc91d""06a6217a5a826a226fb57b7" node bots/code-analysis-bot.js
npm run flow && npm test
# testing js e2e with npm3
npm install -g npm@3
npm --version
./scripts/e2e-test.sh --packager
# testing js e2e with npm2
rm -rf node_modules
npm install -g npm@2
npm install
npm --version
./scripts/e2e-test.sh --packager
elif [ "$TEST_TYPE" = e2e-objc ]
then
travis_retry ./scripts/e2e-test.sh --ios
else
echo "Unknown test type: $TEST_TYPE"
exit 1
fi
- if [[ "$TEST_TYPE" = objc ]]; then travis_retry ./scripts/objc-test.sh; fi
- if [[ "$TEST_TYPE" = e2e-objc ]]; then travis_retry ./scripts/e2e-test.sh --ios; fi
# temporarily disable flow check because it went mad on Travis
# - if [[ "$TEST_TYPE" = js ]]; then npm run flow check; fi
- if [[ "$TEST_TYPE" = js ]]; then npm test -- --maxWorkers=1; fi
- if [[ "$TEST_TYPE" = js ]]; then ./scripts/e2e-test.sh --packager; fi
env:
matrix:

View File

@ -8,16 +8,20 @@
*/
'use strict';
if (!process.env.TRAVIS_REPO_SLUG) {
console.error('Missing TRAVIS_REPO_SLUG. Example: facebook/react-native');
if (!process.env.CI_USER) {
console.error('Missing CI_USER. Example: facebook');
process.exit(1);
}
if (!process.env.CI_REPO) {
console.error('Missing CI_REPO. Example: react-native');
process.exit(1);
}
if (!process.env.GITHUB_TOKEN) {
console.error('Missing GITHUB_TOKEN. Example: 5fd88b964fa214c4be2b144dc5af5d486a2f8c1e');
process.exit(1);
}
if (!process.env.TRAVIS_PULL_REQUEST) {
console.error('Missing TRAVIS_PULL_REQUEST. Example: 4687');
if (!process.env.PULL_REQUEST_NUMBER) {
console.error('Missing PULL_REQUEST_NUMBER. Example: 4687');
process.exit(1);
}
@ -231,12 +235,10 @@ process.stdin.on('end', function() {
delete messages[absolutePath];
}
// TRAVIS_REPO_SLUG // 'facebook/react-native'
var user_repo = process.env.TRAVIS_REPO_SLUG.split('/');
var user = user_repo[0];
var repo = user_repo[1];
var number = process.env.TRAVIS_PULL_REQUEST;
var user = process.env.CI_USER;
var repo = process.env.CI_REPO;
var number = process.env.PULL_REQUEST_NUMBER;
// intentional lint warning to make sure that the bot is working :)
main(messages, user, repo, number)
main(messages, user, repo, number);
});

View File

@ -6,37 +6,40 @@ machine:
node:
version: 5.6.0
environment:
PATH: "~/$CIRCLE_PROJECT_REPONAME/gradle-2.9/bin:$PATH"
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"'
dependencies:
pre:
# BUCK
- if [[ ! -e buck ]]; then git clone https://github.com/facebook/buck.git; fi
- cd buck && ant
- buck/bin/buck --version
- buck/bin/buck fetch ReactAndroid/src/test/java/com/facebook/react/modules
- buck/bin/buck fetch ReactAndroid/src/main/java/com/facebook/react
- buck/bin/buck fetch ReactAndroid/src/main/java/com/facebook/react/shell
- buck/bin/buck fetch ReactAndroid/src/test/...
- buck/bin/buck fetch ReactAndroid/src/androidTest/...
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
- 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/...
- source scripts/circle-ci-android-setup.sh && getAndroidSDK
- ./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion :ReactAndroid:downloadFolly :ReactAndroid:downloadGlog
cache_directories:
- "ReactAndroid/build/downloads"
- "buck"
- "buck-out/bin"
- "website/node_modules"
override:
# 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
# for deployment scripts
- npm install shelljs@0.6.0
- cd website && npm install
cache_directories:
- "ReactAndroid/build/downloads"
- "/home/ubuntu/buck"
- "website/node_modules"
- "node_modules"
test:
pre:
@ -46,12 +49,18 @@ test:
- source scripts/circle-ci-android-setup.sh && waitForAVD
override:
# eslint bot
- 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
# JS tests for dependencies installed with npm3
- npm run flow check
- npm test -- --maxWorkers=1
# build app
- buck/bin/buck build ReactAndroid/src/main/java/com/facebook/react
- buck/bin/buck build ReactAndroid/src/main/java/com/facebook/react/shell
- buck build ReactAndroid/src/main/java/com/facebook/react
- buck build ReactAndroid/src/main/java/com/facebook/react/shell
# unit tests
- buck/bin/buck test ReactAndroid/src/test/... --config build.threads=1
- buck test ReactAndroid/src/test/... --config build.threads=1
# instrumentation tests
# compile native libs with Gradle script
@ -60,7 +69,7 @@ test:
# build JS bundle for instrumentation tests
- node local-cli/cli.js bundle --platform android --dev true --entry-file ReactAndroid/src/androidTest/assets/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
# build test APK
- buck/bin/buck install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=1
- buck install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=1
# run installed apk with tests
- source scripts/circle-ci-android-setup.sh && retry3 ./scripts/run-android-instrumentation-tests.sh com.facebook.react.tests

View File

@ -185,7 +185,6 @@
"flow-bin": "0.22.0",
"jest-cli": "0.9.2",
"portfinder": "0.4.0",
"react": "^0.14.5",
"shelljs": "^0.6.0"
"react": "^0.14.5"
}
}

View File

@ -1,9 +1,15 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
jest
.dontMock('node-haste/lib/lib/getPlatformExtension')
.dontMock('node-haste/node_modules/throat')
.dontMock('../');
jest.autoMockOff();
jest
.mock('crypto')

View File

@ -8,15 +8,24 @@
*/
'use strict';
jest.autoMockOff();
jest
.setMock('worker-farm', () => () => undefined)
.dontMock('node-haste/node_modules/throat')
.dontMock('lodash')
.dontMock('../../lib/ModuleTransport')
.setMock('uglify-js')
.dontMock('../');
jest.mock('fs');
.mock('image-size')
.mock('fs')
.mock('assert')
.mock('progress')
.mock('node-haste')
.mock('../../JSTransformer')
.mock('../../lib/declareOpts')
.mock('../../Resolver')
.mock('../Bundle')
.mock('../PrepackBundle')
.mock('../HMRBundle')
.mock('../../Activity')
.mock('../../lib/declareOpts');
var Bundler = require('../');
var Resolver = require('../../Resolver');

View File

@ -8,22 +8,22 @@
*/
'use strict';
jest.autoMockOff();
jest.setMock('worker-farm', function() { return () => {}; })
.dontMock('node-haste/node_modules/throat')
.dontMock('os')
.dontMock('lodash')
.dontMock('path')
.dontMock('url')
.setMock('timers', { setImmediate: (fn) => setTimeout(fn, 0) })
.setMock('uglify-js')
.dontMock('../')
.setMock('crypto');
.setMock('crypto')
.mock('../../Bundler')
.mock('../../AssetServer')
.mock('../../lib/declareOpts')
.mock('node-haste')
.mock('../../Activity');
const Promise = require('promise');
var Bundler = require('../../Bundler');
var Server = require('../');
var Server = require('../../Server');
var AssetServer = require('../../AssetServer');
var FileWatcher;
@ -108,7 +108,7 @@ describe('processRequest', () => {
requestHandler,
'mybundle.bundle?runModule=true'
).then(response => {
expect(response.getHeader('ETag')).toBeDefined()
expect(response.getHeader('ETag')).toBeDefined();
});
});
@ -118,7 +118,7 @@ describe('processRequest', () => {
'mybundle.bundle?runModule=true',
{ headers : { 'if-none-match' : 'this is an etag' } }
).then(response => {
expect(response.statusCode).toEqual(304)
expect(response.statusCode).toEqual(304);
});
});
@ -262,7 +262,7 @@ describe('processRequest', () => {
Bundler.prototype.bundle = bundleFunc;
const server = new Server(options);
server = new Server(options);
server.setHMRFileChangeListener(() => {});
requestHandler = server.processRequest.bind(server);

View File

@ -8,11 +8,12 @@
*/
'use strict';
jest.autoMockOff();
jest.setMock('uglify-js')
.mock('net')
.mock('fs')
.dontMock('node-haste/node_modules/throat')
.dontMock('../SocketServer');
.mock('bser')
.mock('../../Server');
var PackagerServer = require('../../Server');
var SocketServer = require('../SocketServer');