From 3006d6da238ffea627f20c4f79a5abafe39512ce Mon Sep 17 00:00:00 2001 From: Jonas Vacek Date: Sat, 26 Oct 2024 18:10:17 +0200 Subject: [PATCH] Docs: Add GitLab CI/CD to integrations. (#13915) --- docs/integrations.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/integrations.md b/docs/integrations.md index 31f017c13e..e8479db3b9 100644 --- a/docs/integrations.md +++ b/docs/integrations.md @@ -71,6 +71,34 @@ For example, to run `ruff check --select B ./src` using Ruff version `0.0.259`: src: "./src" ``` +## GitLab CI/CD + +You can add the following configuration to `.gitlab-ci.yml` to run a `ruff format` in parallel with a `ruff check` compatible with GitLab's codequality report. + +```yaml +.base_ruff: + stage: build + interruptible: true + image: + name: ghcr.io/astral-sh/ruff:0.7.1-alpine + before_script: + - cd $CI_PROJECT_DIR + - ruff --version + +Ruff Check: + extends: .base_ruff + script: + - ruff check --output-format=gitlab > code-quality-report.json + artifacts: + reports: + codequality: $CI_PROJECT_DIR/code-quality-report.json + +Ruff Format: + extends: .base_ruff + script: + - ruff format --diff +``` + ## pre-commit Ruff can be used as a [pre-commit](https://pre-commit.com) hook via [`ruff-pre-commit`](https://github.com/astral-sh/ruff-pre-commit): @@ -156,3 +184,4 @@ In addition, ruff publishes the following images: As with the distroless image, each image is published with ruff version tags as `ruff:{major}.{minor}.{patch}-{base}` and `ruff:{major}.{minor}-{base}`, e.g., `ruff:0.6.6-alpine`. +