<commit_before># -*- python -*-
# ex: set syntax=python:

from passwords import HTTP_USERNAME, HTTP_PASSWORD, SLAVE_PASSWORD, CHANGE_PASSWORD
from passwords import GITHUB_DOC_TOKEN, GITHUB_STATUS_TOKEN

SERVO_REPO = "https://github.com/servo/servo"
HEAD_SLAVES = ["servo-head"]
LINUX_SLAVES = ["servo-linux1", "servo-linux2"]
MAC_SLAVES = ["servo-mac1", "servo-mac2"]
ANDROID_SLAVES = ["servo-linux-android1"]

c = BuildmasterConfig = {}

c['caches'] = {
    'Changes': 1000,
    'Builds': 100,
    'chdicts': 1000,
}

####### BUILDSLAVES
from buildbot.buildslave import BuildSlave

c['slavePortnum'] = 9001
c['slaves'] = []
for s in LINUX_SLAVES + MAC_SLAVES + ANDROID_SLAVES + HEAD_SLAVES:
    c['slaves'].append(BuildSlave(s, SLAVE_PASSWORD, max_builds=1))

####### CHANGESOURCES
from buildbot.changes.pb import PBChangeSource

#def branch_filter(b):
#    # grab bors-servo-integration-* and master
#    if b == 'refs/heads/master' or b.startswith('refs/heads/bors-servo-integration-'):
#        return True
#    return False

c['change_source'] = []
c['change_source'].append(PBChangeSource(passwd=CHANGE_PASSWORD))
#c['change_source'].append(GitPoller(
#    SERVO_REPO,
#    workdir='gitpoller-workdir',
#    branches=branch_filter,
#    pollinterval=60
#))

####### SCHEDULERS
from buildbot.schedulers.basic import AnyBranchScheduler, SingleBranchScheduler
from buildbot.schedulers.forcesched import ForceScheduler
from buildbot.changes.filter import ChangeFilter

def bors_filter(c):
    if c.who.startswith('bors-servo') and \
      (c.branch in ["auto", "try"] or c.branch.startswith("bors-servo-integration-")):
        return True
    return False

def bors_master_filter(c):
    if c.who.startswith('bors-servo') and c.branch == "master":
        return True
    return False

c['schedulers'] = []
c['schedulers'].append(AnyBranchScheduler(
    name="auto",
    treeStableTimer=None,
    builderNames=["linux1", "linux2", "mac1", "mac2", "android", "gonk"],
    change_filter=ChangeFilter(filter_fn=bors_filter),
))
c['schedulers'].append(SingleBranchScheduler(
    name="doc-push",
    treeStableTimer=None,
    builderNames=["doc"],
    change_filter=ChangeFilter(filter_fn=bors_master_filter),
))
c['schedulers'].append(ForceScheduler(
    name="force",
    builderNames=["linux1", "linux2", "mac1", "mac2", "android", "gonk", "linux1-rel", "linux2-rel", "mac1-rel", "mac2-rel"]
))

####### BUILDERS
from buildbot.process.factory import BuildFactory
from buildbot.steps.source.git import Git
from buildbot.steps.shell import Compile, ShellCommand
from buildbot.steps.slave import RemoveDirectory

common_test_env = {
    'RUST_BACKTRACE': '1',
    'CARGO_HOME': '/home/servo/.cargo'
}

linux_test_env = dict({'DISPLAY': ':0'}, **common_test_env)
linux_headless_env = dict({'SERVO_HEADLESS': '1'}, **linux_test_env)

linux1_factory = BuildFactory()
linux1_factory.addStep(Git(repourl=SERVO_REPO, mode="full", method="clobber"))
linux1_factory.addStep(ShellCommand(command=["./mach", "test-tidy"], env=linux_headless_env))
linux1_factory.addStep(Compile(command=["./mach", "build"], env=linux_headless_env))
linux1_factory.addStep(ShellCommand(command=["./mach", "test-unit"], env=linux_headless_env))
linux1_factory.addStep(ShellCommand(command=["./mach", "test-content"], env=linux_headless_env))
linux1_factory.addStep(ShellCommand(command=["./mach", "test-ref", "--kind", "cpu"],
                                    env=linux_headless_env))


linux2_factory = BuildFactory()
linux2_factory.addStep(Git(repourl=SERVO_REPO, mode="full", method="clobber"))
linux2_factory.addStep(Compile(command=["./mach", "build"], env=linux_test_env))
linux2_factory.addStep(ShellCommand(command=["./mach", "test-wpt-failure"],
                                    env=linux_test_env))
linux2_factory.addStep(ShellCommand(command=["./mach", "test-wpt", "--processes", "4"],
                                    env=linux_test_env))
