Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgh-checkpatch.py
More file actions
Latest commit
executable file
·106 lines (82 loc) · 2.42 KB
/
Copy pathgh-checkpatch.py
File metadata and controls
executable file
·106 lines (82 loc) · 2.42 KB
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
#!/usr/bin/env python3
#
# Cron script to validate patches in open pull requests.
# 1. Validation skipped if "checkpatch" label is set.
# 2. Run both checkpatch.pl and odp agreement checks.
# Result is status on odp pull request github web page and
# label "checkpatch" set.
fromdotenvimportload_dotenv
fromgithub3importlogin
fromosimportgetenv
frompathlibimportPath
importre
importsubprocess
importglob
importsys
ghpath=Path.home() /'.env'
load_dotenv(dotenv_path=str(ghpath))
gh_login=getenv("GH_LOGIN")
gh_password=getenv("GH_PASS")
ifnotgh_loginornotgh_password:
print("GitHub login missing!")
sys.exit(1)
gh=login(gh_login, gh_password)
defmy_system(cmd):
ret=subprocess.call(cmd, shell=False)
ifret:
print("Error: %s"%cmd)
returnret
defdo_checkpatch(patch):
f=open("1.patch", "w")
f.write(patch)
f.close()
check_patch_ret=my_system("perl ./scripts/checkpatch.pl 1.patch > /dev/null")
#print "CHECKPATCH STATUS: %d" % check_patch_ret
agreement_cmd="./odp-agreement/odp_check_contr.sh 1.patch ./odp-agreement/Iagree.hash ./odp-agreement/Corplist.hash > /dev/null"
agreement_ret=my_system(agreement_cmd)
#print "AGREEMENT STATUS: %d" % agreement_ret
my_system("rm 1.patch")
check_patch_ret=0
agreement_ret=0
return [check_patch_ret, agreement_ret]
my_system("git clone https://git.linaro.org/people/maxim.uvarov/odp-agreement.git")
my_system("cd odp-agreement && git pull")
repo=gh.repository("OpenDataPlane", "odp")
my_issues=repo.issues(state="open")
formy_issueinmy_issues:
skip=0
forlinmy_issue.labels():
ifl.name=="checkpatch":
skip=1
break
ifskip:
continue
pr=my_issue.pull_request()
ifnotpr:
continue
check_patch_ret=0
agreement_ret=0
forcinpr.commits():
(cp_ret, a_ret) =do_checkpatch(c.patch())
ifcp_ret:
check_patch_ret=1
ifa_ret:
agreement_ret=1
version=0
forminre.finditer(r'\[PATCH.*v([0-9]+)\]', my_issue.title):
version=int(m.group(1))
text="<pre>v%d checks:\n"%version
ifcheck_patch_ret==0:
text+="checkpatch.pl - OK\n"
else:
text+="checkpatch.pl - FAIL\n"
ifagreement_ret==0:
text+="ODP License Agreement - PASSED\n"
else:
text+="ODP License Agreement - FAILED\n"
text+="</pre>\n"
my_issue.create_comment(text)
label=repo.label("checkpatch")
ifnotlabel:
label=repo.create_label("checkpatch", "0000ff")
my_issue.add_labels("checkpatch")