From 19facb4bec1840ec3eb5bd617bcd6eac00e7fd35 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Thu, 16 Oct 2025 17:35:52 +0200 Subject: [PATCH] Split CI testing into parallel jobs for OpenTelemetry - test_without_opentelemetry: Run baseline tests without OpenTelemetry - test_with_opentelemetry_and_coverage: Run comprehensive tests with OpenTelemetry enabled and measure coverage - Both jobs run in parallel for faster CI execution - Coverage is measured only on OpenTelemetry-enabled run to capture additional code paths - Updated pages job dependency to use the new coverage job --- .gitlab-ci.yml | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 94a4c78..8c9805d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,7 +11,42 @@ cache: variables: PIP_CACHE_DIR: .pipcache -test_and_coverage: +# Test without OpenTelemetry (baseline testing) +test_without_opentelemetry: + stage: build + services: + - postgres:latest + variables: + POSTGRES_DB: django_db + POSTGRES_USER: django_user + POSTGRES_PASSWORD: django_password + POSTGRES_HOST: postgres + DATABASE_URL: "postgres://django_user:django_password@postgres/django_db" + PYTHONUNBUFFERED: 1 + # Ensure OpenTelemetry is disabled + ENABLE_OPENTELEMETRY: "false" + OTEL_ENABLED: "false" + before_script: + - virtualenv -p python3 /tmp/.virtualenv + - source /tmp/.virtualenv/bin/activate + - pip install -U pip + - pip install Pillow + - pip install -r requirements.txt + - pip install pycco + script: + - source /tmp/.virtualenv/bin/activate + - echo 'from ivatar.settings import TEMPLATES' > config_local.py + - echo 'TEMPLATES[0]["OPTIONS"]["debug"] = True' >> config_local.py + - echo "DEBUG = True" >> config_local.py + - echo "from config import CACHES" >> config_local.py + - echo "CACHES['default'] = CACHES['filesystem']" >> config_local.py + - python manage.py sqldsn + - python manage.py collectstatic --noinput + - echo "Running tests without OpenTelemetry..." + - ./run_tests_no_ot.sh + +# Test with OpenTelemetry enabled and measure coverage +test_with_opentelemetry_and_coverage: stage: build coverage: "/^TOTAL.*\\s+(\\d+\\%)$/" services: @@ -23,6 +58,11 @@ test_and_coverage: POSTGRES_HOST: postgres DATABASE_URL: "postgres://django_user:django_password@postgres/django_db" PYTHONUNBUFFERED: 1 + # Enable OpenTelemetry for comprehensive testing + ENABLE_OPENTELEMETRY: "true" + OTEL_ENABLED: "true" + OTEL_SERVICE_NAME: "ivatar-ci" + OTEL_ENVIRONMENT: "ci" before_script: - virtualenv -p python3 /tmp/.virtualenv - source /tmp/.virtualenv/bin/activate @@ -33,7 +73,6 @@ test_and_coverage: - pip install coverage - pip install pycco - pip install django_coverage_plugin - script: - source /tmp/.virtualenv/bin/activate - echo 'from ivatar.settings import TEMPLATES' > config_local.py @@ -43,7 +82,8 @@ test_and_coverage: - echo "CACHES['default'] = CACHES['filesystem']" >> config_local.py - python manage.py sqldsn - python manage.py collectstatic --noinput - - coverage run --source . manage.py test -v3 --noinput + - echo "Running tests with OpenTelemetry enabled and measuring coverage..." + - coverage run --source . ./run_tests_with_ot.sh - coverage report --fail-under=70 - coverage html artifacts: @@ -73,7 +113,7 @@ pycco: pages: stage: deploy dependencies: - - test_and_coverage + - test_with_opentelemetry_and_coverage - pycco script: - mv htmlcov/ public/