forked from oPromessa/flickr-uploader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
252 lines (225 loc) · 16.1 KB
/
.travis.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
248
249
250
251
252
# -----------------------------------------------------------------------------
# Use travis settings maximum_number_of_builds --set 1 as the builds envs depend on flickr
#
# Sections:
# python
# branches
# before_install
# install
# env
# before_script
# script
# after_failure
# after_script
# deploy
# -----------------------------------------------------------------------------
# language
language: python
python:
- "2.7"
- "3.6.4"
# - "3.7-dev"
# - "nightly"
# -----------------------------------------------------------------------------
#branches:
# except:
# - dev-jun18
# -----------------------------------------------------------------------------
before_install:
# For use with wget into github account
- echo -e "machine github.com\n login $CI_USER\n password $CI_USER_PASSWORD" >> ~/.netrc
# Install exiftool
- sudo apt-get -qq update
- sudo apt-get install -y libimage-exiftool-perl
- which exiftool
# -----------------------------------------------------------------------------
# install dependencies
install:
- pip install -r requirements.txt
# Get deletr to delete all pics Flickr prior to a run
- wget https://github.com/oPromessa/flickr-deletr/archive/master.tar.gz -O flickr-deletr-master.tar.gz
- tar zxvf flickr-deletr-master.tar.gz
# Run python setup.py install. Allow --old-and-unmanageable to copy ini file to etc folder
- python setup.py install --old-and-unmanageable
- which uploadr.py
# -----------------------------------------------------------------------------
# env
env:
global:
- PYTHONPATH=..:.
- LC_ALL=en_US.utf8
- LANG=en_US.utf8
- VerboseVar=-v # Set to -v for Verbose option of uploadr
- BadFilesVar=-b
- ExcludedVar=--remove-excluded
- ListPhotosNotInSet="-l 100"
- TAIL_LINES=20 # Tail $TAIL_LINES for output logging. Default: 20
- WAIT_TIME=1 # Sleep time between first and second run
- DeleteAllFromFlickr=0 # To ensure an empty Flickr. Set DeleteAllFromFlickr=1. 0 otherwise.
# -----------------------------------------------------------------------------
# Matrix of Test Scenarios
# Help
# DryRunNoToken
# Badfiles (disabled for now)
# Multiprocessing
# addAlbumsMigrate
# RemoveReplace, Multiprocessing, Clean BadFiles, ListPhotosNotInSet
# ExcludedFolders+IgnoredFiles in Single Processing mode. Also test cleaning up badfiles database entries and listing files not in set. Plus RAW files.
# Old273INI to test previous INI config file format using os.path.dirname(sys.argv[0]) vs os.getcwd()
# NoVerbose
matrix:
# TestScenario: Help, DryRunNoToken, BadFiles, MultiProcessing, Remove, Replace, RemoveReplace, Old273INI
- TestScenario=Help UploadrOptions="$VerboseVar --help" DeleteAllFromFlickr=1
- TestScenario=DryRunNoToken UploadrOptions="$VerboseVar -n -p 10"
#- TestScenario=BadFiles UploadrOptions="$VerboseVar $BadFilesVar"
- TestScenario=MultiProcessing UploadrOptions="$VerboseVar $BadFilesVar -p 20"
- TestScenario=addAlbumsMigrate UploadrOptions="$VerboseVar -p 20"
- TestScenario=RemoveReplace UploadrOptions="$VerboseVar $BadFilesVar $ListPhotosNotInSet -p 10 -c"
- TestScenario=ExcludedFolders UploadrOptions="$VerboseVar $BadFilesVar $ExcludedVar -c -l 50"
- TestScenario=Old273INI UploadrOptions="$VerboseVar $BadFilesVar $ExcludedVar -p 10"
- TestScenario=NoVerbose UploadrOptions="-p 20"
# -----------------------------------------------------------------------------
# before_script
# - Get database token ready
# - Get uploadr.ini from tests
# - Use environment secure variable for private settings
before_script:
- pwd
- pythonVersion=`python -V 2>&1 | cut -d\ -f2`
- echo $pythonVersion
- echo Travis Python Version
- echo ${TRAVIS_PYTHON_VERSION}
- cp tests/uploadr.ini .
- cp tests/uploadr.ini /home/travis/virtualenv/python$pythonVersion/etc/uploadr.ini || cp tests/uploadr.ini /home/travis/virtualenv/python${TRAVIS_PYTHON_VERSION}/etc/uploadr.ini
- grep PATH uploadr.ini
- echo "INSERT INTO oauth_tokens ( api_key, lookup_key, oauth_token, oauth_token_secret, access_level, fullname, username, user_nsid) VALUES ( '"$api_key"', '', '"$oauth_token"', '"$oauth_token_secret"', 'delete', '"$fullname"', '"$username"', '"$user_nsid"');" | sqlite3 token/oauth-tokens.sqlite
- sqlite3 token/oauth-tokens.sqlite 'SELECT * FROM oauth_tokens;'
# - find "./tests/Test Photo Library" -type f -exec md5sum '{}' \;
# Prevent errors in case log and err files are not generated
- touch build.txt
- touch /home/travis/build/oPromessa/flickr-uploader/uploadr.err
- touch /home/travis/build/oPromessa/flickr-uploader/nohup.log
- touch /home/travis/build/oPromessa/flickr-uploader/nohup.lst
- touch /home/travis/build/oPromessa/flickr-uploader/dbrun1.log
- touch /home/travis/build/oPromessa/flickr-uploader/dbrun2.log
# INI File for deletr... to bypass erro "pytest --doctest-modules" exited with 2.
- cp flickr-deletr-master/tests/deletr.ini /home/travis/virtualenv/python$pythonVersion/bin/deletr.ini || cp flickr-deletr-master/tests/deletr.ini /home/travis/virtualenv/python${TRAVIS_PYTHON_VERSION}/bin/deletr.ini
# -----------------------------------------------------------------------------
# run script for tests
script:
# pytest --flakes (Code analysis)
- pytest -v --flakes
# pytest
- pytest -v
# pytest --doctest-modules
- pytest --doctest-modules
# flake8
- flake8
# unittests
- python tests/TestModules.py
# DELETE RUN: DeleteAllFromFlickr ==1 -----------------------------------------
# Comaptible with Python 2.7 only!
- if [[ $TRAVIS_PYTHON_VERSION == 2* && $DeleteAllFromFlickr == 1 ]]; then cp flickr-deletr-master/tests/deletr.ini flickr-deletr-master/deletr.ini; fi
- if [[ $TRAVIS_PYTHON_VERSION == 2* && $DeleteAllFromFlickr == 1 ]]; then cp token/oauth-tokens.sqlite flickr-deletr-master/token/oauth-tokens.sqlite; fi
- if [[ $TRAVIS_PYTHON_VERSION == 2* && $DeleteAllFromFlickr == 1 ]]; then coverage run -a --concurrency multiprocessing ./flickr-deletr-master/delete.py; fi
# First RUN -------------------------------------------------------------------
# stdout to file, stderr to file
#- travis_wait coverage run -a --concurrency multiprocessing uploadr.py $VerboseVar $UploadrOptions > /home/travis/build/oPromessa/flickr-uploader/nohup.log 2> /home/travis/build/oPromessa/flickr-uploader/nohup.lst
- travis_wait coverage run -a --concurrency multiprocessing `which uploadr.py` $VerboseVar $UploadrOptions > /home/travis/build/oPromessa/flickr-uploader/nohup.log 2> /home/travis/build/oPromessa/flickr-uploader/nohup.lst
- tail -$TAIL_LINES /home/travis/build/oPromessa/flickr-uploader/nohup.log
- tail -$TAIL_LINES /home/travis/build/oPromessa/flickr-uploader/nohup.lst
- coverage combine
#- coverage html --include=lib,uploadr.py --omit=tests,build -d coverage_html
- coverage html
- tar czf coverage_html.tar.gz htmlcov || echo ok
# DB OUTPUT for REFERENCE RUN#1
- if [[ $TestScenario != Help ]]; then sqlite3 flickrdb "SELECT *, datetime( last_modified, 'unixepoch', 'localtime') FROM files ORDER BY path;"; fi
- if [[ $TestScenario != Help ]]; then sqlite3 flickrdb 'SELECT * FROM badfiles ORDER BY path;'; fi
- if [[ $TestScenario != Help ]]; then sqlite3 flickrdb 'SELECT * FROM sets ORDER BY name;'; fi
- if [[ $TestScenario != Help ]]; then sqlite3 flickrdb 'SELECT sets.set_id, sets.name, count(*) FROM sets, files WHERE sets.set_id = files.set_id GROUP BY 1, 2 ORDER BY 2;'; fi
- if [[ $TestScenario != Help ]]; then sqlite3 flickrdb 'SELECT sets.set_id, sets.name, count(*) FROM sets, files WHERE sets.set_id = files.set_id GROUP BY 1, 2 ORDER BY 2;' > dbrun1.log; fi
- if [[ $TestScenario != Help ]]; then sqlite3 flickrdb 'SELECT sets.set_id, sets.name, files_id, path FROM sets, files WHERE sets.set_id = files.set_id ORDER BY sets.name, path;'; fi
- echo DBRUN1------------------------------Start DB sets check
- diff <(sed -r 's/^[0-9]{17}\|/REPLACE\|/' dbrun1.log) <(sed -r 's/^[0-9]{17}\|/REPLACE\|/' tests/dbrunok.log) || echo ok
- echo DBRUN1--------------------------------End DB sets check
# WAIT TIME BEFORE SECOND RUN -------------------------------------------------
- sleep $WAIT_TIME
# Second RUN ------------------------------------------------------------------
- if [[ $TestScenario == DryRunNoToken ]]; then rm -fr token; fi
- if [[ $TestScenario == addAlbumsMigrate ]]; then sqlite3 flickrdb 'PRAGMA user_version="2"'; fi
- if [[ $TestScenario == addAlbumsMigrate ]]; then export UploadrOptions="$UploadrOptions --add-albums-migrate"; echo $UploadrOptions; fi
- if [[ $TestScenario == RemoveReplace ]]; then rm "./tests/Test Photo Library/photo.jpg"; fi
- if [[ $TestScenario == RemoveReplace ]]; then rm "./tests/Test Photo Library/photo_Excepção.jpg"; fi
- if [[ $TestScenario == RemoveReplace ]]; then cp "./tests/Test Photo Library/ReplaceTest/file_34_Substituição.ForReplace" "./tests/Test Photo Library/Pics.Replaced/file_34_Substituição.jpg"; fi
- if [[ $TestScenario == RemoveReplace ]]; then cp "./tests/Test Photo Library/ReplaceTest/file_35.jpg.ForReplace" "./tests/Test Photo Library/Pics.Replaced/file_35.jpg"; fi
- if [[ $TestScenario == RemoveReplace ]]; then cp "./tests/Test Photo Library/ReplaceTest/Video03.ToReplace.MP4.ForReplace" "./tests/Test Photo Library/Pics.Replaced/Video03.ToReplace.MP4"; fi
- if [[ $TestScenario == ExcludedFolders ]]; then cp ./tests/uploadr_excluded.ini ./uploadr.ini; cp ./tests/uploadr_excluded.ini /home/travis/virtualenv/python$pythonVersion/etc/uploadr.ini; fi
- if [[ $TestScenario == Old273INI ]]; then cp ./tests/uploadr_excluded_2.7.3.ini ./uploadr.ini; cp ./tests/uploadr_excluded_2.7.3.ini /home/travis/virtualenv/python$pythonVersion/etc/uploadr.ini; fi
- if [[ $TestScenario == NoVerbose ]]; then cp ./tests/uploadr_NoVerbose.ini ./uploadr.ini; cp ./tests/uploadr_NoVerbose.ini /home/travis/virtualenv/python$pythonVersion/etc/uploadr.ini; fi
# Run coverage uploadr.ini
# Scenario Old273INI: run ./uploadr.py instead of `which uploadr.py`
- if [[ $TestScenario == Old273INI ]]; then travis_wait coverage run -a --concurrency multiprocessing uploadr.py $UploadrOptions >> /home/travis/build/oPromessa/flickr-uploader/nohup.log 2>> /home/travis/build/oPromessa/flickr-uploader/nohup.lst; fi
- if [[ $TestScenario == DryRunNoToken ]]; then travis_wait coverage run -a --concurrency multiprocessing `which uploadr.py` $UploadrOptions >> /home/travis/build/oPromessa/flickr-uploader/nohup.log 2>> /home/travis/build/oPromessa/flickr-uploader/nohup.lst < /home/travis/build/oPromessa/flickr-uploader/tests/verifiercode.txt || echo ok; fi
- if [[ $TestScenario != Old273INI && $TestScenario != DryRunNoToken ]]; then travis_wait coverage run -a --concurrency multiprocessing `which uploadr.py` $UploadrOptions >> /home/travis/build/oPromessa/flickr-uploader/nohup.log 2>> /home/travis/build/oPromessa/flickr-uploader/nohup.lst; fi
#- coverage run -a --concurrency multiprocessing uploadr.py $UploadrOptions >> /home/travis/build/oPromessa/flickr-uploader/nohup.log 2>> /home/travis/build/oPromessa/flickr-uploader/nohup.lst
- tail -$TAIL_LINES /home/travis/build/oPromessa/flickr-uploader/nohup.log
- tail -$TAIL_LINES /home/travis/build/oPromessa/flickr-uploader/nohup.lst
- coverage combine
- coverage report -m
- sleep $WAIT_TIME
# Deleted Pics Non existant on FLickr -----------------------------------------
# For testing a local deleted file also not available in flickr
# - sleep $WAIT_TIME
# Test Deleted file
# - coverage run -a uploadr.py $VerboseVar -bl 10
# - coverage report -m uploadr.py
# - sqlite3 flickrdb "SELECT *, datetime( last_modified, 'unixepoch', 'localtime') FROM files;"
# -----------------------------------------------------------------------------
# after_failure
# Not applicable to "Build times out because no output was received"
after_failure:
# After failure: Save build related data
- echo -e "TRAVIS_TEST_RESULT:\t${TRAVIS_TEST_RESULT}\nTRAVIS_PYTHON_VERSION:\t${TRAVIS_PYTHON_VERSION}\nTRAVIS_BUILD_DIR:\t${TRAVIS_BUILD_DIR}\nTRAVIS_BUILD_ID:\t${TRAVIS_BUILD_ID}\nTRAVIS_BUILD_NUMBER:\t${TRAVIS_BUILD_NUMBER}\nTRAVIS_JOB_NUMBER:\t${TRAVIS_JOB_NUMBER}\nTRAVIS_EVENT_TYPE:\t${TRAVIS_EVENT_TYPE}\nTRAVIS_COMMIT:\t\t${TRAVIS_COMMIT}\nTRAVIS_COMMIT_MESSAGE:\t${TRAVIS_COMMIT_MESSAGE}\n" >> build.txt
# Upload LOG/ERR files to dropbox
- python tests/drop.py --token $DROPBOX_TOKEN build.txt $TRAVIS_BUILD_NUMBER/${TRAVIS_JOB_NUMBER}-${TRAVIS_TEST_RESULT}_${TestScenario}
- python tests/drop.py --token $DROPBOX_TOKEN nohup.log $TRAVIS_BUILD_NUMBER/${TRAVIS_JOB_NUMBER}-${TRAVIS_TEST_RESULT}_${TestScenario}
- python tests/drop.py --token $DROPBOX_TOKEN nohup.lst $TRAVIS_BUILD_NUMBER/${TRAVIS_JOB_NUMBER}-${TRAVIS_TEST_RESULT}_${TestScenario}
- python tests/drop.py --token $DROPBOX_TOKEN dbrun1.log $TRAVIS_BUILD_NUMBER/${TRAVIS_JOB_NUMBER}-${TRAVIS_TEST_RESULT}_${TestScenario}
- python tests/drop.py --token $DROPBOX_TOKEN dbrun2.log $TRAVIS_BUILD_NUMBER/${TRAVIS_JOB_NUMBER}-${TRAVIS_TEST_RESULT}_${TestScenario}
- python tests/drop.py --token $DROPBOX_TOKEN uploadr.err $TRAVIS_BUILD_NUMBER/${TRAVIS_JOB_NUMBER}-${TRAVIS_TEST_RESULT}_${TestScenario}
- tail -$TAIL_LINES /home/travis/build/oPromessa/flickr-uploader/nohup.log
- tail -$TAIL_LINES /home/travis/build/oPromessa/flickr-uploader/nohup.lst
# -----------------------------------------------------------------------------
# after_script
after_script:
# MD5SUM Output for REFERENCE -------------------------------------------------
# - if [[ $TestScenario == RemoveReplace ]]; then find "./tests/Test Photo Library" -type f -exec md5sum '{}' \; ; fi
# DB OUTPUT for REFERENCE RUN#2------------------------------------------------
- sqlite3 flickrdb "SELECT *, datetime( last_modified, 'unixepoch', 'localtime') FROM files ORDER BY path;"
- sqlite3 flickrdb 'SELECT * FROM badfiles ORDER BY path;'
- sqlite3 flickrdb 'SELECT * FROM sets ORDER BY name;'
- sqlite3 flickrdb 'SELECT sets.set_id, sets.name, count(*) FROM sets, files WHERE sets.set_id = files.set_id GROUP BY 1, 2 ORDER BY 2;'
- sqlite3 flickrdb 'SELECT sets.set_id, sets.name, count(*) FROM sets, files WHERE sets.set_id = files.set_id GROUP BY 1, 2 ORDER BY 2;' > dbrun2.log
- sqlite3 flickrdb 'SELECT sets.set_id, sets.name, files_id, path FROM sets, files WHERE sets.set_id = files.set_id ORDER BY sets.name, path;'
- echo DBRUN2-----Start DB sets check
- diff <(sed -r 's/^[0-9]{17}\|/REPLACE\|/' dbrun1.log) <(sed -r 's/^[0-9]{17}\|/REPLACE\|/' tests/dbrunok.log) || echo ok
- echo DBRUN2-------End DB sets check
# After script: Save build related data
- echo -e "TRAVIS_TEST_RESULT:\t${TRAVIS_TEST_RESULT}\nTRAVIS_PYTHON_VERSION:\t${TRAVIS_PYTHON_VERSION}\nTRAVIS_BUILD_DIR:\t${TRAVIS_BUILD_DIR}\nTRAVIS_BUILD_ID:\t${TRAVIS_BUILD_ID}\nTRAVIS_BUILD_NUMBER:\t${TRAVIS_BUILD_NUMBER}\nTRAVIS_JOB_NUMBER:\t${TRAVIS_JOB_NUMBER}\nTRAVIS_EVENT_TYPE:\t${TRAVIS_EVENT_TYPE}\nTRAVIS_COMMIT:\t\t${TRAVIS_COMMIT}\nTRAVIS_COMMIT_MESSAGE:\t${TRAVIS_COMMIT_MESSAGE}\n" >> build.txt
# Upload LOG/ERR files to Dropbox
- python tests/drop.py --token $DROPBOX_TOKEN build.txt $TRAVIS_BUILD_NUMBER/${TRAVIS_JOB_NUMBER}-${TRAVIS_TEST_RESULT}_${TestScenario}
- python tests/drop.py --token $DROPBOX_TOKEN nohup.log $TRAVIS_BUILD_NUMBER/${TRAVIS_JOB_NUMBER}-${TRAVIS_TEST_RESULT}_${TestScenario}
- python tests/drop.py --token $DROPBOX_TOKEN nohup.lst $TRAVIS_BUILD_NUMBER/${TRAVIS_JOB_NUMBER}-${TRAVIS_TEST_RESULT}_${TestScenario}
- python tests/drop.py --token $DROPBOX_TOKEN dbrun1.log $TRAVIS_BUILD_NUMBER/${TRAVIS_JOB_NUMBER}-${TRAVIS_TEST_RESULT}_${TestScenario}
- python tests/drop.py --token $DROPBOX_TOKEN dbrun2.log $TRAVIS_BUILD_NUMBER/${TRAVIS_JOB_NUMBER}-${TRAVIS_TEST_RESULT}_${TestScenario}
- python tests/drop.py --token $DROPBOX_TOKEN uploadr.err $TRAVIS_BUILD_NUMBER/${TRAVIS_JOB_NUMBER}-${TRAVIS_TEST_RESULT}_${TestScenario}
- python tests/drop.py --token $DROPBOX_TOKEN coverage_html.tar.gz $TRAVIS_BUILD_NUMBER/${TRAVIS_JOB_NUMBER}-${TRAVIS_TEST_RESULT}_${TestScenario} || echo ok
# -----------------------------------------------------------------------------
# Deploy to Heroku
#deploy:
# provider: heroku
# api_key: $HEROKU_API_KEY
# #app: uploadr-showcase
# on:
# branch: master
# #repo: oPromessa/flickr-uploadr