linux2_factory.addStep(Compile(command=["./mach", "build-cef"]))

task_limited_test_env = dict({'RUST_TEST_TASKS': '1'}, **common_test_env)

mac1_factory = BuildFactory()
mac1_factory.addStep(Git(repourl=SERVO_REPO, mode="full", method="clobber"))
mac1_factory.addStep(ShellCommand(command=["./mach", "test-tidy"]))
mac1_factory.addStep(Compile(command=["./mach", "build"]))
mac1_factory.addStep(ShellCommand(command=["./mach", "test-wpt-failure"],
                                  env=common_test_env))
mac1_factory.addStep(ShellCommand(command=["./mach", "test-wpt", "--processes", "4", "--total-chunks", "2", "--this-chunk", "1"],
                                 env=common_test_env))
mac1_factory.addStep(ShellCommand(command=["./mach", "test-unit"], env=common_test_env))
mac1_factory.addStep(Compile(command=["./mach", "build-cef"]))

mac2_factory = BuildFactory()
mac2_factory.addStep(Git(repourl=SERVO_REPO, mode="full", method="clobber"))
mac2_factory.addStep(Compile(command=["./mach", "build"]))
mac2_factory.addStep(ShellCommand(command=["./mach", "test-content"], env=common_test_env))
mac2_factory.addStep(ShellCommand(command=["./mach", "test-ref", "--kind", "cpu"],
                                 env=task_limited_test_env))
mac2_factory.addStep(ShellCommand(command=["./mach", "test-wpt", "--processes", "4", "--total-chunks", "2", "--this-chunk", "2"],
                                 env=common_test_env))

android_compile_env = dict({'ANDROID_SDK': '/home/servo/android-sdk-linux/',
                            'ANDROID_NDK': '/home/servo/android-ndk-r10c/',
                            'ANDROID_TOOLCHAIN': '/home/servo/ndk-toolchain/',
                            'PATH': '/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:/home/servo/android-sdk-linux/platform-tools:/home/servo/ndk-toolchain/bin'},
                           **common_test_env)
android_factory = BuildFactory()
android_factory.addStep(Git(repourl=SERVO_REPO, mode="full", method="clobber"))
android_factory.addStep(Compile(command=["./mach", "build", "--android"], env=android_compile_env))

gonk_compile_env = dict({'ANDROID_SDK': '/home/servo/android-sdk-linux/',
                         'ANDROID_NDK': '/home/servo/android-ndk-r10c/',
                         'ANDROID_TOOLCHAIN': '/home/servo/ndk-toolchain/',
                         'GONKDIR': '/home/servo/B2G/',
                         'PATH': '/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:/home/servo/B2G/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin'},
                        **common_test_env)

gonk_factory = BuildFactory()
gonk_factory.addStep(Git(repourl=SERVO_REPO, mode="full", method="clobber"))
gonk_factory.addStep(Compile(command=["./mach", "build-gonk"], env=gonk_compile_env))

doc_factory = BuildFactory()
doc_factory.addStep(Git(repourl=SERVO_REPO, mode="full", method="clobber"))
doc_factory.addStep(ShellCommand(command=["etc/ci/upload_docs.sh"],
                                 env={'TOKEN': GITHUB_DOC_TOKEN},
                                 logEnviron=False)) # important not to leak token


# Release builds


linux1_factory_rel = BuildFactory()
linux1_factory_rel.addStep(Git(repourl=SERVO_REPO, mode="full", method="clobber"))
linux1_factory_rel.addStep(ShellCommand(command=["./mach", "test-tidy"], env=linux_headless_env))
linux1_factory_rel.addStep(Compile(command=["./mach", "build", "--release"], env=linux_headless_env))
# https://github.com/rust-lang/cargo/issues/691
# linux1_factory_rel.addStep(ShellCommand(command=["./mach", "test-unit"], env=linux_headless_env))
linux1_factory_rel.addStep(ShellCommand(command=["./mach", "test-content"], env=linux_headless_env))
linux1_factory_rel.addStep(ShellCommand(command=["./mach", "test-ref", "--kind", "cpu"],
                                    env=linux_headless_env))


linux2_factory_rel = BuildFactory()
linux2_factory_rel.addStep(Git(repourl=SERVO_REPO, mode="full", method="clobber"))<commit_msg>mac has a different home dir<commit_after># -*- python -*-
# ex: set syntax=python:

from passwords import HTTP_USERNAME, HTTP_PASSWORD, SLAVE_PASSWORD, CHANGE_PASSWORD
from passwords import GITHUB_DOC_TOKEN, GITHUB_STATUS_TOKEN

