Skip to content

Commit

Permalink
feat: Add Conventional Commits linter for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
KingMob committed Apr 23, 2024
1 parent bc5fa38 commit cf7804d
Show file tree
Hide file tree
Showing 8 changed files with 4,925 additions and 14 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/commit-linter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: commit-linter

on:
pull_request:
push:
branches: [main]

jobs:
commit-lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable

- uses: DeterminateSystems/magic-nix-cache-action@main

# - name: Setup node
# uses: actions/setup-node@v4
# with:
# node-version: 20
# cache: 'npm'

- name: Install commitlint
# run: npm install commitlint@latest
run: nix develop --command bash -c 'npm install --include=dev'

- name: Print versions
run: |
git --version
node --version
npm --version
npx commitlint --version
- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push'
# run: npx commitlint --last --verbose
run: nix develop --command bash -c '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
run: nix develop --command bash -c 'npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose'
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pom.xml.asc
/.lsp/.cache/
/node_modules/
/out/
package-lock.json
/cljs-test-runner-out/
/.direnv/
/.shadow-cljs/
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ though this should only need to happen the first time you run it.
You will see the changes to `deps.edn` reflected in `deps-lock.json`; you should commit these; and the
release build will work again.

#### Style

##### Git

This repo follows the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary)
specification for commit messages. We use the defaults, except our subject lines
are in sentence case (e.g., "This is in sentence case") and do not end in a
stop/period.

To check your most recent commit message, run `npx commitlint --from HEAD~1
--to HEAD --verbose`. If you need to change the last message, run `git commit
--amend`.

If you forget, a CI job will check it for you when you make a pull request.

#### Building a jar (portable Java application)

```shell
Expand Down
6 changes: 6 additions & 0 deletions commitlint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
extends: ['@commitlint/config-conventional'],
rules: {
'subject-case': [2, 'always', 'sentence-case']
}
};
24 changes: 12 additions & 12 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
in {
# development shell
devShells.default = pkgs.mkShell {
buildInputs = [ pkgs.openjdk21 pkgs.clojure pkgs.babashka depsCache ] ++ (basicToolsFn pkgs);
buildInputs = [ pkgs.openjdk21 pkgs.clojure pkgs.babashka pkgs.nodejs_20 depsCache ] ++ (basicToolsFn pkgs);

shellHook = ''
echo "Setting up default dev shell..."
Expand Down
Loading

0 comments on commit cf7804d

Please sign in to comment.