# This file is a template, and might need editing before it works on your project. # To contribute improvements to CI/CD templates, please follow the Development guide at: # https://docs.gitlab.com/ee/development/cicd/templates.html # This specific template is located at: # https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml # Official language image. Look for the different tagged releases at: # https://hub.docker.com/r/library/python/tags/ image: python:alpine3.18 # Change pip's cache directory to be inside the project directory since we can # only cache local items. variables: PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" # REGISTRY_USERNAME - secret variable # REGISTRY_PASSWORD - secret variable # REGISTRY_SERVER - secret variable IMAGE_NAME: ${REGISTRY_SERVER}/malves/${CI_PROJECT_NAME} # Pip's cache doesn't store the python packages # https://pip.pypa.io/en/stable/reference/pip_install/#caching # # If you want to also cache the installed packages, you have to install # them in a virtualenv and cache it as well. cache: paths: - .cache/pip - venv/ stages: - test - build .before_script_template: &test before_script: - python3 -V # Print out python version for debugging - python3 -m venv /tmp/venv - /tmp/venv/bin/pip3 install .["tests","pyexcel"] - /tmp/venv/bin/pip3 install coverage pytest test: image: python:alpine${ALPINEVERSION} stage: test <<: *test parallel: matrix: - ALPINEVERSION: ["3.16", "3.17", "3.18", "3.19"] script: - /tmp/venv/bin/pytest --version - PYTHONPATH=./tests/ /tmp/venv/bin/coverage run --source halfapi -m pytest - /tmp/venv/bin/coverage xml - /tmp/venv/bin/halfapi --version artifacts: reports: coverage_report: coverage_format: cobertura path: coverage.xml build_pypi: stage: build script: - python3 -V # Print out python version for debugging - python3 -m venv /tmp/venv - /tmp/venv/bin/pip3 install . artifacts: paths: - dist/*.whl rules: - if: '$CI_COMMIT_TAG != ""' variables: TAG: $CI_COMMIT_TAG build_container: rules: - if: '$CI_COMMIT_TAG != ""' variables: IMGTAG: $CI_COMMIT_TAG - if: '$CI_COMMIT_REF_NAME == "devel"' variables: IMGTAG: "latest" stage: build image: $CI_REGISTRY/devtools/kaniko script: - echo "Will upload image halfapi:\"$IMGTAG\"" - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json - /kaniko/executor --force --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY/malves/halfapi:"$IMGTAG" artifacts: paths: - /kaniko/.docker/config.json