Skip to content
Merged
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: 23 additions & 3 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
name: Conventional Commitlint
name: Commit Linter

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

permissions:
contents: read
pull-requests: read
jobs:
commitlint:
runs-on: ubuntu-latest
Expand All @@ -13,5 +16,22 @@ jobs:
contents: read
pull-requests: read
steps:
- name: Conventional Commitlint
uses: opensource-nepal/commitlint@v1
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install commitlint
run: npm install -D @commitlint/cli @commitlint/config-conventional
- name: Print versions
run: |
git --version
node --version
npm --version
npx commitlint --version

- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ rebar3.crashdump
doc
!_index.md
guides
# don't commit the stuff required for commitlint to work
node_modules
package-lock.json
package.json
39 changes: 39 additions & 0 deletions commitlint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {
RuleConfigCondition,
RuleConfigSeverity,
TargetCaseType,
} from "@commitlint/types";

export default {
parserPreset: "conventional-changelog-conventionalcommits",
rules: {
"body-leading-blank": [RuleConfigSeverity.Warning, "always"] as const,
"body-max-line-length": [RuleConfigSeverity.Error, "always", 100] as const,
"footer-leading-blank": [RuleConfigSeverity.Warning, "always"] as const,
"footer-max-line-length": [
RuleConfigSeverity.Error,
"always",
100,
] as const,
"header-max-length": [RuleConfigSeverity.Error, "always", 100] as const,
"header-trim": [RuleConfigSeverity.Error, "always"] as const,
"subject-case": [
RuleConfigSeverity.Error,
"never",
["sentence-case", "start-case", "pascal-case", "upper-case"],
] as [RuleConfigSeverity, RuleConfigCondition, TargetCaseType[]],
"subject-empty": [RuleConfigSeverity.Error, "never"] as const,
"subject-full-stop": [RuleConfigSeverity.Error, "never", "."] as const,
"type-case": [RuleConfigSeverity.Error, "always", "lower-case"] as const,
"type-empty": [RuleConfigSeverity.Error, "never"] as const,
"type-enum": [
RuleConfigSeverity.Error,
"always",
[
"chore",
"feat",
"fix",
],
] as [RuleConfigSeverity, RuleConfigCondition, string[]],
},
};
5 changes: 5 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ changelogs:
git cliff 29b747722addf39ce40014ee1a905a973c9044be.. --include-path "${dir}/**" --workdir ${dir} -o ${dir}/CHANGELOG.md
fi
done

# lint the commits between HEAD and the point from `origin/main` this branch was created from
commit-lint:
npm install -D @commitlint/cli @commitlint/config-conventional
npx commitlint --verbose --from `git merge-base --fork-point origin/main` --to HEAD
Loading