-
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
Open
Copilot
wants to merge
3
commits into
main
Choose a base branch
from
copilot/add-precommit-yaml-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Workflow for running pre-commit checks | ||
| name: Pre-commit | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| pre-commit: | ||
| 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 on line 17 in .github/workflows/pre-commit.yml
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| # Pre-commit configuration file compatible with Trunk.io | ||
| # See https://pre-commit.com for more information | ||
| # See https://docs.trunk.io/check for Trunk.io integration | ||
|
|
||
| default_language_version: | ||
| python: python3.12 | ||
|
|
||
| repos: | ||
| # Ruff - Python linter and formatter (replaces Black, isort, flake8, etc.) | ||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.4.1 | ||
| hooks: | ||
| - id: ruff | ||
| args: [--fix, --exit-non-zero-on-fix] | ||
| - id: ruff-format | ||
|
|
||
| # Prettier - Code formatter for YAML, JSON, Markdown, etc. | ||
| - repo: https://github.com/pre-commit/mirrors-prettier | ||
| rev: v3.1.0 | ||
| hooks: | ||
| - id: prettier | ||
| types_or: [yaml, markdown, json] | ||
|
|
||
| # Standard pre-commit hooks | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v5.0.0 | ||
| hooks: | ||
| - id: check-added-large-files | ||
| args: [--maxkb=1000] | ||
| - id: check-case-conflict | ||
| - id: check-merge-conflict | ||
| - id: check-yaml | ||
| args: [--unsafe] # Allow custom YAML tags | ||
| exclude: ^tests/functional/.*/cassettes/.*\.yaml$ | ||
| - id: check-json | ||
| - id: check-toml | ||
| - id: end-of-file-fixer | ||
| exclude: ^tests/functional/.*/cassettes/.*\.yaml$ | ||
| - id: trailing-whitespace | ||
| exclude: ^tests/functional/.*/cassettes/.*\.yaml$ | ||
| - id: mixed-line-ending | ||
| - id: detect-private-key | ||
|
|
||
| # yamllint - YAML linter | ||
| - repo: https://github.com/adrienverge/yamllint | ||
| rev: v1.35.1 | ||
| hooks: | ||
| - id: yamllint | ||
| args: [-c, .trunk/configs/.yamllint.yaml] | ||
| exclude: ^tests/functional/.*/cassettes/.*\.yaml$ | ||
|
|
||
| # markdownlint - Markdown linter | ||
| - repo: https://github.com/igorshubovych/markdownlint-cli | ||
| rev: v0.39.0 | ||
| hooks: | ||
| - id: markdownlint | ||
| args: [-c, .trunk/configs/.markdownlint.yaml] | ||
|
|
||
| # Bandit - Python security linter | ||
| - repo: https://github.com/PyCQA/bandit | ||
| rev: 1.7.8 | ||
| hooks: | ||
| - id: bandit | ||
| args: [-c, .trunk/configs/bandit.yaml, -r, .] | ||
| exclude: ^tests/ | ||
|
|
||
| # TruffleHog - Secret scanning (Trunk.io handles this via trufflehog-pre-commit action) | ||
| # To enable, uncomment the following: | ||
| # - repo: https://github.com/trufflesecurity/trufflehog | ||
| # rev: v3.74.0 | ||
| # hooks: | ||
| # - id: trufflehog | ||
| # args: | ||
| # - git | ||
| # - file://. | ||
| # - --since-commit | ||
| # - HEAD | ||
| # - --only-verified | ||
| # - --fail | ||
|
|
||
| # Commitlint - Commit message linting (Trunk.io handles this via commitlint action) | ||
| # To enable, uncomment and run: pre-commit install --hook-type commit-msg | ||
| # - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook | ||
| # rev: v9.16.0 | ||
| # hooks: | ||
| # - id: commitlint | ||
| # stages: [commit-msg] | ||
| # additional_dependencies: ["@commitlint/config-conventional"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI about 1 month ago
To fix the problem, you should add a
permissionsblock that restricts theGITHUB_TOKENpermissions to the minimum required. For most pre-commit/CHECK-type jobs that only need to read repository code, settingpermissions: contents: readsuffices, 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 thispermissionsblock at the workflow level (just after thename:and beforeon:), so it applies to all jobs unless otherwise specified. You should insert:at line 3, pushing the
on:and subsequent lines down. No import or variable definition is necessary; just a change to the YAML structure.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.
@copilot