Repository: vuejs/vue
Pull request: Improve #6041, Migrate to CircleCI 2.0

<!--
Please make sure to read the Pull Request Guidelines:
https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md#pull-request-guidelines
-->

<!-- PULL REQUEST TEMPLATE -->
<!-- (Update "[ ]" to "[x]" to check a box) -->

**What kind of change does this PR introduce?** (check at least one)

- [ ] Bugfix
- [ ] Feature
- [ ] Code style update
- [ ] Refactor
- [ ] Build-related changes
- [x] Other, please describe:

**Does this PR introduce a breaking change?** (check one)

- [ ] Yes
- [x] No

If yes, please describe the impact and migration path for existing applications:

**The PR fulfills these requirements:**

- [x] It's submitted to the `dev` branch for v2.x (or to a previous version branch), _not_ the `master` branch
- [x] When resolving a specific issue, it's referenced in the PR's title (e.g. `fix #xxx[,#xxx]`, where "xxx" is the issue number)
- [x] All tests are passing: https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md#development-setup
- [ ] New/updated tests are included

If adding a **new feature**, the PR's description includes:
- [ ] A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

**Other information:**

We are going to migrate to CircleCI 2.0 with #6041, but with a simpler description, we can make the build run time shorter.

When caching node_modules, the build is now finished in 1 minute 20 seconds.
https://circleci.com/workflow-run/7ea0d4e0-48ca-449d-9a52-9880dbbd93a5

In the case of 2.0, we have to describe all of the procedures procedurally, but on the contrary, I think that approach is easy to understand.

Please check this PR 😃 @yyx990803 @posva 

Changed files:
filename: .circleci/config.yml
patch: @@ -0,0 +1,83 @@
+version: 2
+
+defaults: &defaults
+  working_directory: ~/project/vue
+  docker:
+    - image: circleci/node:6-browsers
+
+jobs:
+  install:
+    <<: *defaults
+    steps:
+      - checkout
+      - restore_cache:
+          keys:
+            - v1-vue-{{ .Branch }}-{{ checksum "package-lock.json" }}
+            - v1-vue-{{ .Branch }}-
+            - v1-vue-
+      - run:
+          name: Install Dependencies
+          command: npm install
+      - save_cache:
+          key: v1-vue-{{ .Branch }}-{{ checksum "package-lock.json" }}
+          paths:
+            - node_modules/
+      - persist_to_workspace:
+          root: ~/project
+          paths:
+            - vue
+
+  lint-flow-types:
+    <<: *defaults
+    steps:
+      - attach_workspace:
+          at: ~/project
+      - run: npm run lint
+      - run: node_modules/.bin/flow check
+      - run: npm run test:types
+
+  test-cover:
+    <<: *defaults
+    steps:
+      - attach_workspace:
+          at: ~/project
+      - run: npm run test:cover
+      - run:
+         name: report coverage stats for non-PRs
+         command: |
+           if [[ -z $CI_PULL_REQUEST ]]; then
+             cat ./coverage/lcov.info | ./node_modules/.bin/codecov
+           fi
+
+  test-e2e:
+    <<: *defaults
+    steps:
+      - attach_workspace:
+          at: ~/project
+      - run: npm run test:e2e -- --env phantomjs
+
+  test-ssr-weex:
+    <<: *defaults
+    steps:
+      - attach_workspace:
+          at: ~/project
+      - run: npm run test:ssr
+      - run: npm run test:weex
+
+workflows:
+  version: 2
+  install-and-parallel-test:
+    jobs:
+      - install
+      - test-cover:
+          requires:
+            - install
+      - lint-flow-types:
+          requires:
+            - install
+      - test-e2e:
+          requires:
+            - install
+      - test-ssr-weex:
+          requires:
+            - install

filename: build/ci.sh
patch: @@ -1,7 +0,0 @@
-set -e
-npm test
-
-# report coverage stats for non-PRs
-if [[ -z $CI_PULL_REQUEST ]]; then
-  cat ./coverage/lcov.info | ./node_modules/.bin/codecov
-fi

filename: circle.yml
patch: @@ -1,7 +0,0 @@
-machine:
-  node:
-    version: 6
-
-test:
-  override:
-    - bash build/ci.sh