-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
174 lines (151 loc) · 3.87 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
image: registry.gitlab.com/kimlab/linux-anvil:latest
stages:
- lint
- build
- test
- deploy
cache:
key: ${CI_COMMIT_REF_NAME}
paths:
- .conda_packages
# === Variables ===
variables:
PACKAGE_VERSION: 0.1.1
.py35: &py35
PYTHON_VERSION: "3.5"
.py36: &py36
PYTHON_VERSION: "3.6"
# === Configurations ===
.conda_configure: &conda_configure
before_script:
# Conda environment variables
- export CONDA_PKGS_DIRS="${CI_PROJECT_DIR}/.conda_packages"
# Make conda cache and bld folders
- mkdir -p "${CI_PROJECT_DIR}/conda-bld" "${CONDA_PKGS_DIRS}"
# Conda configure
- conda config --set channel_priority true
- conda config --append pkgs_dirs "${CONDA_PKGS_DIRS}"
- conda config --append channels conda-forge
- conda config --append channels pytorch
- conda config --append channels ostrokach-forge
- conda config --append channels bioconda
- case "${PACKAGE_VERSION}" in
*dev*)
conda config --append channels kimlab;
conda config --append channels kimlab/label/dev;
;;
*)
conda config --append channels kimlab;
;;
esac
# === Lint ===
lint:
stage: lint
<<: [*conda_configure]
variables:
<<: [*py36]
script:
- conda install -yq "python=${PYTHON_VERSION}" isort flake8 mypy
- python -m isort -p ${CI_PROJECT_NAME} -c
- python -m flake8
- python -m mypy -p ${CI_PROJECT_NAME}
# === Build ===
.build: &build
stage: build
script:
- cd "${CI_PROJECT_DIR}/.conda"
- conda build .
--no-test
--python $PYTHON_VERSION
--output-folder "${CI_PROJECT_DIR}/conda-bld"
artifacts:
paths:
- conda-bld
build-py36:
<<: [*conda_configure, *build]
variables:
<<: [*py36]
# === Test ===
.test: &test
stage: test
script:
# Restore built packages
- cp -r $CI_PROJECT_DIR/conda-bld/* /opt/conda/conda-bld/
- conda index /opt/conda/conda-bld/
# Run tests
- cd $CI_PROJECT_DIR/.conda
- conda build .
--test
--python $PYTHON_VERSION
coverage: /^TOTAL.* (\d+\%)/
artifacts:
paths:
- environment-py${PYTHON_VERSION/./}.yml
test-py36:
<<: [*conda_configure, *test]
dependencies:
- build-py36
variables:
<<: [*py36]
# === Pages ===
.docs: &docs
stage: test
script:
# Restore built packages
- cp -r $CI_PROJECT_DIR/conda-bld/* /opt/conda/conda-bld/
- conda index /opt/conda/conda-bld/
# Install required packages
- conda install -yq --use-local "python=$PYTHON_VERSION" $CI_PROJECT_NAME
- conda install -yq nbconvert ipython ipykernel pandoc
- pip install -q sphinx sphinx_rtd_theme recommonmark nbsphinx
# Build docs
- sphinx-build docs public
dependencies:
- build-py36
variables:
<<: [*py36]
test-pages:
<<: [*conda_configure, *docs]
except:
- master
- tags
pages:
<<: [*conda_configure, *docs]
only:
- master
- tags
except:
- triggers
artifacts:
paths:
- public
# === Deploy ===
.deploy: &deploy
stage: deploy
before_script:
- conda install twine -yq --no-channel-priority
script:
# Rename wheels from `-linux_x86_64.whl` to `-manylinux1_x86_64.whl`
# so that they can be uploaded to PyPI.
- for i in $CI_PROJECT_DIR/conda-bld/linux-64/*.whl ; do
echo $i;
mv "${i}" "${i%%-linux_x86_64.whl}-manylinux1_x86_64.whl";
done
# Upload package to Anaconda and PyPi repos.
- case "${PACKAGE_VERSION}" in
*dev*)
anaconda -t $ANACONDA_TOKEN upload $CI_PROJECT_DIR/conda-bld/linux-64/*.tar.bz2 -u ${CI_PROJECT_NAMESPACE} --label dev --force;
;;
*)
anaconda -t $ANACONDA_TOKEN upload $CI_PROJECT_DIR/conda-bld/linux-64/*.tar.bz2 -u ${CI_PROJECT_NAMESPACE};
twine upload $CI_PROJECT_DIR/conda-bld/linux-64/*.whl;
;;
esac
only:
- master
except:
- triggers
deploy-py36:
<<: *deploy
dependencies:
- build-py36