Skip to content

Commit

Permalink
ci: Add Conventional Commits linter for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
KingMob committed May 8, 2024
1 parent 927eb41 commit 27593a1
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 3 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/commit-linter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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: npm install
run: nix develop --command 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: nix develop --command npx commitlint --last --verbose

- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: nix develop --command npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
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'] // override default
}
};
6 changes: 3 additions & 3 deletions flake.lock

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

1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
buildInputs = [
discretization
pkgs.python310Packages.pytest # Adding pytest here so that developers can run the tests.
pkgs.nodejs_20 # To run commitlint
];
};
packages.default = discretization;
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"devDependencies": {
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2"
}
}

0 comments on commit 27593a1

Please sign in to comment.