Skip to content

Commit

Permalink
Switch to yarn
Browse files Browse the repository at this point in the history
Summary:
Switch to Yarn in order to more closely match internal Facebook environment.
Closes #17193

Differential Revision: D6572337

Pulled By: hramos

fbshipit-source-id: 331b1f331937e8ce3b787d48561e2e655d4a1cc9
  • Loading branch information
hramos authored and facebook-github-bot committed Jan 30, 2018
1 parent a9c684a commit da8bec9
Showing 1 changed file with 63 additions and 51 deletions.
114 changes: 63 additions & 51 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
aliases:
- &restore-node-cache
- &restore-yarn-cache
keys:
- v2-dependencies-{{ arch }}-{{ checksum "package.json" }}
- v1-yarn-{{ arch }}-{{ checksum "package.json" }}
# Fallback in case checksum fails
- v2-dependencies-{{ arch }}-

- &save-node-cache
- v1-yarn-{{ arch }}-
- &save-yarn-cache
paths:
- node_modules
key: v2-dependencies-{{ arch }}-{{ checksum "package.json" }}
- ~/.cache/yarn
key: v1-yarn-{{ arch }}-{{ checksum "package.json" }}

- &restore-cache-analysis
keys:
Expand Down Expand Up @@ -60,6 +60,16 @@ aliases:
- ~/watchman
key: v1-watchman-{{ arch }}-v4.9.0

- &yarn
|
yarn install --non-interactive --cache-folder ~/.cache/yarn

- &install-yarn
|
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn

- &install-node-dependencies
|
npm install --no-package-lock --no-spin --no-progress
Expand All @@ -77,18 +87,18 @@ aliases:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

- &run-node-tests
|
npm test -- --maxWorkers=2

- &run-js-tests
|
yarn test --maxWorkers=2
- &run-lint-checks
|
npm run lint
|
yarn lint

- &run-flow-checks
|
npm run flow -- check
|
yarn flow check

- &filter-only-master-stable
branches:
only:
Expand Down Expand Up @@ -203,9 +213,9 @@ jobs:
- image: circleci/node:8
steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run: *run-lint-checks
- run: *run-flow-checks

Expand All @@ -216,10 +226,10 @@ jobs:
- image: circleci/node:8
steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run: *run-node-tests
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run: *run-js-tests

# Runs JavaScript tests on Node 6
test-js-node-6:
Expand All @@ -228,10 +238,10 @@ jobs:
- image: circleci/node:6
steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run: *run-node-tests
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run: *run-js-tests

# Runs unit tests on iOS devices
test-objc-ios:
Expand All @@ -243,9 +253,9 @@ jobs:
- xcrun instruments -w "iPhone 5s (10.3.1)" || true
steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run: ./scripts/objc-test-ios.sh

# Runs unit tests on tvOS devices
Expand All @@ -258,9 +268,9 @@ jobs:
- xcrun instruments -w "Apple TV 1080p (10.0)" || true
steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run: ./scripts/objc-test-tvos.sh

# Runs end to end tests
Expand All @@ -273,9 +283,9 @@ jobs:
- xcrun instruments -w "iPhone 5s (10.3.1)" || true
steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run: node ./scripts/run-ci-e2e-tests.js --ios --js --retries 3;

# Checks podspec
Expand All @@ -285,9 +295,9 @@ jobs:
xcode: "9.0"
steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run: ./scripts/process-podspecs.sh

# Publishes new version onto npm
Expand All @@ -310,9 +320,10 @@ jobs:
- run: *install-buck
- save-cache: *save-cache-buck
- run: *install-node
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run: *install-yarn
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run: buck fetch ReactAndroid/src/test/java/com/facebook/react/modules
- run: buck fetch ReactAndroid/src/main/java/com/facebook/react
- run: buck fetch ReactAndroid/src/main/java/com/facebook/react/shell
Expand Down Expand Up @@ -372,9 +383,10 @@ jobs:

# The JavaScript Bundle is required for instrumentation tests.
- run: *install-node
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run: *install-yarn
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run: *build-js-bundle

# Wait for AVD to finish booting before running tests
Expand All @@ -398,14 +410,14 @@ jobs:
steps:
- checkout
- restore-cache: *restore-cache-analysis
- run: *install-node-dependencies
- run: *yarn
- run:
name: Install Dependencies
name: Install Additional Dependencies
command: |
if [ -n "$CIRCLE_PULL_REQUEST" ]; then
npm install github@0.2.4
yarn add github@0.2.4
cd danger
npm install --no-package-lock --no-spin --no-progress
yarn install --non-interactive --cache-folder ~/.cache/yarn
else
echo "Skipping dependency installation."
fi
Expand All @@ -414,16 +426,16 @@ jobs:
name: Analyze Pull Request
command: |
if [ -n "$CIRCLE_PULL_REQUEST" ]; then
cd danger && DANGER_GITHUB_API_TOKEN="e622517d9f1136ea8900""07c6373666312cdfaa69" npm run danger
cd danger && DANGER_GITHUB_API_TOKEN="e622517d9f1136ea8900""07c6373666312cdfaa69" yarn danger
else
echo "Skipping pull request analysis."
fi
when: always
- run:
name: Analyze Code
command: |
if [ -n "$CIRCLE_PULL_REQUEST" ]; then
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
if [ -n "$CIRCLE_PR_NUMBER" ]; then
cat <(echo eslint; yarn --silent lint --format=json; echo flow; yarn --silent flow 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
else
echo "Skipping code analysis."
fi
Expand Down

2 comments on commit da8bec9

@janicduplessis
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hramos Would it be possible to commit the yarn.lock file with the current infra?

@hramos
Copy link
Contributor Author

@hramos hramos commented on da8bec9 Feb 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid not, as it would conflict with our internal lockfile and offline mirror.

Nothing that cannot be worked around, perhaps we could have an internal .github.yarn.lock => yarn.lock mapping like we do with .github.flowconfig => .flowconfig.

Please sign in to comment.