1414SIG_HEADER = "X-Hub-Signature"
1515
1616
17+ def should_action (action ):
18+ res = False
19+ types = ["synchronize" , "opened" , "reopened" , "labeled" ]
20+ for tt in types :
21+ if action in tt :
22+ res = True
23+ return res
24+
25+
1726def create_app (conn , user , test_config = None ):
1827 app = Flask (__name__ )
1928
@@ -63,7 +72,7 @@ def base():
6372 trigger_label = PULL_REQUEST_TRIGGER_LABEL
6473 if "pull_request" in request_data :
6574 action = request_data ["action" ]
66- if "labeled" == action :
75+ if should_action ( action ) :
6776 pull_request_dict = request_data ["pull_request" ]
6877 head_dict = pull_request_dict ["head" ]
6978 repo_dict = head_dict ["repo" ]
@@ -93,6 +102,7 @@ def base():
93102 )
94103
95104 # Git pushes to repo
105+ before_sha = None
96106 if "ref" in request_data :
97107 repo_dict = request_data ["repository" ]
98108 html_url = repo_dict ["html_url" ].split ("/" )
@@ -101,11 +111,33 @@ def base():
101111 ref = request_data ["ref" ].split ("/" )[- 1 ]
102112 ref_label = request_data ["ref" ]
103113 sha = request_data ["after" ]
114+ before_sha = request_data ["before" ]
104115 use_event = True
105116 event_type = "Git pushes to repo"
106117
107118 if use_event is True :
108- fields = {
119+ if before_sha is not None :
120+ fields_before = {
121+ "git_hash" : sha ,
122+ "ref_label" : ref_label ,
123+ "ref" : ref ,
124+ "gh_repo" : gh_repo ,
125+ "gh_org" : gh_org ,
126+ }
127+ app .logger .info (
128+ "Using event {} to trigger merge-base commit benchmark. final fields: {}" .format (
129+ event_type , fields_before
130+ )
131+ )
132+ result , response_data , err_message = commit_schema_to_stream (
133+ fields_before , conn , gh_org , gh_repo
134+ )
135+ app .logger .info (
136+ "Using event {} to trigger merge-base commit benchmark. final fields: {}" .format (
137+ event_type , response_data
138+ )
139+ )
140+ fields_after = {
109141 "git_hash" : sha ,
110142 "ref_label" : ref_label ,
111143 "ref" : ref ,
@@ -114,11 +146,11 @@ def base():
114146 }
115147 app .logger .info (
116148 "Using event {} to trigger benchmark. final fields: {}" .format (
117- event_type , fields
149+ event_type , fields_after
118150 )
119151 )
120152 result , response_data , err_message = commit_schema_to_stream (
121- fields , conn , gh_org , gh_repo
153+ fields_after , conn , gh_org , gh_repo
122154 )
123155 app .logger .info (
124156 "Using event {} to trigger benchmark. final fields: {}" .format (
0 commit comments