datadog-sdk-testing 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tasks/ci/hooks/pre-commit.py +57 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 013c7b5b9ff3626e2f2924adb8ff35ce45bd5a21
|
4
|
+
data.tar.gz: e53a7fbbc1dcd7a43dc6f34fbbccc4af375df50e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2d11c175dc4d8943e879056a6d718caa7ae1ff09594da070ea6cd97f7aded0c9439f689bdd8b2c415180d054b3cfea567f7b0687a008d7765e088cc281be280
|
7
|
+
data.tar.gz: f587725bbbf302383fc599875ff844a074cba08ab755a21d72c681bf41c73134624c225e0a3aa2faadaa3491144f13cc18791dca344268c8d0bdfb0b63a0a80d
|
@@ -31,12 +31,15 @@ def two_fa():
|
|
31
31
|
|
32
32
|
class RequirementsAnalyzer(object):
|
33
33
|
SPECIFIERS = ['==', '!=' '<=', '>=', '<', '>']
|
34
|
+
COMMENT = '#'
|
34
35
|
|
35
|
-
def __init__(self, remote, local, patterns=['requirements.txt'],
|
36
|
+
def __init__(self, remote, local, patterns=['requirements.txt'],
|
37
|
+
ignorable=[], verbose=False):
|
36
38
|
self.api = None
|
37
39
|
self.remote_sources = remote
|
38
40
|
self.local_sources = local
|
39
41
|
self.req_patterns = patterns
|
42
|
+
self.req_ignore = ignorable
|
40
43
|
self.verbose = verbose
|
41
44
|
|
42
45
|
if github3:
|
@@ -69,28 +72,48 @@ class RequirementsAnalyzer(object):
|
|
69
72
|
files[content.name] = content
|
70
73
|
continue
|
71
74
|
|
72
|
-
|
73
|
-
|
75
|
+
req_file = "/{}/requirements.txt".format(entry)
|
76
|
+
if self.req_ignore:
|
77
|
+
for pattern in self.req_ignore:
|
78
|
+
if not fnmatch.fnmatchcase(req_file, pattern):
|
79
|
+
req = gh_repo.file_contents(req_file)
|
80
|
+
reqs[entry] = req.decoded
|
81
|
+
break
|
82
|
+
else:
|
83
|
+
req = gh_repo.file_contents(req_file)
|
84
|
+
reqs[entry] = req.decoded
|
74
85
|
|
75
86
|
fmatches = []
|
76
87
|
for pattern in self.req_patterns:
|
77
|
-
|
88
|
+
hits = fnmatch.filter(files.keys(), pattern)
|
89
|
+
fmatches.extend(hits)
|
78
90
|
|
91
|
+
fmatches = self.filter_matches(fmatches) # filter/remove duplicates
|
79
92
|
for match in fmatches:
|
80
93
|
req = gh_repo.file_contents(files[match].path)
|
81
94
|
reqs[match] = req.decoded
|
82
95
|
|
83
96
|
return reqs
|
84
97
|
|
85
|
-
def get_local_files(self):
|
98
|
+
def get_local_files(self, src):
|
86
99
|
matches = []
|
87
|
-
for
|
100
|
+
for root, dirnames, filenames in os.walk(src):
|
88
101
|
for pattern in self.req_patterns:
|
89
|
-
|
90
|
-
|
91
|
-
|
102
|
+
hits = [os.path.join(root, hit) for hit in fnmatch.filter(filenames, pattern)]
|
103
|
+
hits = self.filter_matches(hits)
|
104
|
+
matches.extend(hits)
|
92
105
|
|
93
|
-
return matches
|
106
|
+
return list(set(matches))
|
107
|
+
|
108
|
+
def filter_matches(self, matches):
|
109
|
+
if not self.req_ignore:
|
110
|
+
return matches
|
111
|
+
|
112
|
+
excluded = []
|
113
|
+
for pattern in self.req_ignore:
|
114
|
+
excluded.extend(fnmatch.filter(matches, pattern))
|
115
|
+
|
116
|
+
return list(set(matches)-set(excluded))
|
94
117
|
|
95
118
|
def get_local_contents(self, files):
|
96
119
|
local_reqs = {}
|
@@ -116,7 +139,7 @@ class RequirementsAnalyzer(object):
|
|
116
139
|
print 'No Github API set (missing creds?) cant crawl remotes.'
|
117
140
|
|
118
141
|
for local in self.local_sources:
|
119
|
-
requirements = self.get_local_contents(self.get_local_files())
|
142
|
+
requirements = self.get_local_contents(self.get_local_files(local))
|
120
143
|
reqs[local] = requirements
|
121
144
|
|
122
145
|
return reqs
|
@@ -133,6 +156,14 @@ class RequirementsAnalyzer(object):
|
|
133
156
|
|
134
157
|
for line in mycontent:
|
135
158
|
line = "".join(line.split())
|
159
|
+
comment_idx = line.find(self.COMMENT)
|
160
|
+
if comment_idx >= 0:
|
161
|
+
line = line[:comment_idx]
|
162
|
+
|
163
|
+
if not any(sep in line for sep in self.SPECIFIERS):
|
164
|
+
reqs[line] = ('unpinned', integration, source)
|
165
|
+
continue
|
166
|
+
|
136
167
|
for specifier in self.SPECIFIERS:
|
137
168
|
idx = line.find(specifier)
|
138
169
|
if idx < 0:
|
@@ -143,11 +174,12 @@ class RequirementsAnalyzer(object):
|
|
143
174
|
|
144
175
|
if req in reqs and reqs[req][0] != specifier:
|
145
176
|
# version mismatch
|
146
|
-
print "There's a version mismatch with {req} " \
|
147
|
-
" {
|
177
|
+
print "There's a version mismatch with {req} {spec} " \
|
178
|
+
"@ {offense} and {prev_spec} defined in {src} " \
|
148
179
|
"@ {repo}.".format(
|
149
180
|
req=req,
|
150
181
|
spec=specifier,
|
182
|
+
offense=source,
|
151
183
|
prev_spec=reqs[req][0],
|
152
184
|
src=reqs[req][1],
|
153
185
|
repo=reqs[req][2]
|
@@ -167,6 +199,14 @@ def str2bool(v):
|
|
167
199
|
def main(args):
|
168
200
|
remote = local = []
|
169
201
|
verbose = str2bool(os.environ.get('VERBOSE', 'false'))
|
202
|
+
patterns = os.environ.get('REQ_PATTERNS', 'requirements*.txt')
|
203
|
+
if patterns:
|
204
|
+
patterns = patterns.split(',')
|
205
|
+
|
206
|
+
ignorable = os.environ.get('REQ_IGNORE_PATH', None)
|
207
|
+
if ignorable:
|
208
|
+
ignorable = ignorable.split(',')
|
209
|
+
|
170
210
|
if not len(args):
|
171
211
|
remote = [repo.strip() for repo in os.environ.get('REQ_REMOTES', '').split(',')]
|
172
212
|
local = [repo.strip() for repo in os.environ.get('REQ_LOCALS', '').split(',')]
|
@@ -178,8 +218,10 @@ def main(args):
|
|
178
218
|
else:
|
179
219
|
local = ['.']
|
180
220
|
|
181
|
-
analyzer = RequirementsAnalyzer(
|
182
|
-
|
221
|
+
analyzer = RequirementsAnalyzer(remote=remote, local=local,
|
222
|
+
patterns=patterns,
|
223
|
+
ignorable=ignorable,
|
224
|
+
verbose=verbose)
|
183
225
|
|
184
226
|
err, reqs = analyzer.process_requirements(analyzer.get_all_requirements())
|
185
227
|
if not err:
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datadog-sdk-testing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jaime Fullaondo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Datadog Integration SDK testing/scaffolding gem
|
14
14
|
email: jaime.fullaondo@datadoghq.com
|