Skip to content

Conversation

@kolipakakondal
Copy link
Collaborator

@kolipakakondal kolipakakondal commented Oct 9, 2025

  • Add commit message validation using conventional-precommit-linter
  • Update GitHub Actions to latest versions (checkout@v4, setup-python@v4)
  • Add comprehensive error messages with ESP-IDF specific examples
  • Remove unnecessary file-based pre-commit hooks for Java/Maven project
  • Focus workflow on commit message validation only

Description

Please include a summary of the change and which issue is fixed.

Fixes # (IEP-XXX)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How has this been tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Configuration:

  • ESP-IDF Version:
  • OS (Windows,Linux and macOS):

Dependent components impacted by this PR:

  • Component 1
  • Component 2

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Added Documentation
  • Added Unit Test
  • Verified on all platforms - Windows,Linux and macOS

Summary by CodeRabbit

  • Chores
    • Updated CI to newer GitHub Actions versions for improved reliability.
    • Enabled full commit history fetch in CI to support multi-commit checks.
    • Replaced generic pre-commit run with per-commit conventional commit message validation.
    • Renamed and clarified the CI check to reflect conventional commit enforcement.
    • Added detailed, aggregated failure reporting with examples and remediation guidance.

- Add commit message validation using conventional-precommit-linter
- Update GitHub Actions to latest versions (checkout@v4, setup-python@v4)
- Add comprehensive error messages with ESP-IDF specific examples
- Remove unnecessary file-based pre-commit hooks for Java/Maven project
- Focus workflow on commit message validation only
@coderabbitai
Copy link

coderabbitai bot commented Oct 9, 2025

Walkthrough

Updates the pre-commit GitHub Actions workflow: bumps actions/checkout to @v4 and actions/setup-python to @v5, sets fetch-depth: 0, and replaces a single pre-commit run with a per-commit "Validate commit messages" step that enumerates commits (PR: base..head; otherwise latest), runs conventional-precommit-linter via pre-commit on each message, aggregates failures, and fails with guidance.

Changes

Cohort / File(s) Summary
CI workflow updates
.github/workflows/pre-commit.yml
Upgrade actions/checkout to @v4 with fetch-depth: 0; upgrade actions/setup-python to @v5. Replace blanket pre-commit run with a “Validate commit messages” script that computes commits (PR: base..head; else latest), writes each message to a temp file, runs the commit-msg hook via pre-commit using conventional-precommit-linter, aggregates failures, prints detailed remediation and examples, and exits non-zero on any failure.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant GH as GitHub Actions
  participant CO as actions/checkout@v4
  participant PY as actions/setup-python@v5
  participant Runner as Job Runner
  participant Validator as Validate Commit Msgs
  participant PC as pre-commit
  participant Linter as conventional-precommit-linter

  Dev->>GH: push / pull_request
  GH->>CO: Checkout repo (fetch-depth: 0)
  GH->>PY: Setup Python (@v5)
  GH->>Runner: start job
  Runner->>Validator: run "Validate commit messages"
  alt pull_request
    Validator->>GH: determine commits between base..head
  else other events
    Validator->>GH: use latest commit only
  end
  loop for each commit
    Validator->>Validator: extract message, write temp file
    Validator->>PC: invoke commit-msg hook with temp file
    PC->>Linter: run conventional-precommit-linter
    Linter-->>PC: pass/fail
    PC-->>Validator: hook status
  end
  alt any failures
    Validator-->>Runner: output failure details + remediation, exit non-zero
  else all pass
    Validator-->>Runner: succeed
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • sigmaaa
  • alirana01

Poem

Thump-thump, I check each message with care,
From base to head I hop through the air.
Lint one by one, neat titles I seek,
Pass with a twirl, fail — I nudge and I squeak.
Fix the line, commit again — hooray! 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly states that the pull request improves the pre-commit workflow by adding commit message validation, which matches the main change of integrating the conventional-precommit-linter hook. It is concise, specific, and highlights the primary purpose of the update without extra noise.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch IEP-1643

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 230853a and de6af6a.

📒 Files selected for processing (1)
  • .github/workflows/pre-commit.yml (2 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/pre-commit.yml

18-18: the runner of "actions/setup-python@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build_windows
  • GitHub Check: build

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between de6af6a and 53af12e.

📒 Files selected for processing (1)
  • .github/workflows/pre-commit.yml (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: build
  • GitHub Check: build_macos
  • GitHub Check: build_windows

Comment on lines +27 to +33
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
COMMITS=$(git log --oneline $BASE_SHA..$HEAD_SHA)
else
COMMITS=$(git log --oneline -1)
fi
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Ensure commit collection fails fast when the range is missing.

If git log cannot resolve ${{ github.event.pull_request.head.sha }} (common for forked PRs unless we fetch the head ref), the command exits 128 but still assigns an empty string to COMMITS, so the loop never runs and every commit slips past validation. Please fail fast when the log command errors (and likewise in the non-PR branch) so we never treat “couldn’t fetch commits” as “all commits valid”.

-          COMMITS=$(git log --oneline $BASE_SHA..$HEAD_SHA)
+          if ! COMMITS=$(git log --oneline "${BASE_SHA}..${HEAD_SHA}"); then
+            echo "Failed to list commits between ${BASE_SHA} and ${HEAD_SHA}. Did we fetch the head ref?" >&2
+            exit 1
+          fi
@@
-          COMMITS=$(git log --oneline -1)
+          if ! COMMITS=$(git log --oneline -1); then
+            echo "Failed to read the latest commit." >&2
+            exit 1
+          fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
COMMITS=$(git log --oneline $BASE_SHA..$HEAD_SHA)
else
COMMITS=$(git log --oneline -1)
fi
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
if ! COMMITS=$(git log --oneline "${BASE_SHA}..${HEAD_SHA}"); then
echo "Failed to list commits between ${BASE_SHA} and ${HEAD_SHA}. Did we fetch the head ref?" >&2
exit 1
fi
else
if ! COMMITS=$(git log --oneline -1); then
echo "Failed to read the latest commit." >&2
exit 1
fi
fi
🤖 Prompt for AI Agents
.github/workflows/pre-commit.yml around lines 27 to 33: the git log commands
that populate COMMITS can fail (exit 128) and leave COMMITS empty which causes
the script to silently accept no commits; change the logic to fail fast when git
log errors by checking the git log exit status and exiting the workflow with a
non-zero code if it fails (or use a shell option like set -e), e.g., run git log
into a temporary variable and if the command returns non-zero, echo an error and
exit 1, otherwise assign COMMITS to that output; apply the same check in both
the pull_request and non-PR branches.

@kolipakakondal kolipakakondal merged commit 14d4fd1 into master Oct 9, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants