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

Github Actions CI/CD with lerna and commitizen #952

Open
wants to merge 7 commits into
base: eleven
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 26 additions & 0 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node CI

on:
pull_request:

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm i
- run: npm run build --if-present
- run: npm test
58 changes: 58 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This workflow will run tests using node and then publish a package to NPM and GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

#name: Publish Packages
#
#on:
# push:
# branches: [ eleven ]
#jobs:
# build:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-node@v1
# with:
# node-version: 12
# - run: npm ci
# - run: npm test
#
# publish-npm:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - uses: actions/setup-node@v1
# with:
# node-version: 12
# registry-url: https://registry.npmjs.org/
# - run: npm ci
# - run: git config user.email "NEED AUTHORISED EMAIL"
# - run: git config user.name ${{ github.actor }}
# - run: npm run postinstall
# - run: npm run publish:lerna
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

# publish-gpr:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - uses: actions/setup-node@v1
# with:
# node-version: 12
# registry-url: https://npm.pkg.github.com/
# - run: npm ci
# - run: git config user.email "NEED AUTHORISED EMAIL"
# - run: git config user.name ${{ github.actor }}
# - run: npm run postinstall
# - run: npm run publish:lerna
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
This monorepo holds all packages dedicated to `@particle` packages.

[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/)

[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
## Installation

TBD
Expand All @@ -17,9 +19,9 @@ TBD
### Steps

1. Clone the repo
1. Run `npm install`, This will install all dev dependencies and run the postinstall script `lerna:install` which runs `lerna bootstrap --nohoist` and installs all package dependencies.
1. Run `npm install`, This will install all dev dependencies and run the postinstall script `lerna:install` which runs `lerna bootstrap --hoist` and installs all package dependencies.
1. If you update subdependencies, simply run `npm install` or `npm run lerna:install` to re-install lerna package dependencies. This is especially helpful when you are pulling in new code (with sub dependency additionas) from another branch.
1. `npm run build:watch` build the project in the `packages/<PACKAGE_NAME>/lib` folder, packages that do not contain a .tsconfig and do not have a `tsc` and `tsc:build` script will be ignored lerna executes packages that contain only these scripts.
1. `npm run build:watch` build the project in the `packages/<PACKAGE_NAME>/lib` folder, packages that do not contain a .tsconfig and do not have a `tsc` and `tsc:build` script will be ignored as lerna executes packages that contain only these scripts.
1. For all packages, simply execute the target file such as `node packages/particle-cli/lib/bin/particle-cli.js init` to run things, typescript must be compiled for typescript packages to execute
1. `npm run test:watch` to start jest in watch mode (recommended)

Expand Down Expand Up @@ -60,3 +62,18 @@ To remove all node_modules in packages run `npm dev:clean:node_modules`
```bash
npx lerna run --scope @phase2/particle-cli test
```

### Making a commit

Particle 11 uses [Lerna](https://github.com/lerna/lerna) in concert with [Commitizen](https://github.com/commitizen/cz-cli) to follow the [Semantic Versioning](http://semver.org/) specifications. This will allow for all of our package versions to be update automatically when they are published to their file registries.

To this end every commit should be made using ```npm run commit``` or ```npx cz```. Also consider installing [Commitizen](https://github.com/commitizen/cz-cli) globally on your machine and just using ```cz```. This will present you with a CLI to construct your commits

![](https://github.com/commitizen/cz-cli/raw/master/meta/screenshots/add-commit.png)

If you commit without using Commitizen, or have to fix a commit, follow this format:

[type](https://www.conventionalcommits.org/en/v1.0.0/) (scope/file changed, optional): message
EX: ```chore(README.md): update documentation ```

In case you make the wrong kind of commit [SEE THIS](https://www.conventionalcommits.org/en/v1.0.0/#what-do-i-do-if-i-accidentally-use-the-wrong-commit-type)
11 changes: 6 additions & 5 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"npmClient": "npm",
"version": "independent",
"packages": ["packages/*"],
"command": {
"publish": {
"ignoreChanges": ["ignored-file", "*.md"],
"message": "chore(release): publish"
"message": "chore(release): publish",
"conventionalCommits": true
},
"bootstrap": {
"npmClientArgs": ["--hoist", "--no-package-lock"]
"npmClientArgs": ["--no-package-lock"]
}
},
"packages": ["packages/*"],
"version": "independent"
}
}
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,22 @@
},
"license": "GPL-2.0",
"scripts": {
"lerna:install": "lerna bootstrap",
"lerna:install": "lerna bootstrap --hoist",
"postinstall": "npm run lerna:install; npm run build",
"pretty-check": "prettier --check packages/**/*.js",
"publish": "lerna publish --yes",
"test": "jest",
"test:watch": "jest --watch",
"build": "lerna run --concurrency 1 --scope='{@phase2/particle-types,@phase2/generator-particle-storybook,@phase2/generator-particle-base,@phase2/particle-cli}' tsc",
"dev:clean:node_modules": "lerna exec --parallel --scope='{@phase2/particle-types,@phase2/generator-particle-storybook,@phase2/generator-particle-base,@phase2/particle-cli}' 'rm -rf node_modules'",
"dev:clean:lib": "lerna exec --parallel --scope='{@phase2/particle-types,@phase2/generator-particle-storybook,@phase2/generator-particle-base,@phase2/particle-cli}' 'rm -rf lib/'",
"build:watch": "lerna run --parallel --scope='{@phase2/*,generator-*}' tsc:watch",
"update:check": "ncu && lerna exec --concurrency 1 --no-bail -- ncu",
"update:start": "npm-upgrade && lerna exec --concurrency 1 -- npm-upgrade; npm run lerna:install"
"update:start": "npm-upgrade && lerna exec --concurrency 1 -- npm-upgrade; npm run lerna:install",
"commit": "cz"
},
"dependencies": {
"commitizen": "^4.2.1",
"lerna": "^3.22.1",
"typescript": "^3.9.7"
},
Expand All @@ -44,6 +47,7 @@
"@phase2/prettier-config-particle": "./packages/prettier-config",
"@types/jest": "^26.0.8",
"@types/node": "^14.0.27",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.6.0",
"jest": "^26.2.2",
"jest-watch-typeahead": "^0.6.0",
Expand All @@ -52,5 +56,10 @@
"prettier": "2.0.5",
"ts-jest": "^26.1.4",
"ts-node": "^8.10.2"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}