Skip to content

Commit

Permalink
Reduce repetition
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglinmike committed Aug 29, 2018
1 parent 32db5bc commit 82e452d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 27 deletions.
24 changes: 3 additions & 21 deletions .taskcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,14 @@ tasks:
${event.after}
${browser.name}-${browser.channel};
cd ~/web-platform-tests;
./wpt manifest-download || true;
./tools/ci/taskcluster-run.py
--browser ${browser.name}
${browser.name}
--
--log-tbpl=../artifacts/log_tbpl.log
--log-tbpl-level=info
--log-wptreport=../artifacts/wpt_report.json
--log-mach=-
-y
--no-pause
--no-restart-on-unexpected
--install-fonts
--no-fail-on-unexpected
--test-type=${chunk[0]}
--this-chunk=${chunk[1]}
--total-chunks=${chunk[2]};
gzip ../artifacts/wpt_report.json;
- $if: tasks_for == "github-pull-request"
then:
$map: [{name: firefox, channel: nightly}, {name: chrome, channel: dev}]
Expand Down Expand Up @@ -137,24 +128,15 @@ tasks:
${event.pull_request.base.sha}
${browser.name}-${browser.channel};
cd ~/web-platform-tests;
./wpt manifest-download || true;
git fetch
${event.repository.clone_url}
refs/pull/${event.number}/head;
git checkout FETCH_HEAD;
result=0;
./tools/ci/taskcluster-run.py
--browser ${browser.name}
--commit-range ${event.pull_request.base.sha}...
${browser.name}
--
${command.extra_args}
--log-tbpl=../artifacts/log_tbpl.log
--log-tbpl-level=info
--log-mach=-
-y
--no-pause
--no-restart-on-unexpected
--install-fonts || result=$?;
if [ -f ../artifacts/wpt_report.json ]; then gzip ../artifacts/wpt_report.json; fi;
${command.extra_args} || result=$?;
echo $result > ../artifacts/run-return-code.txt;
echo Command exited with code $result (failures are allowed while this task is being vetted).
44 changes: 38 additions & 6 deletions tools/ci/taskcluster-run.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env python

import argparse
import gzip
import logging
import os
import shutil
import subprocess

browser_specific_args = {
Expand All @@ -23,7 +25,19 @@ def tests_affected(commit_range):
return tests


def main(browser, commit_range, wpt_args):
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."""

Expand All @@ -35,6 +49,9 @@ def main(browser, commit_range, wpt_args):
)
logger.addHandler(handler)

child = subprocess.Popen(['python', './wpt', 'manifest-download'])
child.wait()

if commit_range:
logger.info(
"Identifying tests affected in range '%s'..." % commit_range
Expand All @@ -49,21 +66,36 @@ def main(browser, commit_range, wpt_args):
tests = []
logger.info("Running all tests")

wpt_args += browser_specific_args.get(browser, [])
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 + [browser] + tests
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("--browser", action="store", required=True)
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 tests executed""")
parser.add_argument("wpt_args", nargs="*")
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()))

0 comments on commit 82e452d

Please sign in to comment.