image: name: git.linux-kernel.at:5050/oliver/fedora42-python3:latest entrypoint: - "/bin/sh" - "-c" # Cache pip deps to speed up builds cache: paths: - .pipcache variables: PIP_CACHE_DIR: .pipcache # Test with OpenTelemetry instrumentation (always enabled, export disabled in CI) test_and_coverage: stage: build coverage: "/^TOTAL.*\\s+(\\d+\\%)$/" 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 # OpenTelemetry instrumentation always enabled, export controlled by OTEL_EXPORT_ENABLED OTEL_EXPORT_ENABLED: "false" # Disable export in CI to avoid external dependencies OTEL_SERVICE_NAME: "ivatar-ci" OTEL_ENVIRONMENT: "ci" 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 python-coveralls - 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 - 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 with OpenTelemetry instrumentation enabled..." - coverage run --source . scripts/run_tests_with_coverage.py - coverage report --fail-under=70 - coverage html artifacts: paths: - htmlcov/ pycco: stage: test 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 python-coveralls - pip install coverage - pip install pycco - pip install django_coverage_plugin script: - "/bin/true" - find ivatar/ -type f -name "*.py"|grep -v __pycache__|grep -v __init__.py|grep -v /migrations/ | xargs pycco -p -d pycco -i -s artifacts: paths: - pycco/ expire_in: 14 days pages: stage: deploy dependencies: - test_and_coverage - pycco script: - mv htmlcov/ public/ - mv pycco/ public/ artifacts: paths: - public expire_in: 14 days only: - master #build-image: # image: docker # only: # - master # - devel # services: # - docker:dind # before_script: # - docker info # - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY # script: # - ls -lah # - | # if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then # tag="" # echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'" # else # tag=":$CI_COMMIT_REF_SLUG" # echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag" # fi # - docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" . # - docker push "$CI_REGISTRY_IMAGE${tag}" # Deployment verification jobs verify_dev_deployment: stage: deploy image: python:3.11-alpine only: - devel variables: DEV_URL: "https://dev.libravatar.org" MAX_RETRIES: 30 RETRY_DELAY: 60 before_script: - apk add --no-cache curl - pip install Pillow script: - echo "Waiting for dev.libravatar.org deployment to complete..." - python3 scripts/check_deployment.py --dev --max-retries $MAX_RETRIES --retry-delay $RETRY_DELAY allow_failure: false verify_prod_deployment: stage: deploy image: python:3.11-alpine only: - master when: manual variables: PROD_URL: "https://libravatar.org" MAX_RETRIES: 10 RETRY_DELAY: 30 before_script: - apk add --no-cache curl - pip install Pillow script: - echo "Verifying production deployment..." - python3 scripts/check_deployment.py --prod --max-retries $MAX_RETRIES --retry-delay $RETRY_DELAY allow_failure: false include: - template: Jobs/SAST.gitlab-ci.yml - template: Jobs/Dependency-Scanning.gitlab-ci.yml - template: Jobs/Secret-Detection.gitlab-ci.yml