Skip to content

ci: add workflow to run Ruff on Python code#1095

Merged
RoyalOughtness merged 3 commits intosecureblue:livefrom
HastD:ruff
Jun 3, 2025
Merged

ci: add workflow to run Ruff on Python code#1095
RoyalOughtness merged 3 commits intosecureblue:livefrom
HastD:ruff

Conversation

@HastD
Copy link
Copy Markdown
Collaborator

@HastD HastD commented Jun 2, 2025

This workflow runs Ruff, a very fast Python linter, on all Python code in the repo anytime a pull request modifies Python files. This can catch a wide variety of coding errors; while it'd still be good to add unit tests as discussed in #1093, this makes partial progress on the same issue.

The added ruff.toml file configures Ruff's settings; currently the only change from the default is to set the maximum line length to 100 when formatting, which was already being used for the audit script. This helps ensure a consistent formatting standard for Python code. (The small change made to the audit script is such a formatting change, plus removing an unnecessary .strip()—I did check that the output is the same.)

I've also made ruff format --diff part of the workflow so it fails if any Python code hasn't been formatted how Ruff would format it.

@RoyalOughtness
Copy link
Copy Markdown
Collaborator

We could easily also make ruff format --diff part of the workflow so it fails if any Python code hasn't been formatted how Ruff would format it, but I wasn't sure whether to include it so I left it out.

enforcing style and linting it seems reasonable

RoyalOughtness
RoyalOughtness previously approved these changes Jun 2, 2025
HastD added 3 commits June 3, 2025 15:46
Ruff is a Python linter/formatter: https://docs.astral.sh/ruff/
This workflow runs the Ruff linter on all Python code in the repo.

The added `ruff.toml` file configures Ruff's formatting settings; the
only change from the default is to set the maximum line length to 100,
which was already being used for the audit script. This helps ensure a
consistent formatting standard for Python code.

Signed-off-by: Daniel Hast <[email protected]>
@RoyalOughtness RoyalOughtness merged commit 4770eea into secureblue:live Jun 3, 2025
16 of 17 checks passed
@HastD HastD deleted the ruff branch June 3, 2025 22:09
RoyalOughtness pushed a commit to RoyalOughtness/secureblue-dev that referenced this pull request Aug 4, 2025
* ci: add workflow to run Ruff on Python code

Ruff is a Python linter/formatter: https://docs.astral.sh/ruff/
This workflow runs the Ruff linter on all Python code in the repo.

The added `ruff.toml` file configures Ruff's formatting settings; the
only change from the default is to set the maximum line length to 100,
which was already being used for the audit script. This helps ensure a
consistent formatting standard for Python code.

Signed-off-by: Daniel Hast <[email protected]>

* ci: add format check, use ubuntu-24.04, run only on .py file changes

* ci(ruff): only run on pull_request, not push

---------

Signed-off-by: Daniel Hast <[email protected]>
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