ci: enforce conventional commits with commitlint and husky#454
ci: enforce conventional commits with commitlint and husky#454ericksoa merged 10 commits intoNVIDIA:mainfrom
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe pull request introduces commit message linting infrastructure by adding Husky hooks for local validation and a GitHub Actions workflow for continuous integration checks. Configuration files for Commitlint and package dependencies are also added to enforce conventional commit formats. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/pr.yaml:
- Line 8: The workflow enables the pull_request "edited" trigger but the
existing commitlint step (the commit range lint on the step that currently uses
the commit range logic referenced around line 37) only lints commits and thus
misses PR title edits; update the job to also lint the PR title when
github.event.pull_request is present by adding or modifying the commitlint step
to run against github.event.pull_request.title (e.g., invoke commitlint CLI or
the existing action with the PR title input) whenever the workflow was triggered
by an edited PR, so both commit messages and PR title edits are validated.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c6d3ae9e-537d-4d9c-afb4-c174934c327f
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (4)
.github/workflows/pr.yaml.husky/commit-msgcommitlint.config.jspackage.json
|
Review comments:
|
- Skip test jobs on edited events to avoid unnecessary CI runs - Quote $1 in husky commit-msg hook for paths with spaces - Use npm ci --ignore-scripts in lint job for faster, cleaner installs
|
All three addressed in 2bd485c — added |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/pr.yaml:
- Around line 39-40: The workflow step "Lint PR title (squash-merge path)"
currently expands github.event.pull_request.title directly into the run string
which can lead to shell injection; change it to pass the PR title via an env var
(e.g., PR_TITLE: ${{ github.event.pull_request.title }}) and read that var
inside the run command (use a quoted variable like echo "$PR_TITLE" | npx
commitlint --verbose) so the title is not shell-interpolated.
- Line 8: The workflow-level concurrency is cancelling running test runs when an
`edited` PR event triggers (because `types: [opened, synchronize, reopened,
edited]` is evaluated before job-level `if:` conditions), so either extract the
commit-lint step into its own workflow that uses `on: pull_request: types:
[edited]` or change the concurrency grouping for metadata-only runs by using a
different concurrency key for the job that runs on `edited` (so it does not
share the same workflow-level concurrency as the test jobs); update
.github/workflows/pr.yaml to implement one of these: create a new workflow file
for commit-lint bound to `edited` or modify the existing workflow’s
`concurrency` key to be conditional (or use a separate key) for the
metadata/commit-lint path so in-flight `synchronize`/`reopened` runs are not
cancelled.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: bb601617-1d85-4890-b2bc-702aa5983397
📒 Files selected for processing (1)
.github/workflows/pr.yaml
Move commit-lint job to its own workflow file to prevent the `edited` trigger from cancelling in-flight test runs via the shared concurrency group. Also fix shell injection vulnerability by passing PR title through an env var instead of inline interpolation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/commit-lint.yaml (1)
36-38: Consider using environment variables for SHAs for consistency.While SHA values are inherently safe (hex-only strings from GitHub), using environment variables would be consistent with how
PR_TITLEis handled below and aligns with the general best practice of avoiding direct${{ }}interpolation inrun:commands.♻️ Optional: Pass SHAs via environment variables
- name: Lint commits if: github.event.action != 'edited' - run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose + env: + BASE_SHA: ${{ github.event.pull_request.base.sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: npx commitlint --from "$BASE_SHA" --to "$HEAD_SHA" --verbose🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/commit-lint.yaml around lines 36 - 38, Replace direct github expression interpolation in the run step with environment variables: define FROM_SHA and TO_SHA in the step's env using ${{ github.event.pull_request.base.sha }} and ${{ github.event.pull_request.head.sha }} (mirroring how PR_TITLE is handled), and update the run invocation of npx commitlint to use --from $FROM_SHA and --to $TO_SHA so the SHAs are passed consistently via env vars.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/workflows/commit-lint.yaml:
- Around line 36-38: Replace direct github expression interpolation in the run
step with environment variables: define FROM_SHA and TO_SHA in the step's env
using ${{ github.event.pull_request.base.sha }} and ${{
github.event.pull_request.head.sha }} (mirroring how PR_TITLE is handled), and
update the run invocation of npx commitlint to use --from $FROM_SHA and --to
$TO_SHA so the SHAs are passed consistently via env vars.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: bc31bac9-545f-4f87-bbdc-9a27ca67b3a2
📒 Files selected for processing (1)
.github/workflows/commit-lint.yaml
…onal-commits # Conflicts: # package.json
The lock file was generated with npm 11 (Node 25) which omits optional peer dependency entries that npm 10 (Node 22, used in CI) requires. Regenerating with npm 10 adds the missing opusscript@0.0.8 entries. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ericksoa
left a comment
There was a problem hiding this comment.
Clean setup. Types match CONTRIBUTING.md, shell injection is handled via env vars, and the separate workflow avoids cancelling test runs on title edits.
Verified the prepare script change doesn't break any install path — install.sh uses --ignore-scripts, CI has explicit build steps, and CONTRIBUTING.md already documents a separate build step.
* ci: enforce conventional commits with commitlint and husky * ci: lint PR title in addition to commit messages * ci: address review feedback - Skip test jobs on edited events to avoid unnecessary CI runs - Quote $1 in husky commit-msg hook for paths with spaces - Use npm ci --ignore-scripts in lint job for faster, cleaner installs * ci: add PR title linting for squash-merge path Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ci: trigger workflow re-run * ci: split commit-lint into separate workflow Move commit-lint job to its own workflow file to prevent the `edited` trigger from cancelling in-flight test runs via the shared concurrency group. Also fix shell injection vulnerability by passing PR title through an env var instead of inline interpolation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ci): regenerate package-lock.json for Node 22 compatibility The lock file was generated with npm 11 (Node 25) which omits optional peer dependency entries that npm 10 (Node 22, used in CI) requires. Regenerating with npm 10 adds the missing opusscript@0.0.8 entries. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ci: pass commit SHAs through env vars in commit-lint workflow Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* ci: enforce conventional commits with commitlint and husky * ci: lint PR title in addition to commit messages * ci: address review feedback - Skip test jobs on edited events to avoid unnecessary CI runs - Quote $1 in husky commit-msg hook for paths with spaces - Use npm ci --ignore-scripts in lint job for faster, cleaner installs * ci: add PR title linting for squash-merge path Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ci: trigger workflow re-run * ci: split commit-lint into separate workflow Move commit-lint job to its own workflow file to prevent the `edited` trigger from cancelling in-flight test runs via the shared concurrency group. Also fix shell injection vulnerability by passing PR title through an env var instead of inline interpolation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ci): regenerate package-lock.json for Node 22 compatibility The lock file was generated with npm 11 (Node 25) which omits optional peer dependency entries that npm 10 (Node 22, used in CI) requires. Regenerating with npm 10 adds the missing opusscript@0.0.8 entries. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ci: pass commit SHAs through env vars in commit-lint workflow Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
Enforce the conventional commit format documented in
CONTRIBUTING.md.Client-side (Husky + commitlint)
@commitlint/cliand@commitlint/config-conventionalas dev dependencies.commitlint.config.jswith the 8 allowed types from CONTRIBUTING.md (feat,fix,docs,chore,refactor,test,ci,perf).commit-msghook that rejects non-conforming commits locally.CI-side (GitHub Actions)
commit-lint.yamlworkflow (separate frompr.yamlto avoid cancelling in-flight test runs via the shared concurrency group).opened/synchronize/reopenedevents.edited(relevant for squash-merge workflows where the PR title becomes the commit message).Files changed
package.json/package-lock.json— new dev dependencies +preparescriptcommitlint.config.js— new.husky/commit-msg— new.github/workflows/commit-lint.yaml— new workflow.github/workflows/pr.yaml— removeeditedtrigger (no longer needed here)Test plan
commit-lintjob passes on conforming commitscommit-lintjob fails on a non-conventional commit message🤖 Generated with Claude Code