Skip to content

Commit

Permalink
feat: Improve CI process (#1759)
Browse files Browse the repository at this point in the history
  • Loading branch information
kefranabg authored Sep 7, 2019
1 parent 3b68913 commit fe7301b
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 36 deletions.
146 changes: 122 additions & 24 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
#------------------------------------------------------------
# 1. Install dependencies
#------------------------------------------------------------

install-dependencies:
<<: *defaults
steps:
- checkout

- restore_cache:
keys:
- v1-deps-{{ checksum "yarn.lock" }}
- v1-deps

- run:
name: 'Install dependencies'
command: yarn --frozen-lockfile --non-interactive

- 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
#------------------------------------------------------------

working_directory: ~/repo
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
- checkout
- attach_workspace:
at: ~/project
- run:
name: 'Run tests'
command: yarn test

# 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-
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
#------------------------------------------------------------

- run: yarn bootstrap
build:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/project
- run:
name: 'Run tests'
command: yarn build

- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
#------------------------------------------------------------
# Workflows
#------------------------------------------------------------

# run tests!
- run: yarn build && yarn lint && yarn test
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] }
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down
20 changes: 10 additions & 10 deletions packages/docs/docs/miscellaneous/local-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ 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

```bash
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
Expand All @@ -45,17 +45,17 @@ 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
```

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
{
Expand Down Expand Up @@ -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 didn’t 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

Expand Down

0 comments on commit fe7301b

Please sign in to comment.