2021-09-02 10:38:19 +02:00
|
|
|
# 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/
|
2021-12-01 15:49:59 +01:00
|
|
|
image: python:3.9-bullseye
|
2021-09-02 10:38:19 +02:00
|
|
|
|
|
|
|
# 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"
|
2021-11-10 10:46:32 +01:00
|
|
|
# REGISTRY_USERNAME - secret variable
|
2021-11-01 10:29:12 +01:00
|
|
|
# REGISTRY_PASSWORD - secret variable
|
|
|
|
# REGISTRY_SERVER - secret variable
|
|
|
|
IMAGE_NAME: ${REGISTRY_SERVER}/malves/${CI_PROJECT_NAME}
|
2021-09-02 10:38:19 +02:00
|
|
|
|
|
|
|
# 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/
|
|
|
|
|
2022-02-10 15:12:57 +01:00
|
|
|
stages:
|
|
|
|
- test
|
|
|
|
- build
|
|
|
|
|
2022-07-06 08:12:39 +02:00
|
|
|
.before_script_template: &test
|
|
|
|
before_script:
|
2021-12-01 15:49:59 +01:00
|
|
|
- apt-get update && apt-get -y install python3-venv
|
2021-10-12 03:25:59 +02:00
|
|
|
- python3 -V # Print out python version for debugging
|
|
|
|
- pip3 install pipenv
|
|
|
|
- pipenv install --dev --skip-lock
|
2022-07-06 08:12:39 +02:00
|
|
|
|
|
|
|
test:
|
|
|
|
image: python:${PYVERSION}-bullseye
|
|
|
|
stage: test
|
|
|
|
<<: *test
|
|
|
|
parallel:
|
|
|
|
matrix:
|
2023-08-02 06:32:26 +02:00
|
|
|
- PYVERSION: ["3.8", "3.9", "3.10"]
|
2022-07-06 08:12:39 +02:00
|
|
|
script:
|
2021-11-30 12:13:17 +01:00
|
|
|
- pipenv run pytest --version
|
2023-08-02 10:49:54 +02:00
|
|
|
- PYTHONPATH=./tests/ pipenv run coverage run --source halfapi -m pytest
|
|
|
|
- pipenv run coverage xml
|
2021-10-07 13:58:03 +02:00
|
|
|
- pipenv run halfapi --version
|
2021-09-02 10:38:19 +02:00
|
|
|
|
2023-08-02 10:49:54 +02:00
|
|
|
artifacts:
|
|
|
|
reports:
|
|
|
|
coverage_report:
|
|
|
|
coverage_format: cobertura
|
|
|
|
path: coverage.xml
|
|
|
|
|
2022-02-10 15:12:57 +01:00
|
|
|
build_pypi:
|
|
|
|
stage: build
|
2021-09-02 10:38:19 +02:00
|
|
|
script:
|
2021-12-01 15:49:59 +01:00
|
|
|
- apt-get update && apt-get -y install python3-venv
|
2021-10-12 03:25:59 +02:00
|
|
|
- python3 -V # Print out python version for debugging
|
|
|
|
- pip3 install pipenv
|
|
|
|
- pipenv install --dev --skip-lock
|
2021-09-02 10:38:19 +02:00
|
|
|
- pipenv run python -m build --sdist
|
|
|
|
- pipenv run python -m build --wheel
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- dist/*.whl
|
2022-02-10 15:31:30 +01:00
|
|
|
rules:
|
2022-02-10 15:52:20 +01:00
|
|
|
- if: '$CI_COMMIT_TAG != ""'
|
2022-02-10 15:31:30 +01:00
|
|
|
variables:
|
|
|
|
TAG: $CI_COMMIT_TAG
|
2021-10-12 03:13:25 +02:00
|
|
|
|
2022-02-10 15:12:57 +01:00
|
|
|
build_container:
|
2022-02-10 15:52:20 +01:00
|
|
|
rules:
|
|
|
|
- if: '$CI_COMMIT_TAG != ""'
|
|
|
|
variables:
|
|
|
|
IMGTAG: $CI_COMMIT_TAG
|
|
|
|
- if: '$CI_COMMIT_REF_NAME == "devel"'
|
|
|
|
variables:
|
|
|
|
IMGTAG: "latest"
|
2022-02-10 15:12:57 +01:00
|
|
|
stage: build
|
2021-11-16 17:03:21 +01:00
|
|
|
image: $CI_REGISTRY/devtools/kaniko
|
2021-10-12 03:13:25 +02:00
|
|
|
script:
|
2022-02-10 15:52:20 +01:00
|
|
|
- echo "Will upload image halfapi:\"$IMGTAG\""
|
2021-11-16 17:03:21 +01:00
|
|
|
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
|
2022-03-14 15:24:57 +01:00
|
|
|
- /kaniko/executor --force --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY/malves/halfapi:"$IMGTAG"
|
2021-11-16 17:03:21 +01:00
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- /kaniko/.docker/config.json
|