From 6ff027adaa255e4b4755c8f521678cc55d2c9799 Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Thu, 21 Mar 2024 11:46:57 +0100
Subject: [PATCH] [ci] Run pre-commit on changes only.

---
 .gitlab-ci.yml | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1cc64e0e3..5cb57c817 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -29,6 +29,14 @@ cache:
   - make setup_headless
   - source .venv/bin/activate
 
+pre-commit:
+  tags: [shell, envinf]
+  rules:
+    - if: $CI_MERGE_REQUEST_IID
+  needs: []
+  script:
+    - pre-commit run --from-ref ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --to-ref HEAD
+
 build:
   script:
     - pip install build
@@ -38,7 +46,6 @@ tests (arch):
   tags: [shell, envinf]
   needs: []
   script:
-    - pre-commit run --all-files
     - *setup-headless
     - make test
 
-- 
GitLab