Github user dblotsky commented on a diff in the pull request:

    https://github.com/apache/cordova-medic/pull/37#discussion_r26149508
  
    --- Diff: buildbot-conf/cordova.conf ---
    @@ -0,0 +1,326 @@
    +import os
    +import re
    +import json
    +
    +from buildbot.schedulers.basic import SingleBranchScheduler, 
AnyBranchScheduler
    +from buildbot.schedulers.forcesched import ForceScheduler
    +from buildbot.schedulers.timed import Nightly
    +
    +from buildbot.changes.gitpoller import GitPoller
    +from buildbot.changes import filter as change_filter
    +
    +from buildbot.process.factory import BuildFactory
    +from buildbot.config import BuilderConfig
    +
    +from buildbot.process.properties import renderer
    +from buildbot.process.properties import Property as P
    +from buildbot.process.properties import Interpolate as I
    +
    +from buildbot.steps.source.git import Git
    +from buildbot.steps.transfer import FileDownload
    +from buildbot.steps.shell import ShellCommand
    +from buildbot.steps.master import SetProperty
    +
    +from buildbot.status.results import SUCCESS
    +
    +# config
    +MEDIC_CONFIG_FILE    = os.path.join(FP, 'cordova-config.json')
    +PROJECTS_CONFIG_FILE = os.path.join(FP, 'cordova-repos.json')
    +
    +def parse_config_file(file_name):
    +    with open(file_name, 'r') as config_file:
    +        return json.load(config_file)
    +
    +medic_config    = parse_config_file(MEDIC_CONFIG_FILE)
    +projects_config = parse_config_file(PROJECTS_CONFIG_FILE)
    +
    +# constants
    +DEFAULT_REPO_NAME = 'src'
    +BASE_WORKDIR      = '.'
    +
    +OSX     = 'osx'
    +LINUX   = 'linux'
    +WINDOWS = 'windows'
    +
    +# patterns
    +CORDOVA_REPO_PATTERN = r'^.*(cordova-[^\.]+)\.git$'
    +
    +# interpretation of every byte-sized return code as success
    +ALWAYS_SUCCESS = {i: SUCCESS for i in range(0, 256)}
    +
    +####### UTILITIES
    +
    +# helper functions
    +def cordova_builders():
    +    return [b.name for b in c['builders'] if b.name.startswith('cordova_')]
    +
    +def repo_name_from_url(url):
    +    match = re.match(CORDOVA_REPO_PATTERN, url)
    +    if match is not None:
    +        return match.group(1)
    +    return DEFAULT_REPO_NAME
    +
    +def repo_codebase_from_name(name):
    +    repo          = projects_config[name]
    +    codebase_name = repo['codebase']
    +    return repo['codebases'][codebase_name]
    +
    +def repo_url_from_name(name):
    +    return repo_codebase_from_name(name)['repo']
    +
    +def repo_branch_from_name(name):
    +    return repo_codebase_from_name(name)['branch']
    +
    +def slugify(string):
    +    return string.replace(' ', '-')
    +
    +def running_tasks_on_platform(platform_name, os_name):
    +    """
    +    Return the names of tasks possibly started by
    +    builds on the given platform and OS.
    +    """
    +    if platform_name == 'windows':
    +        return ['WWAHost.exe']
    +    elif platform_name == 'wp8':
    +        return ['Xde.exe']
    +    elif platform_name == 'ios':
    +        return ['iOS Simulator']
    +    elif platform_name == 'android':
    +        if os_name == WINDOWS:
    +            return ['emulator-arm.exe', 'adb.exe']
    +        elif os_name == OSX:
    +            return ['emulator64-x86']
    +    return []
    +
    +def can_find_running_tasks(step):
    +    """
    +    Return true if an OS and a platform is specified. Those are the
    +    criteria for finding a task because running_tasks_on_platform uses
    +    those properties to determine which tasks could be running.
    +    """
    +    return (
    +        (step.build.getProperty('slaveos') is not None) and
    +        (step.build.getProperty('platform') is not None)
    +    )
    +
    +# renderers
    +@renderer
    +def render_repo_name(props):
    +    repo_url = props.getProperty('repository')
    +    return repo_name_from_url(repo_url)
    +
    +@renderer
    +def render_task_kill_command(props):
    +
    +    os_name       = props.getProperty('slaveos')
    +    platform_name = props.getProperty('platform')
    +    running_tasks = running_tasks_on_platform(platform_name, os_name)
    +
    +    if not running_tasks:
    +        return ['echo', 'No tasks to kill known.']
    +
    +    if os_name == WINDOWS:
    +        command = ['taskkill', '/F']
    +        for task in running_tasks:
    +            command.append('/IM')
    +            command.append(task)
    +
    +    else:
    +        command = ['killall']
    +        command.extend(running_tasks)
    +
    +    return command
    +
    +@renderer
    +def render_run_args(props):
    +    platform = props.getProperty('platform')
    +    if platform == 'windows':
    +        return '--win'
    +    return ''
    +
    +# step wrappers
    +def DescribedStep(step_class, description, haltOnFailure=True, **kwargs):
    +    return step_class(description=description, 
descriptionDone=description, name=slugify(description), 
haltOnFailure=haltOnFailure, **kwargs)
    +
    +def SH(workdir=BASE_WORKDIR, timeout=medic_config['app']['timeout'], 
**kwargs):
    +    return DescribedStep(ShellCommand, workdir=workdir, timeout=timeout, 
**kwargs)
    +
    +def NPM(npm_command, command=list(), what='code', **kwargs):
    +    return SH(command=['npm', npm_command] + command, description='npm ' + 
npm_command + 'ing ' + what, **kwargs)
    +
    +def NPMInstall(command=list(), **kwargs):
    +    # NOTE:
    +    #      adding the --cache parameter so that we don't use the global
    +    #      npm cache, which is shared with other processes
    +    return NPM('install', command=command + 
[I('--cache=%(prop:workdir)s/npm_cache')], **kwargs)
    +
    +def NPMTest(**kwargs):
    +    return NPM('test', **kwargs)
    +
    +def BuildbotClone(repourl, what='code', workdir=None, **kwargs):
    +    if workdir is None:
    +        workdir = what
    +    return DescribedStep(Git, 'cloning ' + what, repourl=repourl, 
workdir=workdir, mode='full', method='clobber', shallow=True, **kwargs)
    +
    +def CordovaClone(project_name, **kwargs):
    +    branch   = repo_branch_from_name(project_name)
    +    repo_url = repo_url_from_name(project_name)
    +    return BuildbotClone(repourl=repo_url, branch=branch, 
what=project_name, **kwargs)
    +
    +def MedicClone(project_name=None, **kwargs):
    +    """
    +    Clone repositories using medic's checkout.js script.
    +    """
    +
    +    command = ['node', 'cordova-medic/bin/checkout.js', 
'--config=cordova-medic/cordova-repos.json']
    +
    +    if project_name is not None:
    +        command    += ['--project=' + project_name]
    +        description = 'cloning ' + project_name
    +    else:
    +        description = 'cloning all cordova projects'
    +
    +    return SH(command=command, description=description)
    +
    +def RMRF(path, description=None, **kwargs):
    +
    +    if description is None:
    +        description = 'removing ' + path
    +
    +    # this is better than 'rm -rf' because it removes excessively long 
