-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
88 lines (83 loc) · 2.69 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
image: python:3.9-slim
stages:
- test
- external
- tag
- release
variables:
POETRY_VIRTUALENVS_CREATE: 0
test:
stage: test
before_script:
- apt-get update && apt-get install -y build-essential git curl
- curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
- ln -sf /root/.poetry/bin/poetry /usr/local/bin/poetry
- install_cmd="poetry install --no-root"
- if [ -n "$POETRY_EXTRAS" ]; then install_cmd="$install_cmd --extras \"$POETRY_EXTRAS\""; fi
- echo $install_cmd
- eval $install_cmd
script:
- pytest --cov-report=xml --cov-report=term
cache:
paths:
- ~/.cache/pypoetry/
except:
- schedules
external:
stage: external
before_script:
- apt-get update && apt-get install -y build-essential git curl
- curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
- ln -sf /root/.poetry/bin/poetry /usr/local/bin/poetry
- install_cmd="poetry install --no-root"
- if [ -n "$POETRY_EXTRAS" ]; then install_cmd="$install_cmd --extras \"$POETRY_EXTRAS\""; fi
- echo $install_cmd
- eval $install_cmd
script:
- pytest -vvv -m external
cache:
paths:
- ~/.cache/pypoetry/
only:
- schedules
create-tag:
stage: tag
variables:
GIT_SSH_COMMAND: ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
PYTHON_SEMANTIC_RELEASE_VERSION: 7.9.0
before_script:
- apt-get update && apt-get install -y build-essential git openssh-client sshpass
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- git config --global user.email "[email protected]"
- git config --global user.name "Gitlab CI"
- git remote add gitlab-ssh [email protected]:${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}.git || true
script:
- pip install python-semantic-release==$PYTHON_SEMANTIC_RELEASE_VERSION
- semantic-release version
- git fetch gitlab-ssh $CI_COMMIT_REF_SLUG
- git push gitlab-ssh HEAD:$CI_COMMIT_REF_SLUG --tags
cache:
paths:
- ~/.cache/pip/
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: '$CI_COMMIT_TAG'
when: never
- if: '$CI_COMMIT_BRANCH == "master"'
when: manual
publish-pypi:
stage: release
before_script:
- apt-get update && apt-get install -y build-essential git curl
- curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
- ln -sf /root/.poetry/bin/poetry /usr/local/bin/poetry
- poetry config pypi-token.pypi $PYPI_API_TOKEN
script:
- poetry publish --build
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: '$CI_COMMIT_TAG'
when: manual