From f15d4b97dc276361be5339a3e90b95ca9234766a Mon Sep 17 00:00:00 2001 From: Dorian Turba <froggit.commit.z3jqj@simplelogin.com> Date: Mon, 10 Jul 2023 19:57:14 +0200 Subject: [PATCH] add ruff --- python/code_quality/ruff/README.md | 29 +++++++++++++++++++++++++++++ python/code_quality/ruff/ruff.yml | 14 ++++++++++++++ ruff.r2.yml | 14 ++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 python/code_quality/ruff/README.md create mode 100644 python/code_quality/ruff/ruff.yml create mode 100644 ruff.r2.yml diff --git a/python/code_quality/ruff/README.md b/python/code_quality/ruff/README.md new file mode 100644 index 0000000..5ab844a --- /dev/null +++ b/python/code_quality/ruff/README.md @@ -0,0 +1,29 @@ +## Objective + +Run [Ruff](https://github.com/ruffle-rs/ruffle), an extremely fast Python linter, on your Python +code. This tool is written in Rust, and it is designed to quickly analyze your Python code to detect +various syntax and stylistic errors. + +## How to use it + +1. Configure the `pyproject.toml` file in your repository's root directory with your desired rules. +2. Include the Ruff template in your GitLab CI/CD configuration. +3. If you need to customize the job, refer to + the [jobs customization](https://docs.r2devops.io/get-started/use-templates/#job-templates-customization) + documentation. + +### Global Configuration of Ruff + +To add configuration to `ruff` that is shared with any other usage of Ruff (such as manual run, +pre-commit, etc), you can use a `pyproject.toml` configuration file in your project's root +directory. Learn more about [ruff configuration](https://beta.ruff.rs/docs/configuration/) files. + +## Add a <a href="https://github.com/ruffle-rs/ruffle"><img alt="Code style: Ruff" src="https://img.shields.io/badge/Ruff-Linter-blue"></a> Badge to your project README.md + +To display the use of Ruff in your project, you can add the following badge to your README.md: + +```markdown +<a href="https://github.com/ruffle-rs/ruffle"> + <img alt="Code style: Ruff" src="https://img.shields.io/badge/Ruff-Linter-blue"> +</a> +``` diff --git a/python/code_quality/ruff/ruff.yml b/python/code_quality/ruff/ruff.yml new file mode 100644 index 0000000..14838ae --- /dev/null +++ b/python/code_quality/ruff/ruff.yml @@ -0,0 +1,14 @@ +ruff: + image: python:latest + stage: code_quality + script: + - python --version # Debug + - python -m venv venv --upgrade-deps || python -m venv venv # upgrade-deps is not supported before 3.9 + - source venv/bin/activate + - pip install ruff + - ruff + only: + changes: + - ./**/*.py + - .gitlab-ci.yml + - pyproject.toml diff --git a/ruff.r2.yml b/ruff.r2.yml new file mode 100644 index 0000000..616bc6a --- /dev/null +++ b/ruff.r2.yml @@ -0,0 +1,14 @@ +files: + template: ./python/code_quality/ruff/ruff.yml + documentation: ./python/code_quality/ruff/README.md +data: + description: "Run ruff on your repository" + icon: 💎 + public: true + labels: + - Lint + - Utilities + - Code Quality + - Python + license: MIT + deprecated: false -- GitLab