Skip to content

Commit

Permalink
Move more Travis jobs to TaskCluster
Browse files Browse the repository at this point in the history
  • Loading branch information
jgraham committed Mar 7, 2019
1 parent 9eca747 commit e7ae768
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 48 deletions.
60 changes: 53 additions & 7 deletions .taskcluster.yml
Expand Up @@ -98,6 +98,7 @@ tasks:
$map: [{name: firefox, channel: nightly}, {name: chrome, channel: dev}]
each(browser):
$map:
# This is the main place to define new stability checks
- name: wpt-${browser.name}-${browser.channel}-stability
checkout: FETCH_HEAD
diff_range: HEAD^
Expand Down Expand Up @@ -168,13 +169,56 @@ tasks:
--channel=${browser.channel}
${operation.extra_args};
- $map:
- name: lint
description: >-
Lint for wpt-specific requirements
script: tools/ci/ci_lint.sh
conditions:
push
pull-request
# This is the main point to define new CI checks other than stability checks
- name: lint
description: >-
Lint for wpt-specific requirements
script: tools/ci/ci_lint.sh
conditions:
push
pull-request
- name: update built tests
description: >-
Ensure test suites that require a build step are updated
script: ./tools/ci/run_tc.py update_built tools/ci/ci_built_diff.sh
conditions:
pull-request
- name: tools/ unittests (Python 2)
description: >-
Unit tests for tools running under Python 2.7, excluding wptrunner
script: >-
export TOXENV=py27;
export HYPOTHESIS_PROFILE=ci;
./tools/ci/run_tc.py tools_unittest tools/ci/ci_tools_unittest.sh
conditions:
push
pull-request
- name: tools/wpt/ tests
description: >-
Integration tests for wpt commands
script: >-
export TOXENV=py27;
sudo apt install libnss3-tools;
./tools/ci/run_tc.py wpt_integration tools/ci/ci_wpt.sh
conditions:
pull-request
- name: resources/ tests
description: >-
Tests for testharness.js and other files in resources/
script: >-
export TOXENV=py27;
./tools/ci/run_tc.py resources_unittest tools/ci/ci_resources_unittest.sh
conditions:
pull-request
- name: infrastructure/ tests
description: >-
Smoketests for wptrunner
script: >-
sudo apt install libnss3-tools libappindicator1 fonts-liberation;
./tools/ci/run_tc.py wptrunner_infrastructure tools/ci/ci_wptrunner_infrastructure.sh
conditions:
pull-request

each(operation):
# Note: jsone doesn't short-circuit evaluation so all parts of the conditional are evaluated
# Accessing properties using the [] notation allows them to evaluate as null in case they're undefined
Expand All @@ -188,6 +232,7 @@ tasks:
${event.ref}
else:
refs/pull/${event.number}/merge
event_str: {$json: {$eval: event}}
in:
taskId: {$eval: 'as_slugid(operation.name)'}
taskGroupId: {$eval: 'as_slugid("task group")'}
Expand Down Expand Up @@ -223,6 +268,7 @@ tasks:
- --login
- -c
- set -ex;
export TASK_EVENT='${event_str}';
~/start.sh
${event.repository.clone_url}
${checkout_ref}
Expand Down
35 changes: 0 additions & 35 deletions .travis.yml
Expand Up @@ -28,51 +28,16 @@ matrix:
secure: "EljDx50oNpDLs7rzwIv+z1PxIgB5KMnx1W0OQkpNvltR0rBW9g/aQaE+Z/c8M/sPqN1bkvKPybKzGKjb6j9Dw3/EJhah4SskH78r3yMAe2DU/ngxqqjjfXcCc2t5MKxzHAILTAxqScPj2z+lG1jeK1Z+K5hTbSP9lk+AvS0D16w="
file: $WPT_MANIFEST_FILE.gz
skip_cleanup: true
- name: "update-built-tests.sh"
if: type = pull_request
os: linux
python: "2.7"
env: JOB=update_built SCRIPT=tools/ci/ci_built_diff.sh
- name: "build-css-testsuites.sh"
if: type = pull_request
os: linux
python: "2.7"
env: JOB=build_css SCRIPT=css/build-css-testsuites.sh
- name: "tools/ unittests (Python 2)"
if: type = pull_request
os: linux
python: "2.7"
env: JOB=tools_unittest TOXENV=py27 HYPOTHESIS_PROFILE=ci SCRIPT=tools/ci/ci_tools_unittest.sh
- name: "tools/ unittests (Python 3)"
if: type = pull_request
os: linux
python: "3.6"
env: JOB=tools_unittest TOXENV=py36 HYPOTHESIS_PROFILE=ci SCRIPT=tools/ci/ci_tools_unittest.sh
- name: "tools/wpt/ tests"
if: type = pull_request
os: linux
python: "2.7"
addons:
apt:
packages:
- libnss3-tools
env: JOB=wpt_integration TOXENV=py27 SCRIPT=tools/ci/ci_wpt.sh
- name: "resources/ tests"
if: type = pull_request
os: linux
python: "2.7"
env: JOB=resources_unittest TOXENV=py27 SCRIPT=tools/ci/ci_resources_unittest.sh
- name: "infrastructure/ tests"
if: type = pull_request
os: linux
python: "2.7"
env: JOB=wptrunner_infrastructure SCRIPT=tools/ci/ci_wptrunner_infrastructure.sh
addons:
apt:
packages:
- libnss3-tools
- libappindicator1
- fonts-liberation
exclude:
- env: # exclude empty env from the top-level above
allow_failures:
Expand Down
3 changes: 3 additions & 0 deletions tools/ci/before_install.sh
@@ -1,6 +1,9 @@
#!/bin/bash
set -e

