15
15
16
16
try :
17
17
from urllib .parse import urlencode
18
- except ImportError : # pragma: no cover
18
+ except ImportError : # pragma: no cover
19
19
from urllib import urlencode
20
20
21
21
try :
@@ -34,7 +34,8 @@ def build_reports(root):
34
34
accepting = set (('coverage.xml' , 'coverage.json' , 'jacoco.xml' , 'jacocoTestReport.xml' , 'clover.xml' , 'coverage.txt' , 'cobertura.xml' , 'jacoco.xml' , 'lcov.info' , 'gcov.info' ))
35
35
36
36
for _root , dirs , files in os .walk (root ):
37
- if SKIP_DIRECTORIES .search (_root ): continue
37
+ if SKIP_DIRECTORIES .search (_root ):
38
+ continue
38
39
# add data to tboc
39
40
for filepath in files :
40
41
fp = os .path .join (_root , filepath ).replace (root + "/" , '' )
@@ -64,7 +65,7 @@ def build_reports(root):
64
65
reports .append (dumps (cobertura .from_xml (etree .fromstring (f .read ()))))
65
66
66
67
# warn when no reports found and is python
67
- if len (reports )== 0 :
68
+ if len (reports ) == 0 :
68
69
# TODO send `coverage debug sys` to rollbar
69
70
sys .stdout .write ("No reports found. You may need to add a coverage config file. Visit http://bit.ly/1slucpy for configuration help." )
70
71
@@ -73,6 +74,7 @@ def build_reports(root):
73
74
# join reports together
74
75
return "\n <<<<<< EOF\n " .join (["\n " .join (table_of_contents )] + reports )
75
76
77
+
76
78
def try_to_run (cmd ):
77
79
try :
78
80
subprocess .check_output (cmd , shell = True )
@@ -88,13 +90,13 @@ def upload(url, root, env=None, **kwargs):
88
90
assert args .get ('branch' ) not in ('' , None ), "branch is required"
89
91
assert args .get ('commit' ) not in ('' , None ), "commit hash is required"
90
92
assert any ((args .get ('travis_job_id' ),
91
- (args .get ('build' ) and args .get ('service' )== 'circleci' ),
93
+ (args .get ('build' ) and args .get ('service' ) == 'circleci' ),
92
94
args .get ('token' ))), "missing token or other required argument(s)"
93
95
94
96
reports = build_reports (root )
95
97
96
98
if env :
97
- reports = "\n <<<<<< ENV\n " .join (("\n " .join (["%s=%s" % (k ,os .getenv (k ,'' )) for k in env ]), reports ))
99
+ reports = "\n <<<<<< ENV\n " .join (("\n " .join (["%s=%s" % (k , os .getenv (k , '' )) for k in env ]), reports ))
98
100
99
101
kwargs ['package' ] = "codecov-v%s" % VERSION
100
102
@@ -109,6 +111,7 @@ def upload(url, root, env=None, **kwargs):
109
111
except AssertionError as e :
110
112
return dict (message = str (e ), uploaded = False , coverage = 0 )
111
113
114
+
112
115
def main (* argv ):
113
116
defaults = dict (commit = '' , branch = '' , travis_job_id = '' , root = None , pull_request = '' , build_url = '' )
114
117
@@ -131,10 +134,10 @@ def main(*argv):
131
134
defaults .update (dict (branch = os .getenv ('TRAVIS_BRANCH' ),
132
135
service = 'travis-org' ,
133
136
build = os .getenv ('TRAVIS_JOB_NUMBER' ),
134
- pull_request = os .getenv ('TRAVIS_PULL_REQUEST' ) if os .getenv ('TRAVIS_PULL_REQUEST' )!= 'false' else '' ,
137
+ pull_request = os .getenv ('TRAVIS_PULL_REQUEST' ) if os .getenv ('TRAVIS_PULL_REQUEST' ) != 'false' else '' ,
135
138
travis_job_id = os .getenv ('TRAVIS_JOB_ID' ),
136
- owner = os .getenv ('TRAVIS_REPO_SLUG' ).split ('/' ,1 )[0 ],
137
- repo = os .getenv ('TRAVIS_REPO_SLUG' ).split ('/' ,1 )[1 ],
139
+ owner = os .getenv ('TRAVIS_REPO_SLUG' ).split ('/' , 1 )[0 ],
140
+ repo = os .getenv ('TRAVIS_REPO_SLUG' ).split ('/' , 1 )[1 ],
138
141
root = os .getenv ('TRAVIS_BUILD_DIR' ),
139
142
commit = os .getenv ('TRAVIS_COMMIT' )))
140
143
# --------
@@ -166,8 +169,8 @@ def main(*argv):
166
169
defaults .update (dict (branch = os .getenv ('BRANCH_NAME' ),
167
170
service = 'semaphore' ,
168
171
build = os .getenv ('SEMAPHORE_BUILD_NUMBER' ),
169
- owner = os .getenv ('SEMAPHORE_REPO_SLUG' ).split ('/' ,1 )[0 ],
170
- repo = os .getenv ('SEMAPHORE_REPO_SLUG' ).split ('/' ,1 )[1 ],
172
+ owner = os .getenv ('SEMAPHORE_REPO_SLUG' ).split ('/' , 1 )[0 ],
173
+ repo = os .getenv ('SEMAPHORE_REPO_SLUG' ).split ('/' , 1 )[1 ],
171
174
commit = os .getenv ('REVISION' )))
172
175
# --------
173
176
# drone.io
@@ -187,8 +190,8 @@ def main(*argv):
187
190
defaults .update (dict (branch = os .getenv ('APPVEYOR_REPO_BRANCH' ),
188
191
service = "appveyor" ,
189
192
build = os .getenv ('APPVEYOR_BUILD_NUMBER' ),
190
- owner = os .getenv ('APPVEYOR_REPO_NAME' ).split ('/' ,1 )[0 ],
191
- repo = os .getenv ('APPVEYOR_REPO_NAME' ).split ('/' ,1 )[1 ],
193
+ owner = os .getenv ('APPVEYOR_REPO_NAME' ).split ('/' , 1 )[0 ],
194
+ repo = os .getenv ('APPVEYOR_REPO_NAME' ).split ('/' , 1 )[1 ],
192
195
commit = os .getenv ('APPVEYOR_REPO_COMMIT' )))
193
196
# -------
194
197
# Wercker
@@ -210,9 +213,9 @@ def main(*argv):
210
213
service = 'shippable' ,
211
214
build = os .getenv ('BUILD_NUMBER' ),
212
215
build_url = os .getenv ('BUILD_URL' ),
213
- pull_request = os .getenv ('PULL_REQUEST' ) if os .getenv ('PULL_REQUEST' )!= 'false' else '' ,
214
- owner = os .getenv ('REPO_NAME' ).split ('/' ,1 )[0 ],
215
- repo = os .getenv ('REPO_NAME' ).split ('/' ,1 )[1 ],
216
+ pull_request = os .getenv ('PULL_REQUEST' ) if os .getenv ('PULL_REQUEST' ) != 'false' else '' ,
217
+ owner = os .getenv ('REPO_NAME' ).split ('/' , 1 )[0 ],
218
+ repo = os .getenv ('REPO_NAME' ).split ('/' , 1 )[1 ],
216
219
commit = os .getenv ('COMMIT' )))
217
220
# ---
218
221
# git
0 commit comments