Skip to content
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

Run master commits on Taskcluster #9226

Merged
merged 6 commits into from
Apr 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
689 changes: 689 additions & 0 deletions .taskcluster.yml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions tools/ci/ci_taskcluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if [ $1 == "firefox" ]; then
./wpt run firefox --log-tbpl=- --log-tbpl-level=debug --log-wptreport=../artifacts/wpt_report.json --this-chunk=$3 --total-chunks=$4 --test-type=$2 -y --install-browser --no-pause --no-restart-on-unexpected
elif [ $1 == "chrome" ]; then
./wpt run chrome --log-tbpl=- --log-tbpl-level=debug --log-wptreport=../artifacts/wpt_report.json --this-chunk=$3 --total-chunks=$4 --test-type=$2 -y --no-pause --no-restart-on-unexpected
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which version of chrome will this be?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on https://tools.taskcluster.net/groups/bLpNdT49RGCR7nEhELQE1A I'm guessing chrome dev, but I can't tell why.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It gets installed using apt in tools/docker/start.sh, pretty much like we do for travis. This probably isn't the optimal way to do this; the current setup is more of a proof of concept than anything, so I'm sure there are plenty of improvements we can make.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, well as long as it's not just accidentally chrome dev, that's just fine!

fi
4 changes: 3 additions & 1 deletion tools/ci/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
"virtualenv": false},
"check-stability": {"path": "check_stability.py", "script": "run", "parser": "get_parser", "parse_known": true, "help": "Check test stability",
"virtualenv": true, "install": ["requests"], "requirements": ["../wptrunner/requirements.txt"]},
"make-hosts-file": {"path": "make_hosts_file.py", "script": "run", "parser": "create_parser", "help": "Output a hosts file to stdout", "virtualenv": false}
"make-hosts-file": {"path": "make_hosts_file.py", "script": "run", "parser": "create_parser", "help": "Output a hosts file to stdout", "virtualenv": false},
"make-tasks": {"path": "taskgraph.py", "script": "run", "parser": "get_parser", "parse_known": true, "help": "Generate taskcluster.yml file containing the run tasks",
"virtualenv": true, "install": ["pyyaml"]}
}
123 changes: 123 additions & 0 deletions tools/ci/taskgraph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import argparse
import copy
import os
import six

import yaml


here = os.path.dirname(__file__)
wpt_root = os.path.abspath(os.path.join(here, os.pardir, os.pardir))


task_template = {
"provisionerId": "{{ taskcluster.docker.provisionerId }}",
"workerType": "{{ taskcluster.docker.workerType }}",
"extra": {
"github": {
"events": ["push"],
"branches": ["master"],
},
},
"payload": {
"maxRunTime": 5400,
"image": "harjgam/web-platform-tests:0.6",
"command":[
"/bin/bash",
"--login",
"-c",
""">-
~/start.sh &&
cd /home/test/web-platform-tests &&
git fetch {{event.head.repo.url}} &&
git config advice.detachedHead false &&
git checkout {{event.head.sha}} &&
%(command)s"""],
"artifacts": {
"public/results": {
"path": "/home/test/artifacts",
"type": "directory"
}
}
},
"metadata": {
"name": "wpt-%(browser_name)s-%(suite)s-%(chunk)s",
"description": "",
"owner": "{{ event.head.user.email }}",
"source": "{{ event.head.repo.url }}",
}
}


file_template = {
"version": 0,
"tasks": [],
"allowPullRequests": "collaborators"
}

suites = {
"testharness": {"chunks": 12},
"reftest": {"chunks": 6},
"wdspec": {"chunks": 1}
}

browsers = {
"firefox": {"name": "firefox-nightly"},
"chrome": {"name": "chrome-dev"}
}


def get_parser():
parser = argparse.ArgumentParser()
parser.add_argument("--dest",
action="store",
default=wpt_root,
help="Directory to write the .taskcluster.yml file to")
return parser


def fill(template, data):
rv = {}
for key, value in template.iteritems():
rv[key] = fill_inner(value, data)
return rv


def fill_inner(value, data):
if isinstance(value, six.string_types):
return value % data
elif isinstance(value, dict):
return fill(value, data)
elif isinstance(value, list):
return [fill_inner(item, data) for item in value]
elif isinstance(value, (float,) + six.integer_types):
return value
else:
raise ValueError


def run(venv, *args, **kwargs):
if not os.path.isdir(kwargs["dest"]):
raise ValueError("Invalid directory %s" % kwargs["dest"])