SERVO_REPO = "https://github.com/servo/servo"
HEAD_SLAVES = ["servo-head"]
LINUX_SLAVES = ["servo-linux1", "servo-linux2"]
MAC_SLAVES = ["servo-mac1", "servo-mac2"]
ANDROID_SLAVES = ["servo-linux-android1"]

c = BuildmasterConfig = {}

c['caches'] = {
    'Changes': 1000,
    'Builds': 100,
    'chdicts': 1000,
}

####### BUILDSLAVES
from buildbot.buildslave import BuildSlave

c['slavePortnum'] = 9001
c['slaves'] = []
for s in LINUX_SLAVES + MAC_SLAVES + ANDROID_SLAVES + HEAD_SLAVES:
    c['slaves'].append(BuildSlave(s, SLAVE_PASSWORD, max_builds=1))

####### CHANGESOURCES
from buildbot.changes.pb import PBChangeSource

#def branch_filter(b):
#    # grab bors-servo-integration-* and master
#    if b == 'refs/heads/master' or b.startswith('refs/heads/bors-servo-integration-'):
#        return True
#    return False

c['change_source'] = []
c['change_source'].append(PBChangeSource(passwd=CHANGE_PASSWORD))
#c['change_source'].append(GitPoller(
#    SERVO_REPO,
#    workdir='gitpoller-workdir',
#    branches=branch_filter,
#    pollinterval=60
#))

####### SCHEDULERS
from buildbot.schedulers.basic import AnyBranchScheduler, SingleBranchScheduler
from buildbot.schedulers.forcesched import ForceScheduler
from buildbot.changes.filter import ChangeFilter

def bors_filter(c):
    if c.who.startswith('bors-servo') and \
      (c.branch in ["auto", "try"] or c.branch.startswith("bors-servo-integration-")):
        return True
    return False

def bors_master_filter(c):
    if c.who.startswith('bors-servo') and c.branch == "master":
        return True
    return False

c['schedulers'] = []
c['schedulers'].append(AnyBranchScheduler(
    name="auto",
    treeStableTimer=None,
    builderNames=["linux1", "linux2", "mac1", "mac2", "android", "gonk"],
    change_filter=ChangeFilter(filter_fn=bors_filter),
))
c['schedulers'].append(SingleBranchScheduler(
    name="doc-push",
    treeStableTimer=None,
    builderNames=["doc"],
    change_filter=ChangeFilter(filter_fn=bors_master_filter),
))
c['schedulers'].append(ForceScheduler(
    name="force",
    builderNames=["linux1", "linux2", "mac1", "mac2", "android", "gonk", "linux1-rel", "linux2-rel", "mac1-rel", "mac2-rel"]
))

####### BUILDERS
from buildbot.process.factory import BuildFactory
from buildbot.steps.source.git import Git
from buildbot.steps.shell import Compile, ShellCommand
from buildbot.steps.slave import RemoveDirectory

common_test_env = {
    'RUST_BACKTRACE': '1'
}

linux_test_env = dict({'DISPLAY': ':0', 'CARGO_HOME': '/home/servo/.cargo'}, **common_test_env)
linux_headless_env = dict({'SERVO_HEADLESS': '1'}, **linux_test_env)

