forked from elastic/apm-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_changelogs.py
59 lines (47 loc) · 1.61 KB
/
check_changelogs.py
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
#!/usr/bin/env python3
import io
import hashlib
import os
import requests
SUPPORTED_VERSIONS = ["6.8", "7.8", "7.x"]
def parse_version(version):
return tuple([int(x) if x != "x" else 100 for x in version.split('.')])
def shasum(fp):
h = hashlib.sha1()
while True:
buf = fp.read()
if len(buf) == 0:
break
h.update(buf)
return h.hexdigest()
def main():
cl_dir = 'changelogs'
any_failures = False
for cl in sorted(os.listdir(cl_dir)):
version, _ = os.path.splitext(cl)
if version not in SUPPORTED_VERSIONS:
continue
parsed_version = parse_version(version)
with open(os.path.join(cl_dir, cl), mode='rb') as f:
master = shasum(f)
print("**", cl, master, "**")
for v in SUPPORTED_VERSIONS:
if parsed_version <= parse_version(v):
print("checking {} on {}".format(cl, v))
url = "https://raw.githubusercontent.com/elastic/apm-server/{}/changelogs/{}".format(v, cl)
rsp = requests.get(url)
status = "success"
if rsp.status_code == 200:
h = shasum(io.BytesIO(rsp.content))
else:
h = "error: {}".format(rsp.status_code)
# rsp.raise_for_status()
if h != master:
status = "failed"
any_failures = True
print(h, url, status)
print()
if any_failures:
raise Exception('Some changelogs are missing, please look at for failed.')
if __name__ == '__main__':
main()