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

Add circle.yml / CircleCI support #8486

Merged
merged 62 commits into from
Dec 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
5abc616
Initial CircleCI config
zpao Mar 21, 2016
2a963c7
circle timezone
zpao Mar 22, 2016
06a836c
more circle
zpao Mar 22, 2016
9288798
fix circle
zpao Mar 22, 2016
05a3eaa
circle npm bin path
zpao Mar 22, 2016
072b087
lint too
zpao Mar 22, 2016
1111e51
max out at 8 jest workers to prevent blowing memory limit
zpao Mar 22, 2016
5667104
jest option name changed...
zpao Mar 22, 2016
516bda9
jest configuration sucks
zpao Mar 22, 2016
9a60b74
update instead of install
zpao Mar 22, 2016
a9a7151
install docs bundle & cache it
zpao Mar 22, 2016
067aac3
bundle install to the right path
zpao Mar 22, 2016
4ed0330
Upload builds
zpao Mar 23, 2016
9958fd1
fix build probably
zpao Mar 23, 2016
3fa3dcf
use magic staging name maybe
zpao Mar 23, 2016
e5935b9
Cache grunt dir too for build comparison results
zpao Mar 23, 2016
077ac68
stop running jest for now for faster turnaround, we know it works
zpao Mar 23, 2016
b2582b9
how do regexs work?
zpao Mar 23, 2016
3b6574d
so dumb
zpao Mar 23, 2016
06fee65
run server rendering test too
zpao Mar 23, 2016
4ae5162
+x
zpao Mar 23, 2016
9d0d5fa
dummy
zpao Mar 23, 2016
7ba88ca
build website
zpao Mar 23, 2016
a1aa2f9
actually build docs without failing
Mar 23, 2016
2f9f25e
run everything in bash scripts to get that pushd builtin
Mar 23, 2016
c938b56
try to get the commit range
Mar 23, 2016
0e03b81
maybe this
Mar 23, 2016
a120a37
add yarn
zpao Nov 18, 2016
05423f1
yarn install
zpao Nov 18, 2016
a771f21
cache bundler
zpao Nov 18, 2016
5be76bb
don't npm ls
zpao Nov 18, 2016
e7b951e
play with caching
zpao Nov 18, 2016
fbb626e
try jest again
zpao Nov 18, 2016
f433e62
better jest, run in band
zpao Nov 18, 2016
bbfae27
fi runinband
zpao Nov 18, 2016
1835276
disable build steps so we get to tests faster
zpao Nov 18, 2016
90265c6
stop tryign to upload build artifacts
zpao Nov 18, 2016
b8e2af5
run flow
zpao Nov 18, 2016
f293dce
max out at 8 jest workers to prevent blowing memory limit
zpao Mar 22, 2016
59bd23b
jest option name changed...
zpao Mar 22, 2016
c083f2c
jest configuration sucks
zpao Mar 22, 2016
ae0a146
cache bundler
zpao Nov 18, 2016
c64aa1d
play with caching
zpao Nov 18, 2016
8a97e95
upgrade node to v6, and test circle again
tomocchino Nov 30, 2016
024c36b
run lint and jest:coverage
tomocchino Nov 30, 2016
6e30a16
test html generation
tomocchino Nov 30, 2016
5a5a385
rename flow.sh to track_flow_facts and move flow and lint to just use…
tomocchino Nov 30, 2016
db4b834
mess with CIRCLE_COMPARE_URL
tomocchino Nov 30, 2016
32a824b
add extract-errors task
tomocchino Dec 1, 2016
3c6b26b
add test_fiber.sh
tomocchino Dec 1, 2016
f5cb809
disable fiber tests for now until I figure out how to run them with r…
tomocchino Dec 1, 2016
34462e7
reenable fiber tests with maxWorkers jest config set to 1
tomocchino Dec 1, 2016
9ed8055
change order of steps because errors are stupid
tomocchino Dec 2, 2016
c8cc94a
change gitconfig global username to Circle CI instead of Travis
tomocchino Dec 2, 2016
e8a43b2
move test coverage tracking to a shell script so we can pipe the outp…
tomocchino Dec 2, 2016
61e21a3
switch order of pre and override for dependencies section
tomocchino Dec 2, 2016
c543874
rename and reorder some steps, enable the grunt build step
tomocchino Dec 2, 2016
79b091a
move grunt build to post instead of pre because apparently it relies …
tomocchino Dec 2, 2016
2e5d1e7
document what is for
tomocchino Dec 2, 2016
99287c7
move build back above extract errors
tomocchino Dec 2, 2016
f383cff
s/zpao/facebook|reactjs-bot/ and uncomment upload build.. fingers cro…
tomocchino Dec 2, 2016
54c7cd6
Set max workers back, set up github keys before facts
sophiebits Dec 2, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions grunt/tasks/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function run(done, coverage) {

var args = [
path.join('node_modules', 'jest-cli', 'bin', 'jest'),
'--runInBand',
];
if (coverage) {
args.push('--coverage');
Expand Down
33 changes: 33 additions & 0 deletions scripts/circleci/build_gh_pages.sh
Original file line number Diff line number Diff line change
@@ -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 changes: 12 additions & 0 deletions scripts/circleci/set_up_github_keys.sh
Original file line number Diff line number Diff line change
@@ -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 changes: 6 additions & 0 deletions scripts/circleci/test_coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -e

./node_modules/.bin/grunt jest:coverage
cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
9 changes: 9 additions & 0 deletions scripts/circleci/test_fiber.sh
Original file line number Diff line number Diff line change
@@ -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 changes: 9 additions & 0 deletions scripts/circleci/test_html_generation.sh
Original file line number Diff line number Diff line change
@@ -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 changes: 8 additions & 0 deletions scripts/circleci/track_stats.sh
Original file line number Diff line number Diff line change
@@ -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 changes: 23 additions & 0 deletions scripts/circleci/upload_build.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 8 additions & 5 deletions scripts/fiber/record-tests
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function wrapRunner(originalPath) {
};
}

function runJest() {
function runJest(maxWorkers) {
return readConfig(argv, root)
.then((config) => {
config = Object.assign({}, config, {
Expand All @@ -92,7 +92,7 @@ function runJest() {
hasteMap,
config,
{
maxWorkers: Math.max(os.cpus().length - 1, 1),
maxWorkers: maxWorkers,
getTestSummary: () => 'You did it!'
}
);
Expand All @@ -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,
Expand Down Expand Up @@ -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 = {
Expand Down