From 4831db43a4457e6c57722087ed2e4911c352f793 Mon Sep 17 00:00:00 2001
From: Dorian Turba <froggit.commit.z3jqj@simplelogin.com>
Date: Mon, 28 Aug 2023 16:44:35 +0200
Subject: [PATCH] add ruff

---
 templates/python/code_quality/ruff/ruff.yml   | 21 ++++++++++++-------
 tests/ruff_project/pyproject.toml             | 11 ++++++++++
 .../ruff_project/src/ruff_project/__init__.py |  3 +++
 tests/ruff_project/src/ruff_project/main.py   | 11 ++++++++++
 4 files changed, 38 insertions(+), 8 deletions(-)
 create mode 100644 tests/ruff_project/pyproject.toml
 create mode 100644 tests/ruff_project/src/ruff_project/__init__.py
 create mode 100644 tests/ruff_project/src/ruff_project/main.py

diff --git a/templates/python/code_quality/ruff/ruff.yml b/templates/python/code_quality/ruff/ruff.yml
index ed4a47c..5856ace 100644
--- a/templates/python/code_quality/ruff/ruff.yml
+++ b/templates/python/code_quality/ruff/ruff.yml
@@ -1,14 +1,19 @@
+include:
+  - remote: 'https://api.r2devops.io/job/r/gitlab/dorianturba/r2devops_catalog/r2_metadata/python_install@latest.yaml'
+
 ruff:
-    image: python:latest
+    extends:
+        - .python_install
     stage: code_quality
+    variables:
+        PYTHON_SETUP: "pip install ruff"
     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 check .
+        - !reference [.python_install, script]
+        - ruff check ${PROJECT_PATH}
     only:
         changes:
-            - ./**/*.py
+            - ${PROJECT_PATH}/**/*.py
             - .gitlab-ci.yml
-            - pyproject.toml
+            - ${PROJECT_PATH}/pyproject.toml
+            - ${PROJECT_PATH}/.ruff.toml
+            - ${PROJECT_PATH}/ruff.toml
diff --git a/tests/ruff_project/pyproject.toml b/tests/ruff_project/pyproject.toml
new file mode 100644
index 0000000..cea87f6
--- /dev/null
+++ b/tests/ruff_project/pyproject.toml
@@ -0,0 +1,11 @@
+[build-system]
+requires = ["hatchling"]
+build-backend = "hatchling.build"
+
+[project]
+name = "ruff_project"
+version = "0.1.0"
+authors = [
+    { name = "Author Name", email = "author.name@example.com" },
+]
+description = "A description of what the package is for."
diff --git a/tests/ruff_project/src/ruff_project/__init__.py b/tests/ruff_project/src/ruff_project/__init__.py
new file mode 100644
index 0000000..58505af
--- /dev/null
+++ b/tests/ruff_project/src/ruff_project/__init__.py
@@ -0,0 +1,3 @@
+from flake8_project.main import main
+
+__all__ = ['main']
diff --git a/tests/ruff_project/src/ruff_project/main.py b/tests/ruff_project/src/ruff_project/main.py
new file mode 100644
index 0000000..28caf00
--- /dev/null
+++ b/tests/ruff_project/src/ruff_project/main.py
@@ -0,0 +1,11 @@
+"""Sample main module."""
+
+
+def main() -> bool:
+    """Sample main function."""
+    print("Hello, world!")
+    return True
+
+
+if __name__ == '__main__':
+    main()
-- 
GitLab