-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathci.sh
273 lines (213 loc) · 9.21 KB
/
ci.sh
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
#!/usr/bin/env bash
#export TWINE_REPOSITORY="https://test.pypi.org"
#condalabel="test"
condalabel="main"
echo "=============================================================="
echo "BASH_VERSION" $BASH_VERSION
echo $(git --version)
tagname="$(git describe --abbrev=0 --tags)"
tag="$(git rev-list $tagname | head -n 1)"
com="$(git rev-parse HEAD)"
dirty=$(git describe --tags --dirty --always)
msg=$(git log -1 --pretty=%B)
echo "=============================================================="
echo "Establish git variables:"
echo "=============================================================="
echo "Current commit hash : $com"
echo "Dirty tag : $dirty"
echo "Commit msg : $msg"
echo "=============================================================="
echo "Environment variables:"
echo "=============================================================="
echo "CI = $CI"
echo "APPVEYOR = $APPVEYOR"
echo "CIRCLECI = $CIRCLECI"
echo "TRAVIS = $TRAVIS"
echo "CODESHIP = $CI_NAME"
echo "APPVEYOR_REPO_BRANCH = $APPVEYOR_REPO_BRANCH"
echo "TRAVIS_BRANCH = $TRAVIS_BRANCH"
echo "CI_BRANCH = $CI_BRANCH"
echo "=============================================================="
echo "Build information:"
echo "=============================================================="
if [[ "$com" = "$tag" ]]&&[[ $dirty = $tagname ]]
then
echo "Tagged commit: $tagname"
PEP440="^([1-9]*!)?(0|[1-9]*)(\.(0|[1-9]*))*((a|b|rc)(0|[0-9]*))?(\.post(0|[1-9]*))?(\.dev(0|[1-9]*))?$"
if [[ $tagname =~ $PEP440 ]]
then
echo "Git tag is a canonical PEP440 release version number"
echo "deploy a setuptools package to pypi."
echo "deploy conda packages to anaconda.org in the BjornFJohansson channel"
tagged_commit=true
else
echo "Git tag is *NOT* a canonical PEP440 release version number"
echo "git tag ($tagname) was not recognized"
echo "or"
echo "$dirty != $tagname"
exit 0
fi
elif [[ $msg = *"skip"* ]]
then
echo "'skip' found in commit msg: '$msg'"
echo "tests and builds skipped."
echo "=============================================================="
exit 0
else
echo "'skip' not found in commit msg: '$msg'"
echo "but commit not tagged or tag dirty"
echo "test suit will be run."
tagged_commit=false
unset VIRTUAL_ENV
fi
if [[ $CI = true ]]||[[ $CI = True ]]
then
echo "====================Running on CI server======================"
[[ ! -z "$TWINE_USERNAME" ]] && echo "TWINE_USERNAME is set" || echo "TWINE_USERNAME is empty"
[[ ! -z "$TWINE_PASSWORD" ]] && echo "TWINE_PASSWORD is set" || echo "TWINE_PASSWORD is empty"
[[ ! -z "$ANACONDATOKEN" ]] && echo "ANACONDATOKEN is set" || echo "ANACONDATOKEN is empty"
if [[ $TRAVIS = true ]]
then
branch=$TRAVIS_BRANCH
echo "=============================================================="
echo "Running on TRAVIS, download Miniconda3 for MacOSX"
echo "=============================================================="
miniconda="wget -q http://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O Miniconda_latest.sh"
elif [[ $APPVEYOR = true ]]||[[ $APPVEYOR = True ]]
then
branch=$APPVEYOR_REPO_BRANCH
echo "=============================================================="
echo "Running on APPVEYOR, use installed Miniconda3 for Windows"
echo "=============================================================="
miniconda="source appveyor_source_file.sh"
elif [[ $CIRCLECI = true ]]
then
branch=$CI_BRANCH
echo "=============================================================="
echo "Running on Circle CI, download Miniconda3 for Linux"
echo "=============================================================="
miniconda="wget -q https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O Miniconda_latest.sh"
elif [[ $CI_NAME = codeship ]]
then
echo "=============================================================="
echo "Running on Codeship CI, download Miniconda3 for Linux"
echo "=============================================================="
miniconda="wget -q https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O Miniconda_latest.sh"
else
echo "Running on CI server but none of the expected environment variables are set to true"
echo "CI = $CI"
echo "TRAVIS = $TRAVIS"
echo "APPVEYOR = $APPVEYOR"
echo "CIRCLECI = $CIRCLECI"
echo "CI_NAME = $CI_NAME"
exit 1
fi
echo "execute: $miniconda"
$miniconda
if [[ -f Miniconda_latest.sh ]]
then
bash Miniconda_latest.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
rm Miniconda_latest.sh
fi
conda config --set always_yes yes --set show_channel_urls yes --set anaconda_upload no
conda update -yq conda
conda update -yq pip
conda config --append channels conda-forge
conda config --append channels BjornFJohansson
else
echo "Not running on CI server, probably running on local computer"
branch=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)
local_computer=true
fi
echo "=============================================================="
echo "= create conda environments ="
echo "=============================================================="
conda env create -f python36.yml
conda env create -f python37.yml
if [[ $tagged_commit = true ]]
then
echo "=============================================================="
echo "= build conda package and setuptools package(s) ="
echo "=============================================================="
conda install -yq -c anaconda conda-build
conda install -yq -c anaconda conda-verify
echo "=============================================================="
echo "= conda-build version used: "
echo "=============================================================="
conda-build -V
echo "=============================================================="
rm -rf dist
rm -rf build
rm -rf tests/htmlcov
pth2="$(conda build . --output --py 3.6)"
pth3="$(conda build . --output --py 3.7)"
echo "=============================================================="
echo "= build path(s) ="
echo "=============================================================="
echo $pth2
echo $pth3
echo "=============================================================="
source activate python36
conda build --python 3.6 --no-include-recipe --dirty .
source activate python37
conda build --python 3.7 --no-include-recipe --dirty .
echo "========conda upload(s)======================================="
if [[ $CI = true ]]||[[ $CI = True ]]
then
echo "=============================================================="
echo "= anaconda upload using ANACONDATOKEN ="
echo "=============================================================="
anaconda -t $ANACONDATOKEN upload $pth2 --label $condalabel --force
anaconda -t $ANACONDATOKEN upload $pth3 --label $condalabel --force
else
echo "=============================================================="
echo "= anaconda upload ="
echo "=============================================================="
anaconda upload $pth2 --label $condalabel --force
anaconda upload $pth3 --label $condalabel --force
fi
if [[ $TRAVIS = true ]] # MacOSX on Travis
then
source activate python36
python setup.py build bdist_wheel
source activate python37
python setup.py build bdist_wheel
elif [[ $APPVEYOR = true ]]||[[ $APPVEYOR = True ]] # Windows on appveyor
then
source activate python36
python setup.py build bdist_wheel
source activate python37
python setup.py build bdist_wheel
appveyor PushArtifact dist/*
elif [[ $CI_NAME = codeship ]] # Linux on codeship
then
source activate python36
python setup.py build bdist_wheel
source activate python37
python setup.py build bdist_wheel
twine upload dist/*.whl --skip-existing
elif [[ $local_computer = true ]]
then
echo "Local linux: python setup.py sdist --formats=zip bdist_wheel"
source activate python36
python setup.py build bdist_wheel
source activate python37
python setup.py build bdist_wheel
twine upload dist/*.whl --skip-existing
else
echo "Running on CI server but none of the expected environment variables are set to true"
echo "CI = $CI"
echo "TRAVIS = $TRAVIS"
echo "APPVEYOR = $APPVEYOR"
echo "CIRCLECI = $CIRCLECI"
exit 1
fi
else
echo "====================tests================="
source activate python36
python run_test__.py
source activate python37
python run_test__.py
#codecov
fi