Add ruff format --check
Description
As we have a job for black, a job for ruff and that ruff format "is designed as a drop-in replacement for Black, but with an excessive focus on performance and direct integration with Ruff" I would like to use it instead of black with the --check option, see ruff format doc for more details.
Implementation ideas
spec:
inputs:
ruff-format-enabled:
description: Enable ruff format
type: boolean
default: false
...
variables:
PYTHON_RUFF_FORMAT_ENABLED: $[[ inputs.ruff-format-enabled ]]
...
py-ruff-format:
extends: .python-base
stage: build
script:
- install_requirements
- _pip install ruff
- _run ruff format . --check
rules:
# exclude if $PYTHON_RUFF_FORMAT_ENABLED not set
- if: '$PYTHON_RUFF_FORMAT_ENABLED != "true"'
when: never
- !reference [.test-policy, rules]