export GITHUB_PULL_REQUEST=$TRAVIS_PULL_REQUEST
export GITHUB_BRANCH=$TRAVIS_BRANCH

if [[ $RUN_JOB -eq 1 ]] || ./wpt test-jobs --includes $JOB; then
export RUN_JOB=1
git submodule update --init --recursive 1>&2
Expand Down
95 changes: 95 additions & 0 deletions tools/ci/run_tc.py
@@ -0,0 +1,95 @@
#!/usr/bin/env python

import argparse
import json
import os
import re
import subprocess
import sys


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


def get_parser():
p = argparse.ArgumentParser()
p.add_argument("job",
help="Name of the job associated with the current event")
p.add_argument("script", help="Script to run for the job")
return p


def get_extra_jobs(event):
body = None
jobs = set()
if "commits" in event:
body = event["commits"][0]["message"]
elif "pull_request" in event:
body = event["pull_request"]["body"]

if not body:
return jobs

regexp = re.compile("\s*tc-jobs:(.*)$")

for line in body.splitlines():
m = regexp.match(line)
if m:
items = m.group(1)
for item in items.split(","):
jobs.add(item.strip())
break
return jobs


def set_variables(event):
# Set some variables that we use to get the commits on the current branch
pull_request = "false"
if "pull_request" in event:
pull_request = str(event["pull_request"]["number"])
branch = "%s" % event["pull_request"]["head"]["ref"]
elif "ref" in event:
branch = event["ref"]

ref_prefix = "refs/heads/"
if branch.startswith(ref_prefix):
branch = branch[len(ref_prefix):]

os.environ.update({"GITHUB_PULL_REQUEST": pull_request,
"GITHUB_BRANCH": branch})


def include_job(job):
rv = subprocess.call([os.path.join(root, "wpt"),
"test-jobs",
"--includes",
job])
return rv == 0


def main():
args = get_parser().parse_args()
event = json.loads(os.environ["TASK_EVENT"])

set_variables(event)

extra_jobs = get_extra_jobs(event)

job = args.job

if (job == "all" or
"all" in extra_jobs or
job in extra_jobs or
include_job(job)):

# Run the job
subprocess.check_status(["git", "submodule", "update", "--all"])

os.chdir(root)
sys.exit(subprocess.call([args.script]))


if __name__ == "__main__":
main()
12 changes: 6 additions & 6 deletions tools/wpt/testfiles.py
Expand Up @@ -34,14 +34,14 @@ def display_branch_point():

def branch_point():
git = get_git_cmd(wpt_root)
if (os.environ.get("TRAVIS_PULL_REQUEST", "false") == "false" and
os.environ.get("TRAVIS_BRANCH") == "master"):
if (os.environ.get("GITHUB_PULL_REQUEST", "false") == "false" and
os.environ.get("GITHUB_BRANCH") == "master"):
# For builds on the master branch just return the HEAD commit
return git("rev-parse", "HEAD")
elif os.environ.get("TRAVIS_PULL_REQUEST", "false") != "false":
# This is a PR, so the base branch is in TRAVIS_BRANCH
travis_branch = os.environ.get("TRAVIS_BRANCH")
assert travis_branch, "TRAVIS_BRANCH environment variable is defined"
elif os.environ.get("GITHUB_PULL_REQUEST", "false") != "false":
# This is a PR, so the base branch is in GITHUB_BRANCH
travis_branch = os.environ.get("GITHUB_BRANCH")
assert travis_branch, "GITHUB_BRANCH environment variable is defined"
branch_point = git("merge-base", "HEAD", travis_branch)
else:
# Otherwise we aren't on a PR, so we try to find commits that are only in the
Expand Down

0 comments on commit e7ae768

Please sign in to comment.