feat: Improve CI process (#1759)

This commit is contained in:
Franck Abgrall
2019-09-07 14:07:16 +02:00
committed by GitHub
parent 3b68913996
commit fe7301bc48
3 changed files with 137 additions and 37 deletions
+123 -25
View File
@@ -2,36 +2,134 @@
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
version: 2.1
defaults: &defaults
working_directory: ~/project
docker:
- image: circleci/node:latest
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/node:10.15.2
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/mongo:3.4.4
working_directory: ~/repo
#------------------------------------------------------------
# 1. Install dependencies
#------------------------------------------------------------
install-dependencies:
<<: *defaults
steps:
- checkout
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- restore_cache:
keys:
- v1-deps-{{ checksum "yarn.lock" }}
- v1-deps
- run: yarn bootstrap
- run:
name: 'Install dependencies'
command: yarn --frozen-lockfile --non-interactive
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- save_cache:
key: v1-deps-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- persist_to_workspace:
root: ~/project
paths:
- node_modules
- packages/*/node_modules
- packages/@vuepress/*/node_modules
#------------------------------------------------------------
# 2. Run parallel jobs:
# => lerna-boostrap
# => tsc
# => tests
# => linter
# => docs linter
#------------------------------------------------------------
# run tests!
- run: yarn build && yarn lint && yarn test
lerna-bootstrap:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/project
- run:
name: 'Lerna bootstrap'
command: yarn lerna:bootstrap
run-tsc:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/project
- run:
name: 'Run tsc'
command: yarn tsc
- persist_to_workspace:
root: ~/project
paths:
- packages/@vuepress/shared-utils/lib
run-tests:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/project
- run:
name: 'Run tests'
command: yarn test
run-linter-check:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/project
- run:
name: 'Run linter'
command: yarn lint:check
run-docs-linter-check:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/project
- run:
name: 'Run md linter'
command: yarn workspace docs lint-md
#------------------------------------------------------------
# 3. Build VuePress
#------------------------------------------------------------
build:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/project
- run:
name: 'Run tests'
command: yarn build
#------------------------------------------------------------
# Workflows
#------------------------------------------------------------
workflows:
version: 2
build:
jobs:
- install-dependencies
- lerna-bootstrap: { requires: [install-dependencies] }
- run-linter-check: { requires: [install-dependencies] }
- run-docs-linter-check: { requires: [install-dependencies] }
- run-tsc: { requires: [install-dependencies] }
- run-tests: { requires: [run-tsc] }
- build: { requires: [run-tests, run-linter-check, run-docs-linter-check, lerna-bootstrap] }
+4 -2
View File
@@ -9,6 +9,7 @@
"scripts": {
"precommit": "lint-staged",
"bootstrap": "yarn && yarn tsc",
"lerna:bootstrap": "lerna bootstrap",
"clean": "lerna clean && rm -rf node_modules",
"packages:list": "lerna ls -l",
"packages:diff": "lerna diff",
@@ -22,9 +23,10 @@
"view-info": "yarn tsc && yarn workspace docs view-info",
"show-help": "yarn workspace docs show-help",
"register-vuepress": "lerna exec --scope vuepress -- yarn link",
"lint": "yarn lint:check --fix",
"lint:check": "eslint packages --ext .js,.vue",
"release": "yarn --pure-lockfile && yarn tsc && node scripts/release.js",
"unregister-vuepress": "lerna exec --scope vuepress -- yarn unlink",
"lint": "eslint packages --fix --ext .js,.vue",
"release": "yarn --pure-lockfile && yarn tsc && node scripts/release.js",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 2",
"test": "node scripts/test.js",
"tsc": "yarn workspace @vuepress/shared-utils tsc"
@@ -6,9 +6,9 @@ sidebar: auto
## Informations
If you here youh may be intereset of improve core vuepress.
If you here youh may be intereset of improve core VuePress.
Vuepress is using a combo with [Yarn workspaces](https://yarnpkg.com/lang/en/docs/workspaces/) and [Lerna](https://github.com/lerna/lerna).
VuePress is using a combo with [Yarn workspaces](https://yarnpkg.com/lang/en/docs/workspaces/) and [Lerna](https://github.com/lerna/lerna).
## Init packages
@@ -16,11 +16,11 @@ Vuepress is using a combo with [Yarn workspaces](https://yarnpkg.com/lang/en/doc
yarn bootstrap // it will run and install into the root all packages subfolders
```
yarn bootstrap will use hoisting. What it mean for you ?
`yarn bootstrap` will use hoisting. What does it mean for you ?
It will regroup all dependencies in the workspace root and link all packages.
to check the link you can run
Check the link by running the following command:
```bash
ls -la node_modules/@vuepress
@@ -45,7 +45,7 @@ run `yarn tsc` all the time or run in separate shell `yarn run tsc -w`. This wil
## Link
Good from here you have everything ready. You need to link vuepress to your project.
Good from here you have everything ready. You need to link VuePress to your project.
```bash
yarn register-vuepress
@@ -53,9 +53,9 @@ yarn register-vuepress
You will have something like this: `success Registered "vuepress".`
It will link the package vuepress from packages/vuepress. So you will have access to vuepress cli and vuepress packages.
It will link the package VuePress from `packages/vuepress`. You will have access to VuePress cli and packages.
they are decalre in the `packages/vuepress/package.json`
They are declared in the `packages/vuepress/package.json`
```js
{
@@ -87,10 +87,10 @@ If everything work properly you should have an error telling you there is no pac
## BUGS / QA
You will maybe find some difficulty with link. If you encounter something like `There's already a package called "vuepress" registered`.
You have already vuepress registered. so:
You already have VuePress registered:
- if you already link vuepress from [Link](#link). It's totally fine. If you make changes because it is symlink you dont have to re run something. You will have to rerun yarn tsc if you update shared-utils package. Nothing more
- if you have done nothing. You have already vuepress linked somewhere. What you have to do is to delete folder where you already run `yarn link` or run `yarn unlink` inside it.
- If you already link VuePress from [Link](#link). Its totally fine. If you make changes because it is symlink you dont have to re run something. You will have to rerun yarn tsc if you update shared-utils package. Nothing more
- If you didnt do anything. You already have VuePress linked somewhere. What you have to do is deleting folder where you ran `yarn link` or `yarn unlink`.
## More