Add circle.yml / CircleCI support (#8486)
Tom Occhino committed
Dec 2, 2016 at 14:18 UTC
153fe3840300980da89f80d6b81c779e37668a41
10 files changed
+163
-5
circle.yml
new
+54
@@ -0,0 +1,54 @@
1
+---
2
+general:
3
+ branches:
4
+ ignore:
5
+ - gh-pages
6
+
7
+machine:
8
+ timezone: America/Los_Angeles
9
+ node:
10
+ version: 6
11
+ ruby:
12
+ version: 2.2.3
13
+ environment:
14
+ TRAVIS_REPO_SLUG: facebook/react
15
+
16
+dependencies:
17
+ pre:
18
+ # This is equivalent to $TRAVIS_COMMIT_RANGE
19
+ # Need to figure out how to bail early if this is a "docs only" build
20
+ - echo $CIRCLE_COMPARE_URL | cut -d/ -f7
21
+ # install yarn
22
+ - sudo apt-key adv --fetch-keys http://dl.yarnpkg.com/debian/pubkey.gpg
23
+ - echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
24
+ - sudo apt-get update -qq
25
+ - sudo apt-get install -y -qq yarn
26
+ override:
27
+ - bundle install --gemfile=docs/Gemfile --deployment --path=vendor/bundle --jobs=3 --retry=3
28
+ - yarn install
29
+ - scripts/circleci/set_up_github_keys.sh
30
+ post:
31
+ # - npm ls --depth=0
32
+ cache_directories:
33
+ - docs/vendor/bundle
34
+ - .grunt # Show size comparisons between builds
35
+ - ~/react-gh-pages # docs checkout
36
+ - ~/.yarn-cache
37
+
38
+test:
39
+ override:
40
+ - ./node_modules/.bin/gulp lint
41
+ - ./node_modules/.bin/gulp flow
42
+ - ./scripts/circleci/test_coverage.sh
43
+ - ./scripts/circleci/test_fiber.sh
44
+ - ./scripts/circleci/test_html_generation.sh
45
+ - ./scripts/circleci/track_stats.sh
46
+ - ./node_modules/.bin/grunt build
47
+ - ./node_modules/.bin/gulp react:extract-errors
48
+
49
+deployment:
50
+ staging:
51
+ branch: /.*/
52
+ commands:
53
+ - ./scripts/circleci/upload_build.sh
54
+ - ./scripts/circleci/build_gh_pages.sh
grunt/tasks/jest.js
+1
@@ -8,6 +8,7 @@ function run(done, coverage) {
8
9
var args = [
10
path.join('node_modules', 'jest-cli', 'bin', 'jest'),
11
+ '--runInBand',
12
];
13
if (coverage) {
14
args.push('--coverage');
scripts/circleci/build_gh_pages.sh
new
+33
@@ -0,0 +1,33 @@
1
+#!/bin/bash
2
+
3
+set -e
4
+
5
+if [ -z $CI_PULL_REQUEST ] && [ "$CIRCLE_BRANCH" = "$REACT_WEBSITE_BRANCH" ]; then
6
+
7
+ GH_PAGES_DIR=`pwd`/../react-gh-pages
8
+
9
+ # check if directory exists (restored from cache)
10
+ if [ -d $GH_PAGES_DIR ]; then
11
+ pushd $GH_PAGES_DIR
12
+ git pull origin gh-pages
13
+ popd
14
+ else
15
+ git clone --branch gh-pages --depth=1 \
16
+ https://reactjs-bot@github.com/facebook/react.git \
17
+ $GH_PAGES_DIR
18
+ fi
19
+
20
+ pushd docs
21
+ bundle exec rake release
22
+ cd $GH_PAGES_DIR
23
+ git status
24
+ git --no-pager diff
25
+ if ! git diff-index --quiet HEAD --; then
26
+ git add -A .
27
+ git commit -m "Rebuild website"
28
+ git push origin gh-pages
29
+ fi
30
+ popd
31
+else
32
+ echo "Not building website"
33
+fi
scripts/circleci/set_up_github_keys.sh
new
+12
@@ -0,0 +1,12 @@
1
+#!/bin/bash
2
+
3
+set -e
4
+
5
+if [ -n $GITHUB_TOKEN ]; then
6
+
7
+ GH_PAGES_DIR=`pwd`/../react-gh-pages
8
+ echo "machine github.com login reactjs-bot password $GITHUB_TOKEN" >~/.netrc
9
+ git config --global user.name "Circle CI"
10
+ git config --global user.email "circle@reactjs.org"
11
+
12
+fi
scripts/circleci/test_coverage.sh
new
+6
@@ -0,0 +1,6 @@
1
+#!/bin/bash
2
+
3
+set -e
4
+
5
+./node_modules/.bin/grunt jest:coverage
6
+cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
scripts/circleci/test_fiber.sh
new
+9
@@ -0,0 +1,9 @@
1
+#!/bin/bash
2
+
3
+set -e
4
+
5
+echo 'Testing in fiber mode...'
6
+./scripts/fiber/record-tests --track-facts --max-workers 1
7
+git --no-pager diff scripts/fiber
8
+FIBER_TESTS_STATUS=$(git status --porcelain scripts/fiber)
9
+test -z "$FIBER_TESTS_STATUS"
scripts/circleci/test_html_generation.sh
new
+9
@@ -0,0 +1,9 @@
1
+#!/bin/bash
2
+
3
+set -e
4
+
5
+echo 'Testing in server-render (HTML generation) mode...'
6
+printf '\nmodule.exports.useCreateElement = false;\n' \
7
+ >> src/renderers/dom/shared/ReactDOMFeatureFlags.js
8
+./node_modules/.bin/grunt jest:normal
9
+git checkout -- src/renderers/dom/shared/ReactDOMFeatureFlags.js
scripts/circleci/track_stats.sh
new
+8
@@ -0,0 +1,8 @@
1
+#!/bin/bash
2
+
3
+set -e
4
+
5
+ALL_FILES=`find src -name '*.js' | grep -v umd/ | grep -v __tests__ | grep -v __mocks__`
6
+COUNT_ALL_FILES=`echo "$ALL_FILES" | wc -l`
7
+COUNT_WITH_FLOW=`grep '@flow' $ALL_FILES | perl -pe 's/:.+//' | wc -l`
8
+node scripts/facts-tracker/index.js "flow-files" "$COUNT_WITH_FLOW/$COUNT_ALL_FILES"
scripts/circleci/upload_build.sh
new
+23
@@ -0,0 +1,23 @@
1
+#!/bin/bash
2
+
3
+set -e
4
+
5
+if [ -z $CI_PULL_REQUEST ]; then
6
+ curl \
7
+ -F "react=@build/react.js" \
8
+ -F "react.min=@build/react.min.js" \
9
+ -F "react-with-addons=@build/react-with-addons.js" \
10
+ -F "react-with-addons.min=@build/react-with-addons.min.js" \
11
+ -F "react-dom=@build/react-dom.js" \
12
+ -F "react-dom.min=@build/react-dom.min.js" \
13
+ -F "react-dom-server=@build/react-dom-server.js" \
14
+ -F "react-dom-server.min=@build/react-dom-server.min.js" \
15
+ -F "npm-react=@build/packages/react.tgz" \
16
+ -F "npm-react-dom=@build/packages/react-dom.tgz" \
17
+ -F "commit=$CIRCLE_SHA1" \
18
+ -F "date=`git log --format='%ct' -1`" \
19
+ -F "pull_request=false" \
20
+ -F "token=$BUILD_SERVER_TOKEN" \
21
+ -F "branch=$CIRCLE_BRANCH" \
22
+ $BUILD_SERVER_ENDPOINT
23
+fi
scripts/fiber/record-tests
+8
-5
@@ -78,7 +78,7 @@ function wrapRunner(originalPath) {
78
};
79
}
80
81
-function runJest() {
81
+function runJest(maxWorkers) {
82
return readConfig(argv, root)
83
.then((config) => {
84
config = Object.assign({}, config, {
@@ -92,7 +92,7 @@ function runJest() {
92
hasteMap,
93
config,
94
{
95
- maxWorkers: Math.max(os.cpus().length - 1, 1),
95
+ maxWorkers: maxWorkers,
96
getTestSummary: () => 'You did it!'
97
}
98
);
@@ -119,9 +119,9 @@ function formatResults(runResults, predicate) {
119
return formatted.join('\n\n');
120
}
121
122
-function recordTests(trackFacts) {
122
+function recordTests(maxWorkers, trackFacts) {
123
process.env.REACT_DOM_JEST_USE_FIBER = true;
124
- runJest()
124
+ runJest(maxWorkers)
125
.then((runResults) => {
126
const passing = formatResults(
127
runResults,
@@ -169,12 +169,15 @@ function recordTests(trackFacts) {
169
if (require.main === module) {
170
const argv = require('yargs')
171
.demand(0, 0)
172
+ .number('max-workers')
173
+ .describe('max-workers', 'Number of workers to use for jest.')
174
+ .default('max-workers', Math.max(os.cpus().length - 1, 1))
175
.boolean('track-facts')
176
.describe('track-facts', 'Use facts-tracker to record passing tests.')
177
.strict()
178
.help()
179
.argv;
177
- recordTests(argv.trackFacts);
180
+ recordTests(argv.maxWorkers, argv.trackFacts);
181
}
182
183
module.exports = {