Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_github.py

Issue 2518313003: Refactor WPT Export to ensure only one PR in flight at a time (Closed)
Patch Set: Address CL feedback Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_github.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/github.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_github.py
similarity index 52%
rename from third_party/WebKit/Tools/Scripts/webkitpy/w3c/github.py
rename to third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_github.py
index 49a4a7618225eafd34331f4da185497dca753d14..c648dc0b1753ae45c5e6bf07283a9585e56174cb 100644
--- a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/github.py
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_github.py
@@ -8,9 +8,11 @@ import httplib2
import logging
_log = logging.getLogger(__name__)
+API_BASE = 'https://api.github.com'
+EXPORT_LABEL = 'chromium-export'
-class GitHub(object):
+class WPTGitHub(object):
def __init__(self, host):
self.host = host
@@ -36,6 +38,7 @@ class GitHub(object):
pr_branch_name = '{}:{}'.format(self.user, local_branch_name)
+ # TODO(jeffcarp): CC foolip and qyearsley on all PRs for now
# TODO(jeffcarp): add HTTP to Host and use that here
conn = httplib2.Http()
headers = {
@@ -46,7 +49,8 @@ class GitHub(object):
"title": desc_title,
"body": body,
"head": pr_branch_name,
- "base": "master"
+ "base": 'master',
+ "labels": [EXPORT_LABEL]
}
resp, content = conn.request("https://api.github.com/repos/w3c/web-platform-tests/pulls",
"POST", body=json.JSONEncoder().encode(body), headers=headers)
@@ -54,3 +58,40 @@ class GitHub(object):
if resp["status"] != "201":
return None
return json.loads(content)
+
+ def in_flight_pull_requests(self):
+ url_encoded_label = EXPORT_LABEL.replace(' ', '%20')
+ path = '/search/issues?q=repo:w3c/web-platform-tests%20is:open%20type:pr%20labels:{}'.format(url_encoded_label)
+ response, content = self.request(path)
+ if response['status'] == '200':
+ data = json.loads(content)
+ return data['items']
+ else:
+ raise Exception('Non-200 status code (%s): %s' % (response['status'], content))
+
+ def request(self, path, body=None):
+ assert path.startswith('/')
+
+ # Not used yet since only hitting public API
+ # headers = {
+ # "Accept": "application/vnd.github.v3+json",
+ # "Authorization": "Basic " + self.auth_token()
+ # }
+
+ if body:
+ json_body = json.dumps(body)
+ else:
+ json_body = None
+
+ conn = httplib2.Http()
+ return conn.request(API_BASE + path, body=json_body)
+
+ def merge_pull_request(self, pull_request_number):
+ path = '/repos/w3c/web-platform-tests/pulls/%d/merge' % pull_request_number
+ body = {}
+ response, content = self.request(path, body)
+
+ if response['status'] == '200':
+ return json.loads(content)
+ else:
+ raise Exception('PR could not be merged: %d' % pull_request_number)

Powered by Google App Engine
This is Rietveld 408576698