forked from pydna-group/pydna
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathci.sh
262 lines (254 loc) · 9.46 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
#!/usr/bin/env bash
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 "=============================================================="
echo "Build information:"
echo "=============================================================="
if [[ "$com" = "$tag" ]]&&[[ $dirty = $tagname ]]
then
echo "Tagged commit : $tagname"
tagged_commit=true
re_final="^[0-9]\.[0-9]\.[0-9]$"
re_pre="^[0-9]\.[0-9]\.[0-9](a|b|rc)[0-9]+$"
if [[ $tagname =~ $re_final ]]
then
echo "Tag indicate Final release"
echo "deploy to pypi and anaconda.org with label 'main'."
pypiserver="pypi"
condalabel="main"
elif [[ $tagname =~ $re_pre ]]
then
echo "Release tag indicate pre release"
echo "deploy sdist zip package to pypi "
echo "conda package anaconda.org with label 'test'."
pypiserver="testpypi"
condalabel="test"
else
echo "Build cancelled because"
echo "release tag ($tagname) was not recognized"
echo "or"
echo "$dirty != $tagname"
exit 0
fi
elif [[ $msg = *"skip"* ]]
then
echo "Not a tagged commit"
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
echo "=============================================================="
if [[ $CI = true ]]||[[ $CI = True ]]
then
echo "Running on CI server"
echo "Creating a .pypirc file for setuptools"
echo "[server-login]
username: $pypiusername
password: $pypipassword
[distutils]
index-servers=
pypi
testpypi
[testpypi]
repository = https://test.pypi.org/legacy/
username = $pypiusername
password = $pypipassword
[pypi]
username = $pypiusername
password = $pypipassword" > $HOME/.pypirc
if [[ $TRAVIS = true ]]
then
echo "Running on TRAVIS, download Miniconda for MacOSX"
miniconda="wget -q http://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O Miniconda_latest.sh"
elif [[ $APPVEYOR = true ]]||[[ $APPVEYOR = True ]]
then
echo "Running on APPVEYOR, use installed Miniconda for Windows"
miniconda="source appveyor_source_file.sh"
#miniconda="wget -q https://repo.continuum.io/miniconda/Miniconda3-latest-Windows-x86_64.exe -O Miniconda_latest.sh"
elif [[ $CIRCLECI = true ]]
then
miniconda="wget -q https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O Miniconda_latest.sh"
elif [[ $CI_NAME = codeship ]]
then
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
#conda install conda-verify -yq
#conda install jinja2 -yq
conda update -yq conda
conda update -yq pip
conda config --prepend channels conda-forge
conda config --append channels BjornFJohansson
else
echo "Not running on CI server, probably running on local computer"
local_computer=true
fi
set -x
if [[ $tagged_commit = true ]]
then
echo "build conda package and setuptools package(s)"
conda install -yq conda-build
conda-build -V
conda create -yq -n pydnacondabuild35 python=3.5 anaconda-client pypandoc pandoc nbval
conda create -yq -n pydnacondabuild36 python=3.6 anaconda-client pypandoc pandoc nbval
conda create -yq -n pydnapipbuild35 python=3.5 anaconda-client pypandoc pandoc urllib3
conda create -yq -n pydnapipbuild36 python=3.6 anaconda-client pypandoc pandoc
conda create -yq -n twine python=3.5 twine pyOpenSSL ndg-httpsclient pyasn1
rm -rf dist
rm -rf build
rm -rf tests/htmlcov
pth1="$(conda build . --output --py 3.5)"
pth2="$(conda build . --output --py 3.6)"
echo $pth1
echo $pth2
source activate pydnacondabuild35
conda build --python 3.5 --no-include-recipe --dirty .
source activate pydnacondabuild36
conda build --python 3.6 --no-include-recipe --dirty .
if [[ $CI = true ]]||[[ $CI = True ]]
then
set +x
anaconda -t $TOKEN upload $pth1 --label $condalabel --force
anaconda -t $TOKEN upload $pth2 --label $condalabel --force
set -x
else
anaconda upload $pth1 --label $condalabel --force
anaconda upload $pth2 --label $condalabel --force
fi
if [[ $TRAVIS = true ]] # MacOSX on Travis
then
brew update
source activate pydnapipbuild35
conda upgrade -yq pip
python setup.py build bdist_wheel bdist_egg
source activate pydnapipbuild36
conda upgrade -yq pip
python setup.py build bdist_wheel bdist_egg
if [[ $condalabel = "main" ]] # bdist_egg, bdist_wheel do not handle alpha versions, so no upload unless final release.
then
source activate twine
twine upload -r $pypiserver dist/pydna*.whl --skip-existing
twine upload -r $pypiserver dist/pydna*.egg --skip-existing
else
echo "pre release, no upload to pypi."
fi
elif [[ $APPVEYOR = true ]]||[[ $APPVEYOR = True ]] # Windows on appveyor
then
source activate pydnapipbuild35
conda upgrade -yq pip
python setup.py build bdist_wheel bdist_egg
source activate pydnapipbuild36
conda upgrade -yq pip
python setup.py build bdist_wheel bdist_egg
if [[ $condalabel = "main" ]] # bdist_wininst does not handle alpha versions, so no upload unless final release.
then
source activate twine
twine upload -r $pypiserver dist/pygenome*.whl --skip-existing
twine upload -r $pypiserver dist/pygenome*.egg --skip-existing
else
echo "pre release, no upload to pypi."
fi
appveyor PushArtifact dist/*
elif [[ $CI_NAME = codeship ]] # Linux on codeship
then
source activate pydnapipbuild35
conda upgrade -yq pip
python setup.py sdist --formats=zip
source activate pydnapipbuild36
conda upgrade -yq pip
python setup.py sdist --formats=zip
source activate twine
twine upload -r $pypiserver dist/pydna*.zip --skip-existing
elif [[ $local_computer = true ]]
then
echo "Local linux: python setup.py sdist --formats=zip bdist_wheel"
source activate pydnapipbuild35
conda upgrade -yq pip
python setup.py sdist --formats=zip bdist_wheel
source activate pydnapipbuild36
conda upgrade -yq pip
python setup.py sdist --formats=zip bdist_wheel
source activate twine
twine upload -r $pypiserver dist/pydna*.zip --skip-existing
twine upload -r $pypiserver dist/pydna*.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
#ls dist
else
echo "create test environment for python 3.5"
conda env create -f test_environment35.yml
source activate testenv35
which python
python --version
python run_test.py
echo
echo "create test environment for python 3.6"
conda env create -f test_environment36.yml
source activate testenv36
which python
python --version
python run_test.py
source activate root
conda remove -n testenv35 --all -q
conda remove -n testenv36 --all -q
if [[ $local_computer = true ]]
then
conda remove -n pydnacondabuild35 --all -q
conda remove -n pydnacondabuild36 --all -q
conda remove -n pydnapipbuild35 --all -q
conda remove -n pydnapipbuild36 --all -q
conda remove -n twine --all -q
source activate root
conda remove -n testenv35 --all -q
conda remove -n testenv36 --all -q
fi
fi