Repository navigation
feat(lint): run ruff when the repository has Python files - #562
Conversation
Pin ruff in .mise.toml, add a ruff.toml (120 columns, Python 3.8 target for the ai-commits-badge action) and apply ruff format plus the ruff check fixes, so the ruff linter added to lint.yml next passes here. Refs #539 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add a lint-ruff linter (default on, off in lint-include.yml) to both job modes. A first step lists the tracked Python files, minus the shared dprint excludes, and skips the mise install and ruff when there are none. ruff runs ruff check (annotations, plus SARIF for code scanning with upload-sarif) and ruff format --diff. Add a create-only ruff.toml template and pin ruff in the .mise.toml template. Refs #539 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
ruff (EXE001) flags a shebang on a file without the executable bit. Refs #539 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Template syncing can silently override existing Ruff settings, and lint checks can auto-fix violations and pass while those violations remain in committed files.
2 open issues
What changed in this PR
Adds Python-aware Ruff checks to the shared lint workflows as the first part of #539. Repositories without tracked Python files skip Ruff installation and execution.
Changes:
- Adds Ruff linting, formatting checks and optional SARIF reporting in both workflow modes.
- Introduces shared language detection, Ruff configuration templates and version pins.
- Extends workflow tests and documentation, and applies Ruff cleanup to existing Python files.
Review was static only; tests, builds and linters were not run.
| File | Description |
|---|---|
workflow-templates/lint.yml |
Documents the optional Ruff input. |
tests/workflow-script-fetch.py |
Applies Python formatting cleanup. |
tests/workflow-job-conditions.py |
Adds Ruff to expected workflow jobs. |
tests/pr-labeler-config.py |
Applies Python formatting cleanup. |
tests/lint-scripts.sh |
Covers language detection, exclusions and Ruff execution. |
tests/lint-job-modes-contract.sh |
Includes Ruff in mode-parity checks. |
tests/lint-inline-scripts.py |
Applies Python formatting cleanup. |
tests/lint-include.py |
Applies Python formatting cleanup. |
tests/issue-labeler-config.py |
Applies Python formatting cleanup. |
tests/app-key-confinement.py |
Applies formatting and regex-name cleanup. |
tests/ai-commits-badge.py |
Applies formatting and explicit subprocess defaults. |
scripts/lint/ruff.sh |
Runs linting, formatting checks and SARIF generation. |
scripts/lint/language-files.sh |
Lists tracked Python files with shared exclusions. |
scripts/lint/detect-language.sh |
Emits language-presence output for workflow gating. |
scripts/lint-inline-scripts.py |
Simplifies conditions and applies formatting. |
scripts/config-sync/renovate-extends-preset.py |
Uses pathlib for reading and applies formatting. |
ruff.toml |
Configures Ruff for this repository. |
docs/architecture.md |
Documents language detection and Ruff integration. |
config-sync/templates/ruff.toml |
Adds a starter Ruff configuration. |
config-sync/templates/README.md |
Describes the Ruff template. |
config-sync/templates/.mise.toml |
Pins Ruff in the tool template. |
actions/ai-commits-badge/ai_commits_badge.py |
Applies Python formatting cleanup. |
.mise.toml |
Pins Ruff for this repository. |
.github/workflows/lint.yml |
Integrates Ruff into parallel and single-job modes. |
.github/workflows/lint-include.yml |
Exposes and forwards the opt-in Ruff input. |
Review effort: Balanced
…of configured repos Pass --no-fix to ruff check so a fix = true in the repository's config can't edit the files being checked, and don't bootstrap the ruff.toml template next to .ruff.toml or [tool.ruff] in pyproject.toml, which it would override. Refs #539 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
@coderabbitai review |
Action not completed
|

Description
First layer of #539: the reusable Lint workflow runs ruff on repositories that have Python files. Biome and PSScriptAnalyzer follow in stacked PRs and reuse the language detection added here.
Refs #539
Changes
lint-ruff(defaulttrueinlint.yml,falseinlint-include.yml), as aruffjob and as steps of the singleall lintersjob.scripts/lint/detect-language.sh) lists the tracked*.py/*.pyifiles withgit ls-files(scripts/lint/language-files.sh), skipping the excludes of the shareddprint.json(.specify,.venv*, APM agent dirs,node_modules). Without files, the mise install and ruff are skipped.tests/lint-scripts.shfails when adprint.jsonexclude is missing from the helper.scripts/lint/ruff.sh:ruff check --no-fix(PR annotations) andruff format --diffon those files, with--force-excludeso the repo's own ruff excludes still apply. Withupload-sarif, it also writes SARIF for code scanning (categoryruff). ruff must be pinned in the repo's mise config (the usual "not pinned" guidance).config-sync/templates/ruff.toml(120 columns, shared excludes) andruffin the.mise.tomltemplate.sync-files.shdoesn't addruff.tomlnext to.ruff.tomlor[tool.ruff]inpyproject.toml, which it would override.ruff.tomland appliesruff formatplus theruff checkfixes; a later one marks the Python scripts with a shebang executable (ruff EXE001). It's mostly tool output, so reviewing the commits one at a time is easier.lint-scripts.shcases for the helper, detection and ruff,config-sync-scripts.shcases for the template skip. Docs:docs/architecture.md, workflow template, templates README.Repos without Python get no new required input, so this is a
feat:.Checklist
mise exec -- lefthook run pre-commit): this repo has no lefthook config, so I ran ruff, shellcheck, shfmt, yamlfmt, yamllint, actionlint and dprint on the changed files instead. All clean.Tests run locally (Windows, Git Bash):
tests/lint-scripts.sh,tests/lint-job-modes-contract.sh,tests/lint-include.py,tests/lint-inline-scripts.py,tests/workflow-job-conditions.py,tests/workflow-script-fetch.py,tests/ai-commits-badge.py,tests/app-key-confinement.py,tests/issue-labeler-config.py,tests/pr-labeler-config.py,tests/config-sync-scripts.sh,tests/config-sync-renovate-stub.shandtests/config-sync-ai-toolkit-instructions.shall passed. A few unrelated shell tests fail only on Windows (CRLF and bare-repo quirks); CI runs the full suite on Linux and is green. The first CI run caught EXE001 in both job modes, which confirms the new job gates as intended.