Skip to content

Commit fbeeb61

Browse files
mahlau-flexyaugenst-flex
authored andcommitted
feat: added commitlint pipeline
1 parent 75fd628 commit fbeeb61

File tree

3 files changed

+72
-1
lines changed

3 files changed

+72
-1
lines changed

.commitlintrc.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"rules": {
3+
"header-min-length": [2, "always", 12],
4+
"header-max-length": [2, "always", 72],
5+
"footer-max-line-length": [2, "always", 72],
6+
"type-empty": [2, "never"],
7+
"type-enum": [2, "always", [
8+
"feat",
9+
"fix",
10+
"docs",
11+
"style",
12+
"refactor",
13+
"perf",
14+
"test",
15+
"build",
16+
"ci",
17+
"chore",
18+
"revert"
19+
]],
20+
"body-max-line-length": [2, "always", 72],
21+
"scope-case": [2, "always", "lower-case"]
22+
}
23+
}

.github/workflows/tidy3d-python-client-tests.yml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,41 @@ jobs:
159159
run: ruff format --check --diff
160160
- name: Run ruff check
161161
run: ruff check tidy3d
162+
163+
lint-commit-messages:
164+
needs: determine-test-scope
165+
runs-on: ubuntu-latest
166+
name: veryify-commit-linting
167+
steps:
168+
- name: Check out source code
169+
uses: actions/checkout@v4
170+
with:
171+
fetch-depth: 0 # fetch all commits in the PR
172+
173+
- name: Setup node
174+
uses: actions/setup-node@v4
175+
with:
176+
node-version: lts/*
177+
178+
- name: Install commitlint
179+
run: npm install -D @commitlint/cli @commitlint/config-conventional
180+
181+
- name: Print versions
182+
run: |
183+
git --version
184+
node --version
185+
npm --version
186+
npx commitlint --version
187+
188+
- name: Check commit messages (merge_group)
189+
if: github.event_name == 'merge_group'
190+
run: |
191+
# For merge groups, check the commits being merged
192+
npx commitlint --from ${{ github.event.merge_group.base_sha }} --to ${{ github.event.merge_group.head_sha }} --verbose || {
193+
echo "Commit message linting failed; please follow the conventional commits format at https://www.conventionalcommits.org/"
194+
exit 1
195+
}
196+
162197

163198
verify-schema-change:
164199
name: verify-schema-change
@@ -480,7 +515,7 @@ jobs:
480515
(( needs.determine-test-scope.outputs.pr_approval_state == 'true' ) &&
481516
( needs.determine-test-scope.outputs.local_tests == 'true' ) ||
482517
( needs.determine-test-scope.outputs.remote_tests == 'true' ))
483-
needs: [local-tests, remote-tests, lint, verify-schema-change]
518+
needs: [local-tests, remote-tests, lint, verify-schema-change, lint-commit-messages]
484519
runs-on: ubuntu-latest
485520
steps:
486521
- name: check-passing-remote-tests
@@ -502,5 +537,8 @@ jobs:
502537
elif [[ "${{ needs.determine-test-scope.outputs.pr_approval_state }}" == 'true' && github.event.pull_request ]]; then
503538
echo "❌ PR requires approval."
504539
exit 1
540+
elif [[ github.event_name == 'merge_group' && "${{ needs.lint-commit-messages.result }}" != 'success' ]]; then
541+
echo "❌ Linting of commit messages failed or was skipped."
542+
exit 1
505543
fi
506544
echo "✅ All required test jobs passed!"

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1+
default_install_hook_types:
2+
- pre-commit
3+
- commit-msg
14
repos:
25
- repo: https://github.com/astral-sh/ruff-pre-commit
36
rev: "v0.11.11"
47
hooks:
58
- id: ruff-check
69
args: [ --fix ]
710
- id: ruff-format
11+
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
12+
rev: v9.22.0
13+
hooks:
14+
- id: commitlint
15+
stages: [commit-msg]
16+
verbose: true
17+
entry: bash -c 'commitlint --edit || exit 0'
818

0 commit comments

Comments
 (0)