This commit is contained in:
francisco.schulz 2023-04-18 15:37:19 +02:00
parent 873abdca0c
commit 6d49f0ccb9

59
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,59 @@
default:
image: python:3.8
before_script:
- echo "Run started by ${GITLAB_USER_NAME}"
- echo "Pipeline on branch ${CI_COMMIT_REF_SLUG}"
- echo "$(pip cache dir)"
# install poetry
- pip install poetry
# poetry config
- poetry config installer.max-workers 10
- poetry config virtualenvs.in-project true
- poetry config repositories.gitlab https://gitlab.knecon.com/api/v4/projects/${CI_PROJECT_ID}/packages/pypi
# install package & dependencies
- poetry install --with=dev
# activate virtual environment
- source .venv/bin/activate
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
key: "${CI_JOB_NAME}"
paths:
- .venv/
- ${PIP_CACHE_DIR}/.cache/pip
stages:
# - test
- build
run-tests:
stage: test
script:
- echo "Running pytest against the package"
- pytest ./tests
build-pkg-dev:
stage: build
script:
- export PKG_VERSION="$(poetry version -s)-dev"
- echo "Building DEV package with version ${PKG_VERSION}"
- poetry version ${PKG_VERSION}
- poetry build
- echo "Publishing ..."
- poetry publish --repository gitlab -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD}
when: manual
build-pkg-prod:
stage: build
script:
- export PKG_VERSION="$(poetry version -s)"
- echo "Building PROD package with version ${PKG_VERSION}"
- poetry version ${PKG_VERSION}
- poetry build
- echo "Publishing ..."
- poetry publish --repository gitlab -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD}
rules:
- if: $CI_COMMIT_TAG