-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Validate pull requests in TaskCluster #12657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
541acf3
c3f109b
a1f01d0
ee8d57d
7808fb1
0d6c2a2
c1792ee
f422774
150058e
0b623f3
30b4ae4
3371a4c
cbc779c
887512c
d9a12c3
80714c9
c4ea324
dba6e62
5c46835
e79a708
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| #!/usr/bin/env python | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, I think I'm OK with landing this as-is, but I wonder what the effect would be of moving the logic in this file into |
||
|
|
||
| import argparse | ||
| import gzip | ||
| import logging | ||
| import os | ||
| import shutil | ||
| import subprocess | ||
|
|
||
| browser_specific_args = { | ||
| "firefox": ["--install-browser"] | ||
| } | ||
|
|
||
| def tests_affected(commit_range): | ||
| output = subprocess.check_output([ | ||
| "python", "./wpt", "tests-affected", "--null", commit_range | ||
| ], stderr=open(os.devnull, "w")) | ||
|
|
||
| tests = output.split("\0") | ||
|
|
||
| # Account for trailing null byte | ||
| if tests and not tests[-1]: | ||
| tests.pop() | ||
|
|
||
| return tests | ||
|
|
||
|
|
||
| def find_wptreport(args): | ||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument('--log-wptreport', action='store') | ||
| return parser.parse_known_args(args)[0].log_wptreport | ||
|
|
||
|
|
||
| def gzip_file(filename): | ||
| with open(filename, 'rb') as f_in: | ||
| with gzip.open('%s.gz' % filename, 'wb') as f_out: | ||
| shutil.copyfileobj(f_in, f_out) | ||
|
|
||
|
|
||
| def main(product, commit_range, wpt_args): | ||
| """Invoke the `wpt run` command according to the needs of the TaskCluster | ||
| continuous integration service.""" | ||
|
|
||
| logger = logging.getLogger("tc-run") | ||
| logger.setLevel(logging.INFO) | ||
| handler = logging.StreamHandler() | ||
| handler.setFormatter( | ||
| logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") | ||
| ) | ||
| logger.addHandler(handler) | ||
|
|
||
| child = subprocess.Popen(['python', './wpt', 'manifest-download']) | ||
|
jgraham marked this conversation as resolved.
|
||
| child.wait() | ||
|
|
||
| if commit_range: | ||
| logger.info( | ||
| "Identifying tests affected in range '%s'..." % commit_range | ||
| ) | ||
| tests = tests_affected(commit_range) | ||
| logger.info("Identified %s affected tests" % len(tests)) | ||
|
|
||
| if not tests: | ||
| logger.info("Quitting because no tests were affected.") | ||
| return | ||
| else: | ||
| tests = [] | ||
| logger.info("Running all tests") | ||
|
|
||
| wpt_args += [ | ||
| "--log-tbpl=../artifacts/log_tbpl.log", | ||
| "--log-tbpl-level=info", | ||
| "--log-mach=-", | ||
| "-y", | ||
| "--no-pause", | ||
| "--no-restart-on-unexpected", | ||
| "--install-fonts" | ||
| ] | ||
| wpt_args += browser_specific_args.get(product, []) | ||
|
|
||
| command = ["python", "./wpt", "run"] + wpt_args + [product] + tests | ||
|
|
||
| logger.info("Executing command: %s" % " ".join(command)) | ||
|
|
||
| subprocess.check_call(command) | ||
|
|
||
| wptreport = find_wptreport(wpt_args) | ||
| if wptreport: | ||
| gzip_file(wptreport) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| parser = argparse.ArgumentParser(description=main.__doc__) | ||
| parser.add_argument("--commit-range", action="store", | ||
| help="""Git commit range. If specified, this will be | ||
| supplied to the `wpt tests-affected` command to | ||
| determine the list of test to execute""") | ||
| parser.add_argument("product", action="store", | ||
| help="Browser to run tests in") | ||
| parser.add_argument("wpt_args", nargs="*", | ||
| help="Arguments to forward to `wpt run` command") | ||
| main(**vars(parser.parse_args())) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A somewhat unrelated question: how can we create a public/shareable DockerHub account?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, but I think we all want that