use template CI

This commit is contained in:
francisco.schulz 2023-06-20 17:13:08 +02:00
parent d63435e092
commit 892b6e8236

View File

@ -1,59 +1,4 @@
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
include:
- project: "Gitlab/gitlab"
ref: 0.2.3
file: "/ci-templates/research/python_pkg_venv_test_build_release_gitlab-ci.yml"