-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
247 lines (224 loc) · 6.2 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
default:
image: condaforge/linux-anvil-cos7-x86_64:latest
stages:
- custom
- lint
- build
- test
- doc
- deploy
# === Variables ===
variables:
PYTHON_VERSION: "3.8"
PACKAGE_VERSION: "0.1.14"
# === Configurations ===
.skip-custom-pipelines:
except:
variables:
- $UPDATE_PAGES
- $BUILD_IMAGE
- $MIRROR_TO_GITHUB
.configure-conda:
# Set conda envs and pkgs dirs
script: &configure-conda
- |
cat <<EOF > ~/.condarc
channel_priority: true
channels:
- pytorch
- conda-forge
- defaults
- kimlab
- ostrokach-forge
- bioconda
- salilab
EOF
- conda install -yq mamba
# === Lint ===
lint:
stage: lint
extends:
- .skip-custom-pipelines
before_script:
- *configure-conda
script:
- mamba create -n lint -q "python=${PYTHON_VERSION}" isort toml flake8 mypy black
- source activate lint
- python -m isort -p ${CI_PROJECT_NAME} -c .
- python -m flake8 src
- 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 src/${CI_PROJECT_NAME} || true
# === Build ===
build:
stage: build
before_script:
- *configure-conda
script:
- mamba install -yq conda conda-build conda-verify conda-forge-pinning
- cd "${CI_PROJECT_DIR}/devtools/conda"
- >
mamba 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
before_script:
- *configure-conda
script:
# Create conda environment for testing
- mamba create -n test -q -c file://${CI_PROJECT_DIR}/conda-bld --strict-channel-priority
"python=${PYTHON_VERSION}" ${CI_PROJECT_NAME} pytest pytest-cov pytest-benchmark || true
- source activate test
# Run tests
- PKG_INSTALL_DIR=$(python -c "import pagnn; print(pagnn.__path__[0])")
- python -m pytest
-c pyproject.toml
--cov="${PKG_INSTALL_DIR}"
--cov-config=pyproject.toml
--color=yes
"tests/"
# Coverage
- mkdir coverage
- mv .coverage coverage/.coverage.all
artifacts:
paths:
- coverage
dependencies:
- build
# === Document ===
# NB: Has to be called "docs" for the pages script to work.
docs:
stage: doc
before_script:
- *configure-conda
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} nbconvert ipython ipykernel pandoc || true
- source activate test
- pip install -q 'sphinx>=3.4' sphinx_rtd_theme msmb_theme nbsphinx coverage toml
'recommonmark>=0.5' sphinx-markdown-tables
# 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
before_script:
- *configure-conda
script:
- anaconda -t $ANACONDA_TOKEN upload $CI_PROJECT_DIR/*/*/*.tar.bz2 -u ostrokach-forge --no-progress --force
only:
- tags
dependencies:
- build
deploy-pypi:
stage: deploy
before_script:
- *configure-conda
script:
- python -m pip install -q twine wheel
- python setup.py sdist bdist_wheel
- twine upload dist/*
only:
- tags
trigger-custom-pipelines:
image:
name: ubuntu:20.04
stage: deploy
before_script:
- apt-get -y -qq update
- apt-get -y -qq install curl jq
script:
- >
BUILD_JOB_ID=$( \
curl --globoff -sS --header "PRIVATE-TOKEN: ${GITLAB_CI_TOKEN}" \
"https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/jobs?scope[]=success" \
| jq '.[] | select(.name == "build") | .id' \
)
# Update docker image
- curl --request POST
--form token="${CI_JOB_TOKEN}"
--form ref=${CI_COMMIT_TAG}
--form "variables[BUILD_IMAGE]=true"
--form "variables[BUILD_JOB_ID]=${BUILD_JOB_ID}"
https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/trigger/pipeline
# 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
only:
- tags
# === Custom pipelines ===
pages:
stage: custom
before_script:
- pip install gitlab_versioned_pages
script:
- mkdir -p ./public
- python -m gitlab_versioned_pages
--project-id ${CI_PROJECT_ID}
--job-name docs
--private-token ${CI_DOCS_TOKEN}
--output-dir ./public
--url "https://${CI_PROJECT_NAMESPACE}.gitlab.io/${CI_PROJECT_NAME}"
artifacts:
paths:
- public
only:
variables:
- $UPDATE_PAGES
.install-ssh-client:
script: &install-ssh-client
- "which ssh-agent || ( apt-get install -y -qq -o=Dpkg::Use-Pty=0 openssh-client -y )"
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$KNOWN_HOSTS" >> ~/.ssh/known_hosts
.mirror-to-github:
stage: deploy
image:
name: ubuntu:20.04
before_script:
# Install global dependencies
- apt-get update -y -qq -o=Dpkg::Use-Pty=0
- apt-get install -y -qq -o=Dpkg::Use-Pty=0 curl rsync gettext-base git git-lfs
# Install ssh client
- export SSH_PRIVATE_KEY="${GITHUB_SSH_PRIVATE_KEY}"
- export KNOWN_HOSTS="${GITHUB_KNOWN_HOSTS}"
- *install-ssh-client
script:
- git fetch --all
- git remote add mirror [email protected]:ostrokach/protein-adjacency-net.git
- git checkout master
- git push mirror master --no-verify --force
- git push mirror master --no-verify --tags --force
needs: []
# only:
# variables:
# - $MIRROR_TO_GITHUB