mac_test_env = dict({CARGO_HOME': '/Users/servo/.cargo'}, **common_test_env)

linux1_factory = BuildFactory()
linux1_factory.addStep(Git(repourl=SERVO_REPO, mode="full", method="clobber"))
linux1_factory.addStep(ShellCommand(command=["./mach", "test-tidy"], env=linux_headless_env))
linux1_factory.addStep(Compile(command=["./mach", "build"], env=linux_headless_env))
linux1_factory.addStep(ShellCommand(command=["./mach", "test-unit"], env=linux_headless_env))
linux1_factory.addStep(ShellCommand(command=["./mach", "test-content"], env=linux_headless_env))
linux1_factory.addStep(ShellCommand(command=["./mach", "test-ref", "--kind", "cpu"],
                                    env=linux_headless_env))


linux2_factory = BuildFactory()
linux2_factory.addStep(Git(repourl=SERVO_REPO, mode="full", method="clobber"))
linux2_factory.addStep(Compile(command=["./mach", "build"], env=linux_test_env))
linux2_factory.addStep(ShellCommand(command=["./mach", "test-wpt-failure"],
                                    env=linux_test_env))
linux2_factory.addStep(ShellCommand(command=["./mach", "test-wpt", "--processes", "4"],
                                    env=linux_test_env))
linux2_factory.addStep(Compile(command=["./mach", "build-cef"]), env=linux_test_env)

task_limited_test_env = dict({'RUST_TEST_TASKS': '1'}, **mac_test_env)

mac1_factory = BuildFactory()
mac1_factory.addStep(Git(repourl=SERVO_REPO, mode="full", method="clobber"))
mac1_factory.addStep(ShellCommand(command=["./mach", "test-tidy"]))
mac1_factory.addStep(Compile(command=["./mach", "build"], env=mac_test_env))
mac1_factory.addStep(ShellCommand(command=["./mach", "test-wpt-failure"],
                                  env=mac_test_env))
mac1_factory.addStep(ShellCommand(command=["./mach", "test-wpt", "--processes", "4", "--total-chunks", "2", "--this-chunk", "1"],
                                 env=mac_test_env))
mac1_factory.addStep(ShellCommand(command=["./mach", "test-unit"], env=mac_test_env))
mac1_factory.addStep(Compile(command=["./mach", "build-cef"], env=mac_test_env))

mac2_factory = BuildFactory()
mac2_factory.addStep(Git(repourl=SERVO_REPO, mode="full", method="clobber"))
mac2_factory.addStep(Compile(command=["./mach", "build"], env=mac_test_env))
mac2_factory.addStep(ShellCommand(command=["./mach", "test-content"], env=mac_test_env))
mac2_factory.addStep(ShellCommand(command=["./mach", "test-ref", "--kind", "cpu"],
                                 env=task_limited_test_env))
mac2_factory.addStep(ShellCommand(command=["./mach", "test-wpt", "--processes", "4", "--total-chunks", "2", "--this-chunk", "2"],
                                 env=mac_test_env))

android_compile_env = dict({'ANDROID_SDK': '/home/servo/android-sdk-linux/',
                            'ANDROID_NDK': '/home/servo/android-ndk-r10c/',
                            'ANDROID_TOOLCHAIN': '/home/servo/ndk-toolchain/',
                            'PATH': '/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:/home/servo/android-sdk-linux/platform-tools:/home/servo/ndk-toolchain/bin'},
                           **linux_test_env)
android_factory = BuildFactory()
android_factory.addStep(Git(repourl=SERVO_REPO, mode="full", method="clobber"))
android_factory.addStep(Compile(command=["./mach", "build", "--android"], env=android_compile_env))

gonk_compile_env = dict({'ANDROID_SDK': '/home/servo/android-sdk-linux/',
                         'ANDROID_NDK': '/home/servo/android-ndk-r10c/',
                         'ANDROID_TOOLCHAIN': '/home/servo/ndk-toolchain/',
                         'GONKDIR': '/home/servo/B2G/',
                         'PATH': '/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:/home/servo/B2G/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin'},
                        **linux_test_env)

gonk_factory = BuildFactory()
gonk_factory.addStep(Git(repourl=SERVO_REPO, mode="full", method="clobber"))
gonk_factory.addStep(Compile(command=["./mach", "build-gonk"], env=gonk_compile_env))

doc_factory = BuildFactory()
doc_factory.addStep(Git(repourl=SERVO_REPO, mode="full", method="clobber"))
doc_factory.addStep(ShellCommand(command=["etc/ci/upload_docs.sh"],
                                 env={'TOKEN': GITHUB_DOC_TOKEN, 'CARGO_HOME': '/home/servo/.cargo'},
                                 logEnviron=False)) # important not to leak token


# Release builds


linux1_factory_rel = BuildFactory()
linux1_factory_rel.addStep(Git(repourl=SERVO_REPO, mode="full", method="clobber"))
linux1_factory_rel.addStep(ShellCommand(command=["./mach", "test-tidy"], env=linux_headless_env))
linux1_factory_rel.addStep(Compile(command=["./mach", "build", "--release"], env=linux_headless_env))
# https://github.com/rust-lang/cargo/issues/691
# linux1_factory_rel.addStep(ShellCommand(command=["./mach", "test-unit"], env=linux_headless_env))
linux1_factory_rel.addStep(ShellCommand(command=["./mach", "test-content"], env=linux_headless_env))
linux1_factory_rel.addStep(ShellCommand(command=["./mach", "test-ref", "--kind", "cpu"],
                                    env=linux_headless_env))


linux2_factory_rel = BuildFactory()
linux2_factory_rel.addStep(Git(repourl=SERVO_REPO, mode="full", method="clobber"))
{'fraction_non_alphanumeric': 0.17263578973685856, 'fraction_numerical': 0.011875742233889618, 'mean_word_length': 4.379959650302623, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3595518', 'n_tokens_mistral': 5759, 'n_tokens_neox': 5610, 'n_words': 734}