Skip to content

[Advanced]: Add Ruff hook and include in CI pipeline #2043

@exploreriii

Description

@exploreriii

🧠 Advanced Contributors — Prerequisites & Expectations

🐞 Problem Description

We can benefit from a ruff check at the commit level and also in the ci workflows. The reason is if we ever try to fix ruff issues later, there are so many changes and this can be tricky to review. Additionally, we can commit code into the system that is of lower-quality.

Read about
https://docs.astral.sh/ruff/
https://github.com/astral-sh/ruff-action
https://docs.astral.sh/ruff/integrations/

We have some basic configs at pyproject.toml, but these probably need critical thinking to adjust.

Introduce ruff check into the pipeline, you should decide if we should hard fail workflows (can't merge) or just throw a warning.
Consider introducing a ruff hook, so commits are correctly formatted, but consider the trade offs to user experience.

Ensure it:

We would like to:

  • be forward looking to align with future hooks/ci
  • align with current tooling and pipelines we have
  • not break anything, or provide a minimal entry barrier for developers
  • Test to see if it keeps good developer experience, what happens if there are existing issues. Do we need documentation? What kind of issues could this cause?

You'll have to study the ruff errors we currently have, decide what kind of standards we should apply.

Caution

This advanced issue requires extensive independent research and testing.

🏁 Concrete Prerequisites

  • Proven History: Successfully merged ≥ 5 non-trivial intermediate issues in this repo, including at least 2 relating to github actions.
  • Expertise: good architectural understanding of creating high-quality, well tested workflows

⚠️ AI Usage Policy

Using AI to generate code for Advanced issues is strictly discouraged. AI may be used only to help explain file relationships. We require this workflow to work and follow best principles.

⏱️ Timeline & Workflow

  • Typical time: ~2 weeks / ~20 hours.
  • 🔴 Completing an advanced issue in 1–3 days is a red flag and will likely be rejected.
  • Advised: Post your proposed architectural approach as a comment and wait for feedback before writing any code.

🛠️ Implementation Notes

Technical domains involved in this issue:

  • CI/CD Integration
    Updates to the GitHub Actions workflow, including triggers (push, pull_request) and job steps for running linting (Ruff) and tests (pytest).
  • Code Quality / Linting
    Replacing or supplementing with Ruff for faster linting, rule enforcement, and optional auto-formatting.
  • Dependency & Tooling Management
    Installing and managing versions of Ruff and pytest in CI and optionally in local environments.
  • Developer Experience (DX) / Pre-commit Hooks
    Using pre-commit to run Ruff locally before commits, ensuring faster feedback and consistent code quality.
  • Configuration & Consistency
    Optional Ruff configuration (e.g. pyproject.toml), rule selection, line length, and auto-fix behavior to maintain consistent standards across environments.
  • Workflow Optimization
    Streamlining the pipeline by replacing multiple tools (e.g. Flake8 and plugins) with Ruff, reducing CI runtime while maintaining coverage.

🛡️ Quality & Review Standards

The bar for advanced PRs is "safe, maintainable, architecturally sound, and production-ready."

  • CI Reliability. Workflow must run consistently on appropriate trigger
  • Proper lowest permissions set to limited scope files
  • Bandit findings are meaningful and appropriate
  • Suitably complements existing tools
  • Workflow file is simple, readable, and minimal. Uses stable, well-supported GitHub Actions with hashes.
  • Pre-commit hook is appropriate with minimal friction

Notably: Developer architects the solution of how to best apply bandit to the repo

✅ PR Quality Checklist

Before opening your PR, the contributor must confirm:

  • I understand the system-wide impact of these changes on affected modules and performance.
  • The system design fits with current architectural approaches.
  • I have tested my changes extensively against both local and network environments.
  • Every line of code is personally understood and explainable and tested

📚 Resources & Support

Sample from github:
https://github.com/actions/starter-workflows/blob/main/code-scanning/bandit.yml

Project References:

🆘 Stuck?

Metadata

Metadata

Assignees

No one assigned

    Labels

    advancedrequires knowledge of multiple areas in the codebase without defined steps to implement or examplesgithub_actionsPull requests that update Github Actions code.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions