Skip to content

Conversation

@rm3l
Copy link
Contributor

@rm3l rm3l commented Nov 2, 2025

Description of the change

This PR enhances the pre-commit CI Workflow to automatically provide actionable feedback through PR comments in case the pre-commit hooks fail.
I initially planned to make the Workflow automatically push the pre-commit hooks diff, but ran into permission issues for PRs coming from forks.

The two-workflow approach is the recommended GitHub Actions pattern for safely commenting on PRs from forks, as it ensures untrusted code never runs with write permissions while still providing helpful feedback to contributors.

The workflow will:

  • Run on all PRs (same repo as well as fork PRs)
  • Show diffs when pre-commit hooks make changes
  • Fail the check to prevent merging
  • Keep PR conversations clean (one "Pre-commit hook"-related comment at a time)
  • Auto-cleanup comments when issues are fixed

To keep things clean, the existing lint Workflow (which used to run pre-commit) and the test workflow (used to run ct lint as well as ct install) have been reorganized:

  • lint now only runs ct lint
  • test now only runs ct install
  • [NEW] pre-commit to run only pre-commit and automatically trigger the pre-commit Comment workflow

Existing or Associated Issue(s)

Closes #288

Additional information

Example of comment and how it affects the PR: rm3l#1 (comment)

Checklist

  • Chart version bumped in Chart.yaml according to semver. (N/A - workflow changes only)
  • Variables are documented in the values.yaml and added to the README.md. (N/A - workflow changes only)
  • JSON Schema generated. (N/A - workflow changes only)
  • List tests pass for Chart using the Chart Testing tool and the ct lint command. (N/A - workflow changes only)

@rm3l rm3l force-pushed the 288-automatically-run-pre-commit-hooks-and-push-any-changes-as-part-of-the-pr-worfklows branch 11 times, most recently from 07d94c1 to db071ac Compare November 8, 2025 22:48
rm3l added 4 commits November 8, 2025 23:50
…mment on the PR what the user should do next

Ideally, we could automatically push changes to the PR branch, but this would require elevated permissions (like running in a pull_request_target trigger), which come with certain restrictions (like the fact that the PR checks will not be re-triggered on a push by the GH Actions bot)

Signed-off-by: Armel Soro <[email protected]>
@rm3l rm3l force-pushed the 288-automatically-run-pre-commit-hooks-and-push-any-changes-as-part-of-the-pr-worfklows branch from db071ac to 3655d20 Compare November 8, 2025 22:51
@rm3l rm3l changed the title ci: Comment PRs with the diff from the pre commit hooks ci: Comment PRs on with the diff from the pre-commit hooks Nov 8, 2025
@rm3l rm3l changed the title ci: Comment PRs on with the diff from the pre-commit hooks ci: Comment on PRs with the diff from the pre-commit hooks Nov 8, 2025
@rm3l rm3l marked this pull request as ready for review November 9, 2025 08:37
@rm3l rm3l requested a review from a team as a code owner November 9, 2025 08:37
@rm3l
Copy link
Contributor Author

rm3l commented Nov 9, 2025

cc @ChrisJBurns Please take a look when you get a chance. Thanks.

@ChrisJBurns ChrisJBurns merged commit 7246f09 into backstage:main Nov 9, 2025
5 checks passed
@rm3l rm3l deleted the 288-automatically-run-pre-commit-hooks-and-push-any-changes-as-part-of-the-pr-worfklows branch November 9, 2025 17:49
@vinzscam vinzscam mentioned this pull request Nov 24, 2025
4 tasks
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.

Automatically run pre-commit hooks and push any changes as part of the PR worfklows

2 participants