Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,25 @@ 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`.

## GitLab CI/CD

You can add the following configuration to `.gitlab-ci.yml` to run a `ruff format`, and a `ruff check` compatible with GitLab's codequality.

```yaml
Ruff:
stage: .pre
interruptible: true
image:
name: ghcr.io/astral-sh/ruff:0.7.1-alpine
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the motivation of using the docker image over using e.g. pip or uv pip to install the project's ruff version?
That would be more aligned with our GitHub Actions example

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's way faster than installing ruff with pip every single time. That's one of the major advantages of the new images with extra tags you guys push.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. It does have the downside that they have to update the ruff version number locally in the project dependencies and CI. But I guess we can always add a second example if needed.

variables:
CODE_LOCATION: $CI_PROJECT_DIR
script:
- cd $CODE_LOCATION
- ruff --version
- ruff check --output-format=gitlab > code-quality-report.json
- ruff format --diff --verbose
artifacts:
reports:
codequality: $CODE_LOCATION/code-quality-report.json
```