From dfc66c4d3e9870828775e651b96f5781821e2ad1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Benjamin=20H=C3=A4ttasch?=
 <benjamin.haettasch@fachschaft.informatik.tu-darmstadt.de>
Date: Sun, 5 Nov 2023 16:07:59 +0100
Subject: [PATCH] Fix CI pipeline

Restrict before script to stages using a python image
---
 .gitlab-ci.yml | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 53e961a2..fe4d4446 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -14,24 +14,27 @@ cache:
   paths:
     - ~/.cache/pip/
 
-before_script:
-  - python -V  # Print out python version for debugging
-  - apt-get -qq update
-  - apt-get -qq install -y python3-virtualenv python3 python3-dev python3-pip gettext default-mysql-client default-libmysqlclient-dev
-  - ./Utils/setup.sh --ci
-  - mkdir -p public/badges public/lint
-  - echo undefined > public/badges/$CI_JOB_NAME.score
-  - source venv/bin/activate
-  - pip install pylint-gitlab pylint-django
-  - mysql --version
+.before_script_template:
+  before_script:
+    - python -V  # Print out python version for debugging
+    - apt-get -qq update
+    - apt-get -qq install -y python3-virtualenv python3 python3-dev python3-pip gettext default-mysql-client default-libmysqlclient-dev
+    - ./Utils/setup.sh --ci
+    - mkdir -p public/badges public/lint
+    - echo undefined > public/badges/$CI_JOB_NAME.score
+    - source venv/bin/activate
+    - pip install pylint-gitlab pylint-django
+    - mysql --version
 
 check:
+  extends: .before_script_template
   script:
     - ./Utils/check.sh --all
     - source venv/bin/activate
     - ./manage.py makemigrations --dry-run --check
 
 test:
+  extends: .before_script_template
   script:
     - source venv/bin/activate
     - echo "GRANT ALL on *.* to '${MYSQL_USER}';"| mysql -u root --password="${MYSQL_ROOT_PASSWORD}" -h mysql
@@ -50,6 +53,7 @@ test:
       junit: unit.xml
 
 lint:
+  extends: .before_script_template
   stage: test
   script:
     - pylint --load-plugins pylint_django --django-settings-module=AKPlanning.settings_ci --rcfile pylintrc --exit-zero --output-format=text AK* | tee /tmp/pylint.txt
@@ -67,6 +71,7 @@ lint:
     when: always
 
 doc:
+  extends: .before_script_template
   stage: test
   script:
     - cd docs
-- 
GitLab