paths on Windows
    +    js_script = "var s = require('shelljs'); console.log('removing 
{path}'); s.rm('-rf', '{path}');".format(path=path)
    +
    +    return SH(command=['node', '-e', js_script], description=description, 
**kwargs)
    +
    +def Set(name, value, **kwargs):
    +    return DescribedStep(SetProperty, 'setting ' + name, property=name, 
value=value, **kwargs)
    +
    +def Download(mastersrc, slavedest):
    +    return FileDownload(mastersrc=mastersrc, slavedest=slavedest, 
workdir=BASE_WORKDIR)
    +
    +####### SLAVES
    +
    +OSX_SLAVES     = ['cordova-ios-slave']
    +WINDOWS_SLAVES = ['cordova-windows-slave']
    +
    +####### CHANGESOURCES
    +
    +# None, because Apache manages them, and we should not touch them.
    +
    +####### CHANGE FILTERS
    +
    +# None
    +
    +####### BUILDERS
    +
    +common_setup_steps = [
    +
    +    # set build properties
    +    Set('repositoryname', render_repo_name),
    +
    +    # kill running emulators
    +    SH(
    +        command         = render_task_kill_command,
    +        doStepIf        = can_find_running_tasks,
    +        description     = 'killing running tasks',
    +        haltOnFailure   = False,
    +        flunkOnWarnings = False,
    +        warnOnWarnings  = False,
    +        decodeRC        = ALWAYS_SUCCESS,
    +    ),
    +
    +    # clean up
    +    NPMInstall(command=['shelljs'], what='shelljs'),
    +    RMRF('~/.cordova/*', description='removing cache', 
haltOnFailure=False),
    +    RMRF(BASE_WORKDIR + '/*', description='cleaning workspace', 
haltOnFailure=False),
    +]
    +
    +common_plugins_steps = [
    +
    +    # get medic and its config
    +    CordovaClone('cordova-medic'),
    +    NPMInstall(command=['--production'], what='cordova-medic', 
workdir='cordova-medic'),
    +    Download(mastersrc=PROJECTS_CONFIG_FILE, 
slavedest='cordova-medic/cordova-repos.json'),
    +    Download(mastersrc=MEDIC_CONFIG_FILE, 
slavedest='cordova-medic/config.json'),
    +
    +    # clone all repos
    +    MedicClone(),
    +
    +    # install tools
    +    NPMInstall(what='cordova-coho',        workdir='cordova-coho'),
    +    NPMInstall(what='cordova-lib',         
workdir='cordova-lib/cordova-lib'),
    +    NPMInstall(what='cordova-cli',         workdir='cordova-cli'),
    +    NPMInstall(what='cordova-js',          workdir='cordova-js'),
    +    NPMInstall(what='cordova-plugman',     workdir='cordova-plugman'),
    +    NPMInstall(what='platform',            
workdir=I('cordova-%(prop:platform)s')),
    +    NPMInstall(what='cordova-mobile-spec', 
workdir='cordova-mobile-spec/createmobilespec'),
    +
    +    # link the installed code
    +    SH(command=['cordova-coho/coho', 'npm-link'], description='coho link'),
    +
    +    # prepare the test app
    +    SH(
    +        command = [
    +            'node',
    +            'cordova-mobile-spec/createmobilespec/createmobilespec.js',
    +            I('--%(prop:platform)s')
    +        ],
    +        description='creating mobilespec app'
    +    ),
    +    SH(
    +        command=[
    +            'node',
    +            'cordova-medic/updateconfig.js',
    +            I('--%(prop:platform)s'),
    +        ],
    +        description='preparing mobilespec app'
    +    ),
    +]
    +
    +cordova_plugins_all = BuildFactory()
    +cordova_plugins_all.addSteps(common_setup_steps)
    +cordova_plugins_all.addSteps(common_plugins_steps)
    +cordova_plugins_all.addSteps([
    +    SH(command=['node', I('cordova-medic/build_%(prop:platform)s.js')], 
description='running tests'),
    +])
    +
    +# WORKAROUND:
    +#            this is here to match what medic already does; these
    +#            should be their own builders, using a proper test matrix
    +cordova_plugins_windows = BuildFactory()
    +cordova_plugins_windows.addSteps(common_setup_steps)
    +cordova_plugins_windows.addSteps(common_plugins_steps)
    +cordova_plugins_windows.addSteps([
    +    SH(command=['node', I('cordova-medic/build_%(prop:platform)s.js'), 
"--store80"], description='running tests (Windows 8.0)'),
    +    SH(command=['node', I('cordova-medic/build_%(prop:platform)s.js'), 
"--store"], description='running tests (Windows 8.1)'),
    +    SH(command=['node', I('cordova-medic/build_%(prop:platform)s.js'), 
"--phone"], description='running tests (Windows Phone 8.1)'),
    +])
    +
    +c['builders'].extend([
    +
    +    # plugins builders
    +    BuilderConfig(name='cordova_plugins_ios_osx',            
slavenames=OSX_SLAVES,     factory=cordova_plugins_all,     
properties={'platform': 'ios',        'slaveos': OSX}),
    +    BuilderConfig(name='cordova_plugins_android_osx',        
slavenames=OSX_SLAVES,     factory=cordova_plugins_all,     
properties={'platform': 'android',    'slaveos': OSX}),
    +    BuilderConfig(name='cordova_plugins_windows_windows',    
slavenames=WINDOWS_SLAVES, factory=cordova_plugins_windows, 
properties={'platform': 'windows',    'slaveos': WINDOWS}),
    +    BuilderConfig(name='cordova_plugins_wp8_windows',        
slavenames=WINDOWS_SLAVES, factory=cordova_plugins_all,     
properties={'platform': 'wp8',        'slaveos': WINDOWS}),
    +    BuilderConfig(name='cordova_plugins_android_windows',    
slavenames=WINDOWS_SLAVES, factory=cordova_plugins_all,     
properties={'platform': 'android',    'slaveos': WINDOWS}),
    --- End diff --
    
    We already made a name change a few months back, and it didn't seem to be a 
problem. However, I'll keep the names the same for this PR then, and just add 
the new Android builder for OS X.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org

Reply via email to