Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move more Travis jobs to TaskCluster
- Loading branch information
Showing
5 changed files
with
157 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters