Files
sousa-gecko/testing/web-platform/tests/tools/ci/taskcluster-run.py
T
James Graham dbbc7e348e Bug 2012434 [wpt PR 57333] - Support running specific binaries in Taskcluster CI, a=testonly
Automatic update from web-platform-tests
Add --install-browser-url argument to wpt run

For supported browsers this allows providing a specific URL to
download from. This is helpful for testing specific builds that aren't
on the normal release channels (e.g. developer builds from vendor CI).

--
Support failling back to branches for gecko prefs

Sometimes if a build is from a branch that hasn't been released yet
there isn't a tag to download the prefs from. In these cases we want
to fall back to downloading from the tip of the relevant branch.

--
Support providing command args in the commit message

This allows taskcluster tasks to define a `commit-args-name` in the
task definition. This is a string value like `foo-args`. When this is
present, the last commit message, or PR body, will be scanned for
strings of the form:

```
foo-args: --arg
```

In which case `--arg` will be appended to the test command. This makes
it easier to run PRs with specific options set, without having to go
in an edit the specific task definitions.

--
Don't provide --binary to Firefox if we don't want to use the default binary

--
Add extra debugging to decision task

--
Fix getting body from head commit

--
Improve local debugging of decision task

--
Add initial types to decision task

This doesn't really improve anything, since there are so many Mapping[str, Any] types,
but it's a first step to cleaning up the code.

--

wpt-commits: 236f55ddb6129fa10d11bdbb89487565226acec7, d72177ca939891c1205c531166792efba4aaad44, 30e9cb8f80408723d74bc56a4b6d7796679a4773, 344dd7c6089443bd3deb26445df3dd8dac32c7e4, c6b91b7c08017cd11cf33fa686c6a6611a64c2c1, 4482d7804b221d2931c5a92bae2e80adca817f35, 548f3d72d52e79d1ad8021dfd0f9a23a3d5f2eb3, a3b93a911ba931fd74a9617f9cf4b0a06e17ae3a
wpt-pr: 57333
2026-03-30 08:03:48 +00:00

123 lines
4.5 KiB
Python
Executable File

#!/usr/bin/env python3
# mypy: allow-untyped-defs
import argparse
import gzip
import logging
import os
import shutil
import subprocess
import sys
def get_browser_args(product, channel, artifact_path, wpt_args):
if product == "firefox" and not any(item.startswith("--install-browser") for item in wpt_args):
local_binary = os.path.expanduser(os.path.join("~", "build", "firefox", "firefox"))
if os.path.exists(local_binary):
return ["--binary=%s" % local_binary]
print("WARNING: Local firefox binary not found")
return ["--install-browser", "--install-webdriver"]
if product == "firefox_android":
return ["--install-browser", "--install-webdriver", "--logcat-dir", artifact_path]
if product == "servo":
return ["--install-browser", "--processes=12"]
if product == "chrome" or product == "chromium":
# Taskcluster machines do not have GPUs, so use software rendering via --enable-swiftshader.
return ["--enable-swiftshader", "--install-browser", "--install-webdriver"]
if product in ["webkitgtk_minibrowser", "wpewebkit_minibrowser"]:
# Using 4 parallel jobs gives 4x speed-up even on a 1-core machine and doesn't cause extra timeouts.
# See: https://github.com/web-platform-tests/wpt/issues/38723#issuecomment-1470938179
return ["--install-browser", "--processes=4"]
return []
def find_wptreport(args):
parser = argparse.ArgumentParser()
parser.add_argument('--log-wptreport')
return parser.parse_known_args(args)[0].log_wptreport
def find_wptscreenshot(args):
parser = argparse.ArgumentParser()
parser.add_argument('--log-wptscreenshot')
return parser.parse_known_args(args)[0].log_wptscreenshot
def gzip_file(filename, delete_original=True):
with open(filename, 'rb') as f_in:
with gzip.open('%s.gz' % filename, 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
if delete_original:
os.unlink(filename)
def main(product, channel, commit_range, artifact_path, 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)
subprocess.call(['python3', './wpt', 'manifest-download'])
if commit_range:
logger.info(
"Running tests affected in range '%s'..." % commit_range
)
wpt_args += ['--affected', commit_range]
else:
logger.info("Running all tests")
wpt_args += [
"--log-mach-level=info",
"--log-mach=-",
"-y",
"--no-pause",
"--no-restart-on-unexpected",
"--install-fonts",
"--verify-log-full"
]
# Enable headless mode for WPE MiniBrowser and Servo because they do not work under Xvfb/X11 (needs Wayland)
wpt_args.append("--headless" if product in ("wpewebkit_minibrowser", "servo") else "--no-headless")
wpt_args += get_browser_args(product, channel, artifact_path, wpt_args)
wpt_args.append(product)
command = ["python3", "./wpt", "run"] + wpt_args
logger.info("Executing command: %s" % " ".join(command))
with open(os.path.join(artifact_path, "checkrun.md"), "a") as f:
f.write("\n**WPT Command:** `%s`\n\n" % " ".join(command))
retcode = subprocess.call(command, env=dict(os.environ, TERM="dumb"))
if retcode != 0:
sys.exit(retcode)
wptreport = find_wptreport(wpt_args)
if wptreport:
gzip_file(wptreport)
wptscreenshot = find_wptscreenshot(wpt_args)
if wptscreenshot:
gzip_file(wptscreenshot)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=main.__doc__)
parser.add_argument("--commit-range",
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("--artifact-path", default="/home/test/artifacts/",
help="Path to store output files")
parser.add_argument("product", help="Browser to run tests in")
parser.add_argument("channel", help="Channel of the browser")
parser.add_argument("wpt_args", nargs="*",
help="Arguments to forward to `wpt run` command")
main(**vars(parser.parse_args())) # type: ignore