Skip to content

Add pre-commit config for repo hygiene and secret detection - #334

Open
Harshaada wants to merge 5 commits into
redhat-data-and-ai:mainfrom
Harshaada:pre-commit-config
Open

Harshaada wants to merge 5 commits into
redhat-data-and-ai:mainfrom
Harshaada:pre-commit-config

Conversation

@Harshaada

Copy link
Copy Markdown

Changes

📝 Description

What changed?

  • Added .pre-commit-config.yaml with hygiene hooks (trailing-whitespace, end-of-file-fixer, check-yaml, detect-private-key, check-merge-conflict) and gitleaks for secret detection.
  • Updated CONTRIBUTING.md with steps to install and enable pre-commit locally.

Why is this change needed?

Contributors currently have no shared local checks for common file issues and accidental secret commits. Pre-commit gives a consistent gate before code reaches GitHub (where secret scanning / push protection can add defense in depth).

Dependencies

Local: pip install pre-commit (Go >= 1.23.8 for the gitleaks hook)


🧪 Testing

Test Coverage

  • Verified config and contribution docs locally.
  • After install, run: pre-commit run --all-files

Performance Impact

  • N/A

🚀 Deployment

Deploy Steps

  1. N/A

Prerequisites

  • N/A

Post-Deployment Monitoring

  • N/A

Rollback Plan

Revert this PR / remove .pre-commit-config.yaml if needed


⚠️ Breaking Changes

  • This PR contains breaking changes
  • Migration guide provided (if applicable)

Details:

  • N/A

⚙️ Configuration Changes

  • N/A

✅ Developer Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added positive and negative tests that prove my fix is effective or that my feature works
  • Relevant documentation (README, tech specs, etc.) has been added or updated
  • All CI/CD checks are passing

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: daef18ee-6421-454d-9aee-374b78d165ad

📥 Commits

Reviewing files that changed from the base of the PR and between a9bd3c4 and 0e0765c.

📒 Files selected for processing (2)
  • .pre-commit-config.yaml
  • CONTRIBUTING.md

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Chores

    • Added automated pre-commit checks for formatting, YAML validity, merge conflicts, exposed private keys, and leaked secrets.
    • Added automated linting and tests before commits.
  • Documentation

    • Updated contribution guidance with instructions for installing and enabling pre-commit checks.
    • Renumbered subsequent contribution workflow steps to reflect the new setup step.

Walkthrough

The repository adds a pre-commit configuration with validation, secret-scanning, lint, and test hooks. CONTRIBUTING.md documents pre-commit installation and renumbers the remaining contribution steps.

Changes

Pre-commit adoption

Layer / File(s) Summary
Hook configuration and contributor setup
.pre-commit-config.yaml, CONTRIBUTING.md
The repository adds hygiene, YAML, private-key, merge-conflict, Gitleaks, secret-check, lint, and test hooks. Contributor instructions add pre-commit installation and update the workflow step numbering.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 0e076

The documented setup preserves existing hooks and does not require contributors to install Go separately, so no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: adding a pre-commit configuration for repository hygiene and secret detection.
Description check ✅ Passed The description covers the changes, rationale, dependencies, testing, deployment, rollback, breaking changes, and checklist sections. The configuration section incorrectly states N/A despite adding `.…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

⚠️ This pull request shows signs of AI-generated slop (description_diff_mismatch, ai_padded_prose). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.


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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.pre-commit-config.yaml:
- Around line 10-14: Preserve the existing project checks by updating the
pre-commit configuration around the hooks list to run the equivalent of
scripts/check-secrets.sh and make lint test, or ensure the legacy
scripts/pre-commit chain remains invoked alongside the configured hooks. Keep
both the pre-commit hook checks and the project-specific checks active.
- Around line 23-27: Add a separate full-repository Gitleaks scan alongside the
existing gitleaks hook, using a command such as gitleaks detect --source .; keep
the current staged-change hook unchanged and ensure the new scan runs against
the entire repository rather than passed filenames.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d3e22625-e81c-41bb-8ad9-87b18e3dcd2a

📥 Commits

Reviewing files that changed from the base of the PR and between edf1baa and 8f26782.

📒 Files selected for processing (2)
  • .pre-commit-config.yaml
  • CONTRIBUTING.md

Comment thread .pre-commit-config.yaml
Comment thread .pre-commit-config.yaml
Harrshada added 3 commits August 20, 2026 17:36
Signed-off-by: Harrshada <hgaikwad@redhat.com>
Signed-off-by: Harrshada <hgaikwad@redhat.com>
Signed-off-by: Harrshada <hgaikwad@redhat.com>
Harrshada and others added 2 commits September 17, 2026 12:50
Signed-off-by: Harrshada <hgaikwad@redhat.com>
Preserve the legacy scripts/pre-commit behavior when using the
pre-commit framework so pip install does not drop project checks.

Signed-off-by: Harrshada <hgaikwad@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant