-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
156 lines (143 loc) · 3.51 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
image: "python:3.8-buster"
stages:
- tox
- Documentation
- build
- publish
- update-tox-cache
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache: &global_cache
paths:
- .cache/pip
- venv/
- .tox
- apt-cache/
key: ${CI_COMMIT_REF_SLUG}
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/reference/pip_install/#caching
before_script:
- mkdir -p apt-cache
# pandoc needed for docu, see https://nbsphinx.readthedocs.io/en/0.7.1/installation.html?highlight=pandoc#pandoc
- apt-get update -yq && apt-get update -yq && apt-get -o dir::cache::archives="$(pwd)/apt-cache" install -yq pandoc
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- mv $CONFIG_LOCAL ./config_local.json && echo "retrieved local config"
tox_recreate:
stage: tox
only:
changes:
# recreate environments if dependencies have changed
- requirements.txt
cache:
<<: *global_cache
policy: push
services:
- name: bitnami/minio:latest
alias: remote-storage
variables:
MINIO_ACCESS_KEY: minio-root-user
MINIO_SECRET_KEY: minio-root-password
script:
- pip install tox
- tox -r
artifacts:
paths:
- badges
- docs/_build
- htmlcov
- pylint.html
tox_use_cache:
stage: tox
except:
changes:
# use cache if environments if dependencies haven't changed
- requirements.txt
cache:
<<: *global_cache
policy: pull
services:
- name: bitnami/minio:latest
alias: remote-storage
variables:
MINIO_ACCESS_KEY: minio-root-user
MINIO_SECRET_KEY: minio-root-password
script:
- pip install tox
- tox
artifacts:
paths:
- badges
- docs/_build
- htmlcov
- pylint.html
pages:
cache: {}
stage: Documentation
script:
- mv docs/_build/html/* public/docs
- mv pylint.html public/pylint/index.html
- mv htmlcov/* public/coverage
artifacts:
paths:
- public
only:
- develop
package:
cache:
paths:
- .cache/pip
- venv/
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
stage: build
script:
- |
# Bump version number of develop branch
if [ "$CI_COMMIT_BRANCH" = "develop" ]; then
# Git config
git config user.name "Gitlab CI"
git config user.email "[email protected]"
chmod 0600 $GITLAB_DEPLOY_KEY
# HTTPS clone URL -> git+ssh URL for pushing
export GIT_REPO_URL_SSH=$(echo -n $CI_REPOSITORY_URL | sed -r 's%https?://.*@([^/]+)/%git@\1:%' -)
git remote set-url origin $GIT_REPO_URL_SSH
export GIT_SSH_COMMAND='ssh -i $GITLAB_DEPLOY_KEY -o IdentitiesOnly=yes -o StrictHostKeyChecking=no'
pip install bump2version
apt-get update && apt-get install -y git-lfs
bump2version build --commit
git push -o ci.skip origin HEAD:develop
fi
- pip install setuptools wheel
- python setup.py sdist bdist_wheel
artifacts:
paths:
- dist/*.tar.gz
- dist/*.whl
publish_package:
cache: {}
only:
- tags
- develop
stage: publish
needs: [package]
script:
- pip install twine
- export TWINE_REPOSITORY_URL=$PYPI_REPO_URL
- export TWINE_USERNAME=$PYPI_REPO_USER
- export TWINE_PASSWORD=$PYPI_REPO_PASS
- twine upload dist/*
update_tox_cache:
needs: []
except:
changes:
- requirements.txt
when: manual
allow_failure: true
cache:
<<: *global_cache
policy: push
stage: update-tox-cache
script:
- pip install tox
- tox -r