Skip to content

Commit

Permalink
ci(gh): add git hooks to enforce Conventional Commit structure (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
kv979w authored Jan 22, 2022
1 parent f7ca723 commit 173572a
Show file tree
Hide file tree
Showing 8 changed files with 577 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .commitlintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extends:
- '@commitlint/config-conventional'
14 changes: 14 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
name: PR Checks
on: [push, pull_request]
jobs:

# Checks that PR commits match the Conventional Commmit format
# See: https://www.conventionalcommits.org/en/v1.0.0/
commitlint:
name: Lint commit message
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v4 # See: https://github.com/wagoid/commitlint-github-action
with:
configFile: .commitlintrc.yml

install-node-modules:
name: Install node_modules
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx commitlint -e
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm test
7 changes: 7 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
npmRegistryServer: "https://registry.yarnpkg.com"
nodeLinker: "node-modules"
yarnPath: ".yarn/releases/yarn-berry.js"
packageExtensions:
# Resolves yarn 2 peer dependency conflict due to @types/node requirement set here:
# https://github.com/Codex-/cosmiconfig-typescript-loader/blob/d5ce8bb4ee75fec7efd6e73612d9fe076a844810/package.json#L34
'cosmiconfig-typescript-loader@*':
peerDependenciesMeta:
'@types/node':
optional: true
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Bundle TS types with library
- Add workflow to auto close PRs with no response from the author after 30 days
- Add workflow to close stale PRs and Issues
- Add checks via [https://www.npmjs.com/package/husky](husky) and [commit-lint](https://www.npmjs.com/package/@commitlint/cli) to validate commit messages match the [Conventional Commit specification](https://www.conventionalcommits.org/en/v1.0.0/) specification.

## 2.0.0 (November 8, 2021)

Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
"format": "prettier --write src/**/*.ts",
"format:check": "prettier --check src/**/*.ts",
"lint": "eslint src/**/*.ts",
"build:watch": "yarn build:babel --watch & yarn tsc --watch"
"build:watch": "yarn build:babel --watch & yarn tsc --watch",
"postinstall": "husky install",
"prepublishOnly": "pinst --disable",
"postpublish": "pinst --enable"
},
"author": "",
"dependencies": {
Expand Down Expand Up @@ -49,6 +52,8 @@
"@babel/plugin-proposal-object-rest-spread": "^7.14.7",
"@babel/preset-env": "^7.15.0",
"@babel/preset-typescript": "^7.16.0",
"@commitlint/cli": "^16.0.2",
"@commitlint/config-conventional": "^16.0.0",
"@types/byline": "^4.2.33",
"@types/jest": "^27.0.2",
"@types/util.promisify": "^1.0.4",
Expand All @@ -58,8 +63,10 @@
"eslint": "7.32.0",
"eslint-plugin-flowtype": "5.9.0",
"eslint-plugin-import": "2.24.0",
"husky": "^7.0.4",
"jest": "^27",
"lerna": "4.0.0",
"pinst": "^2.1.6",
"prettier": "^2.3.2",
"typescript": "^4.4.4"
},
Expand Down
Loading

0 comments on commit 173572a

Please sign in to comment.