-
Notifications
You must be signed in to change notification settings - Fork 1
Add pre-commit configuration file compatible with Trunk.io #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Merging to
|
Running Code Quality on PRs by uploading data to Trunk will soon be removed. You can still run checks on your PRs using trunk-action - see the migration guide for more information. |
Co-authored-by: brendancsmith <[email protected]>
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.12" | ||
- uses: pre-commit/[email protected] |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 days ago
To fix the problem, you should add a permissions
block that restricts the GITHUB_TOKEN
permissions to the minimum required. For most pre-commit/CHECK-type jobs that only need to read repository code, setting permissions: contents: read
suffices, unless the workflow specifically needs to write to pull requests or issues (which it does not appear to from the provided actions). The recommended approach is to add this permissions
block at the workflow level (just after the name:
and before on:
), so it applies to all jobs unless otherwise specified. You should insert:
permissions:
contents: read
at line 3, pushing the on:
and subsequent lines down. No import or variable definition is necessary; just a change to the YAML structure.
-
Copy modified lines R3-R4
@@ -1,5 +1,7 @@ | ||
# Workflow for running pre-commit checks | ||
name: Pre-commit | ||
permissions: | ||
contents: read | ||
|
||
on: | ||
pull_request: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overview
This PR adds a comprehensive
.pre-commit-config.yaml
file that integrates seamlessly with the existing Trunk.io setup in the repository. Pre-commit hooks provide automated code quality checks before commits, helping maintain consistent code standards across contributions.What's Included
1. Pre-commit Configuration (
.pre-commit-config.yaml
)A fully configured pre-commit setup with 6 repositories and 16 hooks:
Python Tools:
Code Formatting:
.trunk/configs/.yamllint.yaml
.trunk/configs/.markdownlint.yaml
Standard Checks (v5.0.0):
2. GitHub Actions Workflow (
.github/workflows/pre-commit.yml
)Automated pre-commit checks run on:
This ensures code quality standards are maintained in CI/CD pipelines.
3. Documentation Updates
Added a comprehensive "Development Setup" section to
CONTRIBUTING.md
with:Trunk.io Compatibility
This configuration is designed to work alongside Trunk.io, not replace it:
✅ Hook versions match those in
.trunk/trunk.yaml
✅ Reuses existing Trunk configuration files
✅ Properly excludes test cassettes from linting
✅ TruffleHog and Commitlint commented out (handled by Trunk.io actions)
✅ Compatible with existing Trunk.io pre-commit and pre-push actions
Usage
Contributors can enable pre-commit hooks with:
Hooks will automatically run on every commit. Manual runs are also supported:
Benefits
Closes #[issue_number]
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.