mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 14:52:01 +00:00
![]() ## Summary I've added support for configuring the `ruff check` output file via the environment variable `RUFF_OUTPUT_FILE` akin to #1731. This is super useful when, e.g., generating a [GitLab code quality report](https://docs.gitlab.com/ee/ci/testing/code_quality.html#implement-a-custom-tool) while running Ruff as a pre-commit hook. Usually, `ruff check` should print its human-readable output to `stdout`, but when run through `pre-commit` _in a GitLab CI job_ it should write its output in `gitlab` format to a file. So, to override these two settings only during CI, environment variables come handy, and `RUFF_OUTPUT_FORMAT` already exists but `RUFF_OUTPUT_FILE` has been missing. A (simplified) GitLab CI job config for this scenario might look like this: ```yaml pre-commit: stage: test image: python variables: RUFF_OUTPUT_FILE: gl-code-quality-report.json RUFF_OUTPUT_FORMAT: gitlab before_script: - pip install pre-commit script: - pre-commit run --all-files --show-diff-on-failure artifacts: reports: codequality: gl-code-quality-report.json ``` ## Test Plan I tested it manually. |
||
---|---|---|
.. | ||
ruff | ||
ruff_benchmark | ||
ruff_cache | ||
ruff_dev | ||
ruff_diagnostics | ||
ruff_formatter | ||
ruff_index | ||
ruff_linter | ||
ruff_macros | ||
ruff_notebook | ||
ruff_python_ast | ||
ruff_python_codegen | ||
ruff_python_formatter | ||
ruff_python_index | ||
ruff_python_literal | ||
ruff_python_parser | ||
ruff_python_resolver | ||
ruff_python_semantic | ||
ruff_python_stdlib | ||
ruff_python_trivia | ||
ruff_server | ||
ruff_shrinking | ||
ruff_source_file | ||
ruff_text_size | ||
ruff_wasm | ||
ruff_workspace |