ci: Replace regex commit checker with commitlint.#234
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the commit-message validation workflow to use commitlint in CI, aligning CI validation with the existing local husky/commitlint hook (closing #231).
Changes:
- Replace the regex-based
gsactions/commit-message-checkersteps with a checkout + Node setup +npm ci+npx commitlintrun. - Fetch full git history (
fetch-depth: 0) so commitlint can validate a specific commit range. - Validate commits between PR base SHA and head SHA using the repository’s
commitlint.config.js.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| run: npm ci | ||
|
|
||
| - name: "📜 Validate commit messages" | ||
| run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose |
There was a problem hiding this comment.
To ensure this uses the repo’s installed/pinned commitlint (and fails if dependencies weren’t installed), consider adding --no-install to the npx commitlint ... invocation. This avoids npx falling back to downloading packages if the local install step changes in the future.
| run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose | |
| run: npx --no-install commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose |
| excludeDescription: "true" | ||
| checkAllCommitMessages: "true" | ||
| accessToken: ${{ secrets.GITHUB_TOKEN }} | ||
| node-version: "20" |
There was a problem hiding this comment.
actions/setup-node is configured with node-version: "20", but package.json requires Node >=20.17. If GitHub’s latest 20.x ever resolves below 20.17, npm ci will fail due to the engine check. Consider pinning to 20.17 (or 20.17.x) here to match the repo’s declared minimum and make CI deterministic.
| node-version: "20" | |
| node-version: "20.17.x" |
| cache: "npm" | ||
|
|
||
| - name: "🛠 Install commitlint" | ||
| run: npm ci |
There was a problem hiding this comment.
npm ci will run lifecycle scripts, including the repo’s prepare script (make prepare -> husky). That’s unnecessary for commitlint validation and can introduce CI flakiness/side effects. Consider running npm ci --ignore-scripts (and/or installing only commitlint) so the workflow doesn’t attempt to install git hooks during CI.
| run: npm ci | |
| run: npm ci --ignore-scripts |
nedseb
left a comment
There was a problem hiding this comment.
Addressed all 3 Copilot comments (bd424ca):
npx --no-install— Added to avoid fallback download.- Node version
20.17.x— Pinned to matchengines.nodein package.json. npm ci --ignore-scripts— Skip husky install in CI (unnecessary for commit validation).
|
🎉 This PR is included in version 0.0.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
Closes #231.
Replaces the
gsactions/commit-message-checker(regex-based) with commitlint in CI, so that local hooks and CI use the same tool and same rules.Before
^[^!]+: [A-Za-z]+.+ .+\.$via gsactions/commit-message-checkerfeat(scope): ...) accepted locally but rejected by CI regexAfter
npx commitlint --from base..headcommitlint.config.jsused everywhereChanges
.github/workflows/check-commits.yml— replaced gsactions with checkout + node + npm ci + commitlintfetch-depth: 0to access full commit history for range validation${{ github.event.pull_request.base.sha }}andhead.shafor precise commit rangeTest plan
npx commitlint --from HEAD~3 --to HEAD --verbosepasses locally