-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
71 lines (63 loc) · 2.64 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# 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:3.9
# 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"
# 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
cache:
paths:
- .cache/pip
- .config/pypoetry
stages:
- parallel
before_script:
- python -V # Print out python version for debugging
- pip install poetry
- python -m poetry config virtualenvs.path "$CI_PROJECT_DIR/.config/pypoetry"
- python -m poetry config repositories.ae-cashless https://ae-dev.utbm.fr/api/v4/projects/105/packages/pypi
server:
stage: parallel
script:
- cd server
- python -m poetry check
- sed -i -E "s/^version ?= ?\"[0-9][0-9.a-z]+\"/version = \"$(python -c "print('$(cat pyproject.toml | grep --color=never ^version | grep --color=never -oE '[0-9]([0-9.a-z]+)')' + ('.dev+${CI_COMMIT_BRANCH}-$(git rev-parse HEAD)' if ('$CI_COMMIT_BRANCH' != '$CI_DEFAULT_BRANCH') else ''))")\"/" pyproject.toml
- python -m poetry install -E testing
- python -m poetry run cash setup
- python -m poetry run cash setup 2019.json
- python -m poetry run pytest --cov-report=html --cov=cashless_server
- python -m poetry build
- python -m poetry publish -r ae-cashless -u $ci_user -p $ci_token
artifacts:
paths:
- server/dist
- server/htmlcov
# Checks that no version with the same number already exists
server_version_check:
stage: parallel
script:
- cd server
- (! pip install -i https://ae-dev.utbm.fr/api/v4/projects/105/packages/pypi/simple $(cat pyproject.toml | grep --color=never ^name | grep --color=never -oE '".+"' | grep --color=never -oE '[A-z0-9_]+')==$(cat pyproject.toml | grep --color=never ^version | grep --color=never -oE '[0-9]([0-9.a-z]+)'))
only:
- merge_requests
# Check black
black:
stage: parallel
script:
- cd server
- version=$(cat pyproject.toml | grep --color=never black | grep --color=never -oE '[0-9]([0-9.a-z]+)')
- pip install black==$version
- black --check .
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip_black"
cache:
paths:
- .cache/pip_black