task_config = copy.deepcopy(file_template)
for browser, browser_props in browsers.iteritems():
for suite, suite_props in suites.iteritems():
total_chunks = suite_props.get("chunks", 1)
for chunk in six.moves.xrange(1, total_chunks + 1):
data = {
"suite": suite,
"chunk": chunk,
"browser_name": browser_props["name"],
"command": ("./tools/ci/ci_taskcluster.sh %s %s %s %s" %
(browser, suite, chunk, total_chunks))
}

task_data = fill(task_template, data)
task_config["tasks"].append(task_data)

with open(os.path.join(kwargs["dest"], ".taskcluster.yml"), "w") as f:
f.write("""# GENERATED FILE DO NOT EDIT
# To regenerate this file run ./wpt make-tasks
""")
yaml.dump(task_config, f)
4 changes: 4 additions & 0 deletions tools/docker/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function xvfb_start() {
GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"
xvfb-run --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" $@
}
76 changes: 76 additions & 0 deletions tools/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
FROM ubuntu:16.04

# No interactive frontend during docker build
ENV DEBIAN_FRONTEND=noninteractive \
DEBCONF_NONINTERACTIVE_SEEN=true

# General requirements not in the base image
RUN apt-get -qqy update \
&& apt-get -qqy install \
bzip2 \
ca-certificates \
dbus-x11 \
gdebi \
git \
locales \
pulseaudio \
python \
python-pip \
tzdata \
sudo \
unzip \
wget \
xvfb

# Installing just the deps of firefox and chrome is moderately tricky, so
# just install the default versions of them, and some extra deps we happen
# to know that chrome requires

RUN apt-get -qqy install \
firefox \
Copy link
Member

@Hexcles Hexcles Apr 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I meant everything below could be removed, i.e. just apt-get -qqy install firefox should be enough.

The other packages below are "some extra deps we happen to know that chrome requires" according to the comment above. And since gdebi chrome.deb will take care of them, we don't need to guess and install these dependencies any more.

The comment above should also be updated to reflect that we are only installing firefox now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing more stuff at build time does have the advantage that we don't do so much work at runtime, so generally it makes more sense to move stuff into the docker build rather than the other way around.

In this case we agreed on irc that it doesn't make much difference either way and there are plenty of performance optimisations and potential cleanup left on the table, so it's OK to just merging what we have now.

libnss3-tools \
fonts-liberation \
indicator-application \
libappindicator1 \
libappindicator3-1 \
libdbusmenu-gtk3-4 \
libindicator3-7 \
libindicator7

RUN pip install --upgrade pip
RUN pip install virtualenv

ENV TZ "UTC"
RUN echo "${TZ}" > /etc/timezone \
&& dpkg-reconfigure --frontend noninteractive tzdata

RUN useradd test \
--shell /bin/bash \
--create-home \
&& usermod -a -G sudo test \
&& echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers \
&& echo 'test:secret' | chpasswd

ENV SCREEN_WIDTH 1280
ENV SCREEN_HEIGHT 1024
ENV SCREEN_DEPTH 24
ENV DISPLAY :99.0

USER test

WORKDIR /home/test

COPY .bashrc /home/test/.bashrc

COPY start.sh /home/test/start.sh

# Remove information on how to use sudo on login
RUN sudo echo ""

RUN git clone --depth=1 https://github.com/w3c/web-platform-tests.git

RUN mkdir -p /home/test/.fonts && \
cp web-platform-tests/fonts/Ahem.ttf ~/.fonts && \
fc-cache -f -v

RUN mkdir -p /home/test/artifacts
14 changes: 14 additions & 0 deletions tools/docker/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

cd web-platform-tests
git pull --depth=1

sudo sh -c './wpt make-hosts-file >> /etc/hosts'

# Install Chome dev
deb_archive=google-chrome-unstable_current_amd64.deb
wget https://dl.google.com/linux/direct/$deb_archive

sudo gdebi -n $deb_archive
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Installing Google Chrome will add the Google repository so your system
will automatically keep Google Chrome up to date. If you don’t want Google's
repository, do sudo touch /etc/default/google-chrome before installing the
package.

Source: https://www.google.com/intl/en/chrome/browser/

Is this relevant given the expected lifespan of the container?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No; any changes only persist for the lifetime of the container, which is just for a single test run.


sudo Xvfb $DISPLAY -screen 0 ${SCREEN_WIDTH}x${SCREEN_HEIGHT}x${SCREEN_DEPTH} &
3 changes: 2 additions & 1 deletion tools/wpt/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@ def log(x):

def run_single(venv, **kwargs):
from wptrunner import wptrunner
return wptrunner.start(**kwargs)
wptrunner.start(**kwargs)
return


def main():
Expand Down