Skip to content

feat(lint): run ruff when the repository has Python files - #562

Merged
DevSecNinja merged 4 commits into
mainfrom
devsecninja-feat-lint-language-linters
Nov 17, 2026
Merged

DevSecNinja merged 4 commits into
mainfrom
devsecninja-feat-lint-language-linters

Conversation

@DevSecNinja

@DevSecNinja DevSecNinja commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

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 (default true in lint.yml, false in lint-include.yml), as a ruff job and as steps of the single all linters job.
  • Cheap when there's no Python: a first step (scripts/lint/detect-language.sh) lists the tracked *.py/*.pyi files with git ls-files (scripts/lint/language-files.sh), skipping the excludes of the shared dprint.json (.specify, .venv*, APM agent dirs, node_modules). Without files, the mise install and ruff are skipped. tests/lint-scripts.sh fails when a dprint.json exclude is missing from the helper.
  • scripts/lint/ruff.sh: ruff check --no-fix (PR annotations) and ruff format --diff on those files, with --force-exclude so the repo's own ruff excludes still apply. With upload-sarif, it also writes SARIF for code scanning (category ruff). ruff must be pinned in the repo's mise config (the usual "not pinned" guidance).
  • Templates: create-only config-sync/templates/ruff.toml (120 columns, shared excludes) and ruff in the .mise.toml template. sync-files.sh doesn't add ruff.toml next to .ruff.toml or [tool.ruff] in pyproject.toml, which it would override.
  • This repo dogfoods it: the first commit pins ruff, adds ruff.toml and applies ruff format plus the ruff check fixes; 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.
  • Tests: contract and job-condition lists, lint-scripts.sh cases for the helper, detection and ruff, config-sync-scripts.sh cases 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

  • Linting passes locally (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.
  • Commit messages follow Conventional Commits
  • Documentation updated (if applicable)

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.sh and tests/config-sync-ai-toolkit-instructions.sh all 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.

DevSecNinja and others added 2 commits November 17, 2026 14:15
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>
@DevSecNinja
DevSecNinja requested a balanced review from Copilot November 17, 2026 13:16
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 87e14cdb-b822-40bf-bd6e-8ce915cda5f9
Commits

Reviewing files that changed from the base of the PR and between 4fb90ff and fc54040.

Files selected for processing: 27

  • .github/workflows/lint-include.yml
  • .github/workflows/lint.yml
  • .mise.toml
  • actions/ai-commits-badge/ai_commits_badge.py
  • config-sync/templates/.mise.toml
  • config-sync/templates/README.md
  • config-sync/templates/ruff.toml
  • docs/architecture.md
  • ruff.toml
  • scripts/config-sync/renovate-extends-preset.py
  • scripts/config-sync/sync-files.sh
  • scripts/lint-inline-scripts.py
  • scripts/lint/detect-language.sh
  • scripts/lint/language-files.sh
  • scripts/lint/ruff.sh
  • tests/ai-commits-badge.py
  • tests/app-key-confinement.py
  • tests/config-sync-scripts.sh
  • tests/issue-labeler-config.py
  • tests/lint-include.py
  • tests/lint-inline-scripts.py
  • tests/lint-job-modes-contract.sh
  • tests/lint-scripts.sh
  • tests/pr-labeler-config.py
  • tests/workflow-job-conditions.py
  • tests/workflow-script-fetch.py
  • workflow-templates/lint.yml
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@github-advanced-security

Copy link
Copy Markdown

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:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

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>

Copilot AI 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.

🟡 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

Comment thread config-sync/templates/ruff.toml Resolved
Comment thread scripts/lint/ruff.sh Resolved
…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>

Copilot AI 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.

🟢 Approval recommended

No active review issues were identified, though runtime checks were not run during this static review.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@DevSecNinja
DevSecNinja added this pull request to stack #565 November 17, 2026 14:22
@DevSecNinja
DevSecNinja merged commit e416a44 into main Nov 17, 2026
42 checks passed
@DevSecNinja
DevSecNinja deleted the devsecninja-feat-lint-language-linters branch November 17, 2026 14:43
@DevSecNinja

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Action not completed

Pull request is closed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

3 participants