Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 13, 2025

When pre-commit checks fail on a PR, contributors receive no actionable guidance. This adds an automated comment with fix instructions.

Changes

Modified .github/workflows/ci-cd.yml pre-commit job:

  • Added step tracking (id: pre-commit) and continue-on-error: true to capture failure state
  • Added conditional step that posts comment on PR when steps.pre-commit.outcome == 'failure'
  • Comment includes installation instructions, local fix commands (pre-commit run --all-files), and setup tip (pre-commit install)
  • Added explicit failure step to preserve failed job status for PR checks

The workflow now provides immediate, actionable feedback while maintaining the failed status indicator on the PR.

- name: Run pre-commit
  id: pre-commit
  uses: pre-commit/[email protected]
  continue-on-error: true
- name: Comment on PR if pre-commit fails
  if: github.event_name == 'pull_request' && steps.pre-commit.outcome == 'failure'
  uses: actions/github-script@v7
  # ... posts helpful comment with fix instructions
- name: Fail the job if pre-commit failed
  if: steps.pre-commit.outcome == 'failure'
  run: exit 1
Original prompt

for the github actions if the pre-commit doesn't pass add a comment to the PR with the output and instructions on how to run the pre-commit to fix it


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 13, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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

Copilot AI changed the title [WIP] Add comment on PR for pre-commit failure Add automated PR comment on pre-commit failure with fix instructions Nov 13, 2025
Copilot AI requested a review from DonnieBLT November 13, 2025 15:48
@github-actions github-actions bot added files-changed: 1 and removed files-changed: 0 PR changes 0 files labels Nov 15, 2025
@DonnieBLT DonnieBLT marked this pull request as ready for review November 15, 2025 20:14
@github-actions
Copy link
Contributor

❌ Pre-commit checks failed

The pre-commit hooks found issues that need to be fixed. Please run the following commands locally to fix them:

# Install pre-commit if you haven't already
pip install pre-commit

# Run pre-commit on all files
pre-commit run --all-files

# Or run pre-commit on staged files only
pre-commit run

After running these commands, the pre-commit hooks will automatically fix most issues.
Please review the changes, commit them, and push to your branch.

💡 Tip: You can set up pre-commit to run automatically on every commit by running:

pre-commit install

For more information, see the pre-commit documentation.

@DonnieBLT DonnieBLT merged commit 3928983 into main Nov 16, 2025
18 of 20 checks passed
@DonnieBLT DonnieBLT deleted the copilot/add-comment-on-pre-commit-failure branch November 16, 2025 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants