From a3fbb6ef978f084f1ef12d1a87df578fdb889305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20Kivim=C3=A4ki?= Date: Thu, 5 Sep 2024 14:11:29 +0300 Subject: [PATCH] ci: add commit linter --- .commitlintrc.js | 3 +++ .github/workflows/lint.yml | 29 ++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 .commitlintrc.js diff --git a/.commitlintrc.js b/.commitlintrc.js new file mode 100644 index 00000000..b29b5ae8 --- /dev/null +++ b/.commitlintrc.js @@ -0,0 +1,3 @@ +export default { + extends: ["@commitlint/config-conventional"], +}; diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a30ba968..7d1a97b6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,6 +1,7 @@ name: Lint on: + push: pull_request: workflow_call: @@ -13,9 +14,35 @@ jobs: - uses: actions/setup-go@v5 with: go-version: "1.22" - cache: false + cache: false # Disable cache since golangci-lint does its own caching - name: Lint source code uses: golangci/golangci-lint-action@v4 with: version: latest + + commitlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: lts/* + + - name: Install commitlint + run: | + npm install conventional-changelog-conventionalcommits + npm install commitlint@latest + + - 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