-
Notifications
You must be signed in to change notification settings - Fork 8
/
.gitlab-ci.yml
222 lines (202 loc) · 5.24 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
default:
image: condaforge/linux-anvil-cos7-x86_64:latest
stages:
- custom
- linting
- build
- test
- doc
- deploy
# === Variables ===
variables:
PACKAGE_VERSION: "0.1.25"
PYTHON_VERSION: "3.8"
# === Configurations ===
.skip-custom-pipelines:
except:
variables:
- $UPDATE_PAGES
- $BUILD_IMAGE
.configure:
extends:
- .skip-custom-pipelines
before_script:
# Set conda envs and pkgs dirs
- |
cat <<EOF > ~/.condarc
channel_priority: true
channels:
- pytorch
- conda-forge
- defaults
- kimlab
- ostrokach-forge
- bioconda
- salilab
- omnia
EOF
# === Lint ===
lint:
stage: linting
extends:
- .configure
script:
- conda create -n lint -q "python=${PYTHON_VERSION}" isort toml flake8 mypy black
- source activate lint
- python -m isort ${CI_PROJECT_NAME} --check --diff
- python -m flake8 ${CI_PROJECT_NAME}
- python -m black --config pyproject.toml --check .
# MyPy does not support namespace packages until this issue gets resolved:
# https://github.com/python/mypy/issues/1645
- python -m mypy -p ${CI_PROJECT_NAME} || true
# === Build ===
build:
stage: build
extends:
- .configure
script:
- conda install -yq conda conda-build conda-verify conda-forge-pinning
- cd "${CI_PROJECT_DIR}/.ci/conda"
- >
conda build .
--variant-config-files /opt/conda/conda_build_config.yaml
--variants "{python: [${PYTHON_VERSION}], numpy: [1.16], python_impl: [cpython]}"
--no-test
--output-folder "$CI_PROJECT_DIR/conda-bld"
artifacts:
paths:
- conda-bld
# === Test ===
test:
stage: test
extends:
- .configure
script:
# Create conda environment for testing
- conda update -yq conda
- conda create -n test -q -c file://${CI_PROJECT_DIR}/conda-bld --strict-channel-priority
"python=${PYTHON_VERSION}" ${CI_PROJECT_NAME} torch-geometric pytest pytest-cov || true
- source activate test
# Run tests
- PKG_INSTALL_DIR=$(python -c "import proteinsolver; print(proteinsolver.__path__[0])")
- python -m pytest
-c setup.cfg
--cov="${PKG_INSTALL_DIR}"
--cov-config=setup.cfg
--color=yes
"tests/"
# Coverage
- mkdir coverage
- mv .coverage coverage/.coverage.all
dependencies:
- build
artifacts:
paths:
- coverage
# === Docs ===
# NB: Has to be called "docs" for the pages script to work.
docs:
stage: doc
extends:
- .configure
script:
# Create conda environment for testing
- conda update -yq conda
- conda create -n test -q -c file://${CI_PROJECT_DIR}/conda-bld --strict-channel-priority
"python=${PYTHON_VERSION}" ${CI_PROJECT_NAME} torch-geometric nbconvert ipython ipykernel pandoc || true
- source activate test
- pip install -q sphinx sphinx_rtd_theme msmb_theme recommonmark sphinx-markdown-tables
nbsphinx coverage
# Build docs
- sphinx-build ${CI_PROJECT_DIR}/docs public
- ln -s . public/docs
# Coverage
- coverage combine coverage/
- coverage report
- coverage html
- mv htmlcov public/
coverage: /^TOTAL.* (\d+\%)/
dependencies:
- build
- test
artifacts:
paths:
- public
when: always
# === Deploy ===
deploy:
stage: deploy
extends:
- .configure
script:
- anaconda -t $ANACONDA_TOKEN upload $CI_PROJECT_DIR/conda-bld/*/*.tar.bz2 -u ostrokach-forge --no-progress
dependencies:
- build
only:
- tags
trigger-custom-pipelines:
stage: deploy
extends:
- .skip-custom-pipelines
image:
name: ubuntu:18.04
before_script:
- apt-get -y -qq update
- apt-get -y -qq install curl
script:
# Update pages
- curl --request POST
--form token="${CI_JOB_TOKEN}"
--form ref=${CI_COMMIT_TAG}
--form "variables[UPDATE_PAGES]=true"
https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/trigger/pipeline
# Update images
- curl --request POST
--form token="${CI_JOB_TOKEN}"
--form ref=${CI_COMMIT_TAG}
--form "variables[BUILD_IMAGE]=true"
https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/trigger/pipeline
only:
- tags
# === Custom pipelines ===
pages:
stage: custom
before_script:
- sudo yum update -y -q
- sudo yum install -y -q unzip
- pip install jinja2 python-gitlab
script:
# Set environment variables
- export OUTPUT_DIR="./public"
- mkdir -p ${OUTPUT_DIR}
# Download all previous docs
- python .ci/pages/download_docs.py
--project-id ${CI_PROJECT_ID}
--job-name docs
--private-token ${CI_DOCS_TOKEN}
--output-dir ${OUTPUT_DIR}
artifacts:
paths:
- public
only:
variables:
- $UPDATE_PAGES
docker-images:
stage: custom
image:
name: docker:latest
services:
- docker:dind
script:
- if [[ ! -z ${CI_COMMIT_TAG} ]] ; then
IMAGE_TAG=${CI_COMMIT_TAG} ;
else
IMAGE_TAG="latest" ;
fi
- echo "${CI_REGISTRY_IMAGE}:${IMAGE_TAG}"
- docker login registry.gitlab.com -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
- docker build -t "${CI_REGISTRY_IMAGE}:${IMAGE_TAG}" .ci/docker/
- docker push "${CI_REGISTRY_IMAGE}:${IMAGE_TAG}"
only:
variables:
- $BUILD_IMAGE