mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
Add circle.yml / CircleCI support (#8486)
This commit is contained in:
54
circle.yml
Normal file
54
circle.yml
Normal file
@@ -0,0 +1,54 @@
|
||||
---
|
||||
general:
|
||||
branches:
|
||||
ignore:
|
||||
- gh-pages
|
||||
|
||||
machine:
|
||||
timezone: America/Los_Angeles
|
||||
node:
|
||||
version: 6
|
||||
ruby:
|
||||
version: 2.2.3
|
||||
environment:
|
||||
TRAVIS_REPO_SLUG: facebook/react
|
||||
|
||||
dependencies:
|
||||
pre:
|
||||
# This is equivalent to $TRAVIS_COMMIT_RANGE
|
||||
# Need to figure out how to bail early if this is a "docs only" build
|
||||
- echo $CIRCLE_COMPARE_URL | cut -d/ -f7
|
||||
# install yarn
|
||||
- sudo apt-key adv --fetch-keys http://dl.yarnpkg.com/debian/pubkey.gpg
|
||||
- echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -y -qq yarn
|
||||
override:
|
||||
- bundle install --gemfile=docs/Gemfile --deployment --path=vendor/bundle --jobs=3 --retry=3
|
||||
- yarn install
|
||||
- scripts/circleci/set_up_github_keys.sh
|
||||
post:
|
||||
# - npm ls --depth=0
|
||||
cache_directories:
|
||||
- docs/vendor/bundle
|
||||
- .grunt # Show size comparisons between builds
|
||||
- ~/react-gh-pages # docs checkout
|
||||
- ~/.yarn-cache
|
||||
|
||||
test:
|
||||
override:
|
||||
- ./node_modules/.bin/gulp lint
|
||||
- ./node_modules/.bin/gulp flow
|
||||
- ./scripts/circleci/test_coverage.sh
|
||||
- ./scripts/circleci/test_fiber.sh
|
||||
- ./scripts/circleci/test_html_generation.sh
|
||||
- ./scripts/circleci/track_stats.sh
|
||||
- ./node_modules/.bin/grunt build
|
||||
- ./node_modules/.bin/gulp react:extract-errors
|
||||
|
||||
deployment:
|
||||
staging:
|
||||
branch: /.*/
|
||||
commands:
|
||||
- ./scripts/circleci/upload_build.sh
|
||||
- ./scripts/circleci/build_gh_pages.sh
|
||||
@@ -8,6 +8,7 @@ function run(done, coverage) {
|
||||
|
||||
var args = [
|
||||
path.join('node_modules', 'jest-cli', 'bin', 'jest'),
|
||||
'--runInBand',
|
||||
];
|
||||
if (coverage) {
|
||||
args.push('--coverage');
|
||||
|
||||
33
scripts/circleci/build_gh_pages.sh
Executable file
33
scripts/circleci/build_gh_pages.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ -z $CI_PULL_REQUEST ] && [ "$CIRCLE_BRANCH" = "$REACT_WEBSITE_BRANCH" ]; then
|
||||
|
||||
GH_PAGES_DIR=`pwd`/../react-gh-pages
|
||||
|
||||
# check if directory exists (restored from cache)
|
||||
if [ -d $GH_PAGES_DIR ]; then
|
||||
pushd $GH_PAGES_DIR
|
||||
git pull origin gh-pages
|
||||
popd
|
||||
else
|
||||
git clone --branch gh-pages --depth=1 \
|
||||
https://reactjs-bot@github.com/facebook/react.git \
|
||||
$GH_PAGES_DIR
|
||||
fi
|
||||
|
||||
pushd docs
|
||||
bundle exec rake release
|
||||
cd $GH_PAGES_DIR
|
||||
git status
|
||||
git --no-pager diff
|
||||
if ! git diff-index --quiet HEAD --; then
|
||||
git add -A .
|
||||
git commit -m "Rebuild website"
|
||||
git push origin gh-pages
|
||||
fi
|
||||
popd
|
||||
else
|
||||
echo "Not building website"
|
||||
fi
|
||||
12
scripts/circleci/set_up_github_keys.sh
Executable file
12
scripts/circleci/set_up_github_keys.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ -n $GITHUB_TOKEN ]; then
|
||||
|
||||
GH_PAGES_DIR=`pwd`/../react-gh-pages
|
||||
echo "machine github.com login reactjs-bot password $GITHUB_TOKEN" >~/.netrc
|
||||
git config --global user.name "Circle CI"
|
||||
git config --global user.email "circle@reactjs.org"
|
||||
|
||||
fi
|
||||
6
scripts/circleci/test_coverage.sh
Executable file
6
scripts/circleci/test_coverage.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
./node_modules/.bin/grunt jest:coverage
|
||||
cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
|
||||
9
scripts/circleci/test_fiber.sh
Executable file
9
scripts/circleci/test_fiber.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo 'Testing in fiber mode...'
|
||||
./scripts/fiber/record-tests --track-facts --max-workers 1
|
||||
git --no-pager diff scripts/fiber
|
||||
FIBER_TESTS_STATUS=$(git status --porcelain scripts/fiber)
|
||||
test -z "$FIBER_TESTS_STATUS"
|
||||
9
scripts/circleci/test_html_generation.sh
Executable file
9
scripts/circleci/test_html_generation.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo 'Testing in server-render (HTML generation) mode...'
|
||||
printf '\nmodule.exports.useCreateElement = false;\n' \
|
||||
>> src/renderers/dom/shared/ReactDOMFeatureFlags.js
|
||||
./node_modules/.bin/grunt jest:normal
|
||||
git checkout -- src/renderers/dom/shared/ReactDOMFeatureFlags.js
|
||||
8
scripts/circleci/track_stats.sh
Executable file
8
scripts/circleci/track_stats.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
ALL_FILES=`find src -name '*.js' | grep -v umd/ | grep -v __tests__ | grep -v __mocks__`
|
||||
COUNT_ALL_FILES=`echo "$ALL_FILES" | wc -l`
|
||||
COUNT_WITH_FLOW=`grep '@flow' $ALL_FILES | perl -pe 's/:.+//' | wc -l`
|
||||
node scripts/facts-tracker/index.js "flow-files" "$COUNT_WITH_FLOW/$COUNT_ALL_FILES"
|
||||
23
scripts/circleci/upload_build.sh
Executable file
23
scripts/circleci/upload_build.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ -z $CI_PULL_REQUEST ]; then
|
||||
curl \
|
||||
-F "react=@build/react.js" \
|
||||
-F "react.min=@build/react.min.js" \
|
||||
-F "react-with-addons=@build/react-with-addons.js" \
|
||||
-F "react-with-addons.min=@build/react-with-addons.min.js" \
|
||||
-F "react-dom=@build/react-dom.js" \
|
||||
-F "react-dom.min=@build/react-dom.min.js" \
|
||||
-F "react-dom-server=@build/react-dom-server.js" \
|
||||
-F "react-dom-server.min=@build/react-dom-server.min.js" \
|
||||
-F "npm-react=@build/packages/react.tgz" \
|
||||
-F "npm-react-dom=@build/packages/react-dom.tgz" \
|
||||
-F "commit=$CIRCLE_SHA1" \
|
||||
-F "date=`git log --format='%ct' -1`" \
|
||||
-F "pull_request=false" \
|
||||
-F "token=$BUILD_SERVER_TOKEN" \
|
||||
-F "branch=$CIRCLE_BRANCH" \
|
||||
$BUILD_SERVER_ENDPOINT
|
||||
fi
|
||||
@@ -78,7 +78,7 @@ function wrapRunner(originalPath) {
|
||||
};
|
||||
}
|
||||
|
||||
function runJest() {
|
||||
function runJest(maxWorkers) {
|
||||
return readConfig(argv, root)
|
||||
.then((config) => {
|
||||
config = Object.assign({}, config, {
|
||||
@@ -92,7 +92,7 @@ function runJest() {
|
||||
hasteMap,
|
||||
config,
|
||||
{
|
||||
maxWorkers: Math.max(os.cpus().length - 1, 1),
|
||||
maxWorkers: maxWorkers,
|
||||
getTestSummary: () => 'You did it!'
|
||||
}
|
||||
);
|
||||
@@ -119,9 +119,9 @@ function formatResults(runResults, predicate) {
|
||||
return formatted.join('\n\n');
|
||||
}
|
||||
|
||||
function recordTests(trackFacts) {
|
||||
function recordTests(maxWorkers, trackFacts) {
|
||||
process.env.REACT_DOM_JEST_USE_FIBER = true;
|
||||
runJest()
|
||||
runJest(maxWorkers)
|
||||
.then((runResults) => {
|
||||
const passing = formatResults(
|
||||
runResults,
|
||||
@@ -169,12 +169,15 @@ function recordTests(trackFacts) {
|
||||
if (require.main === module) {
|
||||
const argv = require('yargs')
|
||||
.demand(0, 0)
|
||||
.number('max-workers')
|
||||
.describe('max-workers', 'Number of workers to use for jest.')
|
||||
.default('max-workers', Math.max(os.cpus().length - 1, 1))
|
||||
.boolean('track-facts')
|
||||
.describe('track-facts', 'Use facts-tracker to record passing tests.')
|
||||
.strict()
|
||||
.help()
|
||||
.argv;
|
||||
recordTests(argv.trackFacts);
|
||||
recordTests(argv.maxWorkers, argv.trackFacts);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user