Skip to content

Commit

Permalink
feat: add commit lint to the project
Browse files Browse the repository at this point in the history
  • Loading branch information
jorilindell committed Apr 29, 2024
1 parent ffdca65 commit 4e6e2df
Show file tree
Hide file tree
Showing 6 changed files with 550 additions and 7 deletions.
26 changes: 26 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"extends": ["@commitlint/config-conventional"],
"rules": {
"header-max-length": [2, "always", 72],
"body-max-line-length": [2, "always", 72],
"body-leading-blank": [2, "always"],
"type-enum": [
2,
"always",
[
"build",
"chore",
"ci",
"deps",
"docs",
"feat",
"fix",
"perf",
"refactor",
"revert",
"style",
"test"
]
]
}
}
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: linkedregistrations-ui-ci

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Install commitlint
run: |
yarn add @commitlint/config-conventional
yarn add @commitlint/cli
- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push'
run: npx commitlint --last --verbose

- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn commitlint --edit $1
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ e.g. https://linkedregistrations-ui.test.kuva.hel.ninja/fi/registration/22/signu

This parameter can be used to redirect user automatically to selected url after successful signup. It's important to include also protocol to the url.

## Commit message format

New commit messages must adhere to the [Conventional Commits](https://www.conventionalcommits.org/)
specification, and line length is limited to 72 characters.

[`commitlint`](https://github.com/conventional-changelog/commitlint) checks new commit messages for the correct format.

## Available Scripts

In the project directory, you can run:
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build": "next build",
"start": "next start -p 3001",
"lint": "next lint",
"prepare": "husky",
"test": "TZ=UTC jest --watch",
"test:coverage": "TZ=UTC jest --testResultsProcessor=\"./node_modules/jest-junit\" --coverage --watchAll=false",
"test:e2e:install": "npx playwright install",
Expand Down Expand Up @@ -43,6 +44,8 @@
"yup": "^1.4.0"
},
"devDependencies": {
"@commitlint/cli": "^19.2.2",
"@commitlint/config-conventional": "^19.2.2",
"@faker-js/faker": "^8.4.1",
"@playwright/test": "^1.42.1",
"@swc/core": "^1.4.8",
Expand All @@ -57,6 +60,7 @@
"eslint-config-next": "14.1.3",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^27.9.0",
"husky": "^9.0.11",
"jest": "^29.7.0",
"jest-axe": "^8.0.0",
"jest-date-mock": "^1.0.8",
Expand Down
Loading

0 comments on commit 4e6e2df

Please sign in to comment.