Skip to content

ci: Replace regex commit checker with commitlint.#234

Merged
nedseb merged 2 commits intomainfrom
ci/commitlint-in-ci
Mar 24, 2026
Merged

ci: Replace regex commit checker with commitlint.#234
nedseb merged 2 commits intomainfrom
ci/commitlint-in-ci

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Mar 24, 2026

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

  • Local: commitlint via husky hook (conventional commits format)
  • CI: regex ^[^!]+: [A-Za-z]+.+ .+\.$ via gsactions/commit-message-checker
  • Mismatch: conventional commits (feat(scope): ...) accepted locally but rejected by CI regex

After

  • Local: commitlint via husky hook
  • CI: commitlint via npx commitlint --from base..head
  • Same commitlint.config.js used everywhere

Changes

  • .github/workflows/check-commits.yml — replaced gsactions with checkout + node + npm ci + commitlint
  • fetch-depth: 0 to access full commit history for range validation
  • Uses ${{ github.event.pull_request.base.sha }} and head.sha for precise commit range

Test plan

  • npx commitlint --from HEAD~3 --to HEAD --verbose passes locally
  • CI workflow passes on this PR

Copilot AI review requested due to automatic review settings March 24, 2026 12:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-checker steps with a checkout + Node setup + npm ci + npx commitlint run.
  • 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.

Comment thread .github/workflows/check-commits.yml Outdated
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
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/check-commits.yml Outdated
excludeDescription: "true"
checkAllCommitMessages: "true"
accessToken: ${{ secrets.GITHUB_TOKEN }}
node-version: "20"
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
node-version: "20"
node-version: "20.17.x"

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/check-commits.yml Outdated
cache: "npm"

- name: "🛠 Install commitlint"
run: npm ci
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
run: npm ci
run: npm ci --ignore-scripts

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

@nedseb nedseb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed all 3 Copilot comments (bd424ca):

  1. npx --no-install — Added to avoid fallback download.
  2. Node version 20.17.x — Pinned to match engines.node in package.json.
  3. npm ci --ignore-scripts — Skip husky install in CI (unnecessary for commit validation).

@nedseb nedseb merged commit 0f4691d into main Mar 24, 2026
3 checks passed
@nedseb nedseb deleted the ci/commitlint-in-ci branch March 24, 2026 12:41
@semantic-release-updater
Copy link
Copy Markdown

🎉 This PR is included in version 0.0.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: Harmonize commit message format between commitlint and check-commits CI.

2 participants