From 5fa0615de6f12accfb14425ebe77785eba591ab9 Mon Sep 17 00:00:00 2001 From: IMGoodrich Date: Thu, 17 Sep 2020 12:48:33 -0700 Subject: [PATCH 1/7] ci(.github/workflows): add initial github actions workflow files --- lerna.json | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lerna.json b/lerna.json index 0b88bf2270..e263fb4e81 100644 --- a/lerna.json +++ b/lerna.json @@ -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" + } } From d279709be656dd157fb4028874ce26c5c656e898 Mon Sep 17 00:00:00 2001 From: IMGoodrich Date: Thu, 17 Sep 2020 12:49:30 -0700 Subject: [PATCH 2/7] build(lerna.json): update lerna.json config file --- .github/workflows/node.yml | 26 +++++++++++++ .github/workflows/pr-commit-lint.yml | 14 +++++++ .github/workflows/publish.yml | 58 ++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 .github/workflows/node.yml create mode 100644 .github/workflows/pr-commit-lint.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml new file mode 100644 index 0000000000..438528c776 --- /dev/null +++ b/.github/workflows/node.yml @@ -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 ci + - run: npm run build --if-present + - run: npm test diff --git a/.github/workflows/pr-commit-lint.yml b/.github/workflows/pr-commit-lint.yml new file mode 100644 index 0000000000..11710d7c4e --- /dev/null +++ b/.github/workflows/pr-commit-lint.yml @@ -0,0 +1,14 @@ +name: Linters + +on: [pull_request] + +jobs: + validate-commits: + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Commitsar check + uses: docker://aevea/commitsar diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000000..c1c0d87c76 --- /dev/null +++ b/.github/workflows/publish.yml @@ -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: [ main ] +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}} From ac2cec2b75935268800ec0cba4d16da00906ab72 Mon Sep 17 00:00:00 2001 From: IMGoodrich Date: Thu, 17 Sep 2020 12:50:43 -0700 Subject: [PATCH 3/7] build(package.json): add commitizen, and update scripts --- package.json | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b97fd701c2..7791242be7 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,10 @@ }, "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", @@ -33,9 +34,11 @@ "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" }, @@ -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", @@ -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" + } } } From 78e13a67a60136d0d9ad05e208de17fa0f625f26 Mon Sep 17 00:00:00 2001 From: IMGoodrich Date: Thu, 17 Sep 2020 12:51:18 -0700 Subject: [PATCH 4/7] docs(readme.md): update README.md --- README.md | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3e936be4f9..11d253cf73 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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//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//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) @@ -60,3 +62,19 @@ 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) + +On the CI we are also using [Commistar](https://commitsar.tech/) (see .github/workflows/pr-commit-lint.yml) which will check your commits to make sure they all adhere to semvar specs. 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 ``` + +Currently Commistar will not prevent you from merging pull requests if all of you commits do not adhere to the specification. From 902b5625c10d30c0ad4bb415c1ce8b4496257952 Mon Sep 17 00:00:00 2001 From: IMGoodrich Date: Thu, 17 Sep 2020 15:49:52 -0700 Subject: [PATCH 5/7] ci(pr-commit-lint.yml): removed due to buggy performance --- .github/workflows/pr-commit-lint.yml | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .github/workflows/pr-commit-lint.yml diff --git a/.github/workflows/pr-commit-lint.yml b/.github/workflows/pr-commit-lint.yml deleted file mode 100644 index 11710d7c4e..0000000000 --- a/.github/workflows/pr-commit-lint.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Linters - -on: [pull_request] - -jobs: - validate-commits: - runs-on: ubuntu-latest - steps: - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Commitsar check - uses: docker://aevea/commitsar From bb60e76ea4c350c225581ba8830ac0a6b7a28d10 Mon Sep 17 00:00:00 2001 From: IMGoodrich Date: Thu, 17 Sep 2020 15:50:50 -0700 Subject: [PATCH 6/7] docs(readme.md): update README.md to reflect removal of commit linter --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 11d253cf73..1504cfad5b 100644 --- a/README.md +++ b/README.md @@ -71,10 +71,9 @@ To this end every commit should be made using ```npm run commit``` or ```npx cz` ![](https://github.com/commitizen/cz-cli/raw/master/meta/screenshots/add-commit.png) -On the CI we are also using [Commistar](https://commitsar.tech/) (see .github/workflows/pr-commit-lint.yml) which will check your commits to make sure they all adhere to semvar specs. If you commit without using Commitizen, or have to fix a commit, follow this format: - +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 ``` -Currently Commistar will not prevent you from merging pull requests if all of you commits do not adhere to the specification. +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) From cd86289d7234c4c5311b2da893c828e90187df63 Mon Sep 17 00:00:00 2001 From: IMGoodrich Date: Thu, 17 Sep 2020 15:53:43 -0700 Subject: [PATCH 7/7] ci: update publish target branch to eleven, comment out all of publish to prevent accidental use --- .github/workflows/node.yml | 2 +- .github/workflows/publish.yml | 70 +++++++++++++++++------------------ 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 438528c776..62bfc7a445 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -21,6 +21,6 @@ jobs: uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - - run: npm ci + - run: npm i - run: npm run build --if-present - run: npm test diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c1c0d87c76..5172a98704 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,41 +1,41 @@ # 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: [ main ] -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}} +#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