2025, Oct 30 23:00

How to run Ruff with the strictest rules in GitHub Actions: use args 'check --select ALL'

Configure Ruff in GitHub Actions for strict linting. Use args 'check --select ALL' to enable all rules and keep CI consistent, catching whitespace issues early.

When running Ruff in GitHub Actions, the out-of-the-box configuration may feel too permissive. A typical example is trailing whitespace slipping through CI because the default invocation doesn’t enable the most aggressive rule set. If you want the strictest possible gate, you need to explicitly select every rule.

Baseline setup that isn’t strict enough

The minimal action usage calls Ruff with its default behavior, which won’t enforce the most stringent checks:

- uses: astral-sh/ruff-action@v3
  with:
    src: >-
      path/to/file1.py
      path/to/file2.py

What actually happens

This configuration runs ruff check without additional flags, so you only get the default rule selection. That’s why issues like trailing whitespace can pass. The action itself is fine; it’s simply mirroring the default ruff check unless you tell it otherwise.

The fix: opt into all rules

To enable the strictest checks, pass explicit arguments to the action. Adding args: "check --select ALL" instructs Ruff to enable every rule category:

- uses: astral-sh/ruff-action@v3
  with:
    args: "check --select ALL"
    src: >-
      path/to/file1.py
      path/to/file2.py

If you prefer a complete workflow that runs on pushes to the master branch and on pull requests, here is a compact example you can drop into .github/workflows/lint.yml:

name: linting-pipeline
on:
  push:
    branches:
      - master
  pull_request:

jobs:
  style_audit:
    name: Ruff checks
    runs-on: ubuntu-latest
    steps:
      - name: Fetch repository
        uses: actions/checkout@v4
      - name: Execute Ruff — Python linter
        uses: astral-sh/ruff-action@v3
        with:
          version: latest
          args: "check --select ALL"
          src: >-
            path/to/file1.py
            path/to/file2.py

Why this matters

CI is only as reliable as the bar it sets. If the workflow uses the default rule set, its signal will diverge from what you expect of a strict linter—leading to inconsistent reviews and avoidable churn later. By selecting ALL, you align expectations, catch cosmetic and structural issues early, and keep “works on my machine” surprises out of your pull requests.

Related approaches

Why not just use the action to install ruff, then call whatever commands you like? Or configure it so the rules you want are applied every time you run it, wherever you do so?

If your team prefers alternative wiring, those are viable routes. The key point is to ensure your CI invocation enforces the rules you intend.

Summary

For the most stringent Ruff run inside GitHub Actions, pass args: "check --select ALL" to the action. This small change switches the linter from default behavior to an exhaustive rule set, keeping your codebase consistently clean and your CI feedback predictable.

The article is based on a question from StackOverflow by Timur Shtatland and an answer by Timur Shtatland.