# This pipeline would run the test coverage report to satisfy Coverage-Check rule. stages: - test - build - publish variables: PROJECT_ID: 217 # Define a cache for pip dependencies to speed up builds cache: paths: - .cache/pip/ # Install dependencies and run tests with coverage test: stage: test image: python:3.11 # Use the desired Python version before_script: - python -V # Print Python version for debugging - pip install --upgrade pip - pip install -r requirements.txt # Install project dependencies - pip install pytest coverage # Install testing and coverage tools script: - coverage run -m pytest # Run tests with coverage - coverage report -m # Generate coverage report - coverage xml # Generate coverage report in XML format for GitLab artifacts: reports: coverage_report: coverage_format: cobertura path: coverage.xml paths: - coverage.xml coverage: '/^TOTAL.*\s+(\d+%)$/' # Regex to extract coverage percentage from the report #rules: # - if: $CI_COMMIT_BRANCH == "develop" # Run this job only on the 'develop' branch # Build the package build: stage: build image: python:3.11 before_script: - pip install --upgrade pip - pip install setuptools wheel script: - python setup.py sdist bdist_wheel artifacts: paths: - dist/ # Publish the package to PyPI publish: stage: publish image: python:3.11 before_script: - pip install --upgrade pip - pip install twine script: # - twine upload --username $CI_REGISTRY_USER --password $CI_REGISTRY_PASSWORD dist/* - twine upload --repository-url https://git.cleverthis.com/api/v4/projects/$PROJECT_ID/packages/pypi --username $CI_REGISTRY_USER --password $CI_REGISTRY_PASSWORD dist/* #only: # - main # Only publish from the main branch #rules: # - if: $CI_COMMIT_BRANCH == "main"