From 482dd772e125f5f96908554df9d456603b5d340a Mon Sep 17 00:00:00 2001
From: Anton Tetov <anton@tetov.se>
Date: Thu, 7 Apr 2022 17:09:50 +0200
Subject: [PATCH] install git on failed quality check for artifact

---
 .gitlab-ci.yml | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index dd28be5..cf2bf1c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -36,7 +36,6 @@ stages:
   <<: *install-deps
   image: python:3.9-slim-bullseye
   stage: quality
-  allow_failure: true
 
 .test-template: &test
   <<: *install-deps
@@ -48,6 +47,21 @@ stages:
 run-pre-commit:
   <<: *quality
   script: make check
+  allow_failure: true
+  after_script:
+    - mkdir -pv changed
+    - |
+      test $CI_JOB_STATUS -eq "failed" &&
+      apt install git -y &&
+      git status --porcelain 
+        | awk 'match($1,"M"){print $2}' 
+        | xargs -r cp -vt changed
+  artifacts:
+    name: "$CI_JOB_NAME"
+    expire_in: 7 days
+    paths:
+      - "changed/*"
+    when: on_failure
 
 # Tests jobs
 
-- 
GitLab