コード例 #1
0
def run():
    homu_cfg = toml.load('/home/servo/homu/cfg.toml')
    homu_builders = homu_cfg['repo']['servo']['buildbot']

    # We need to invoke a new process to read the Buildbot master config
    # because Buildbot is written in python2.
    scriptpath = os.path.join(os.path.dirname(__file__), 'get_buildbot_cfg.py')
    ret = subprocess.run(['/usr/bin/python2', scriptpath],
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE)
    if ret.returncode != 0:
        return Failure('Unable to retrieve buildbot builders:', ret.stderr)

    buildbot_builders = json.loads(ret.stdout.decode('utf-8'))['builders']

    failure_msg = ''
    for builder_set in ['builders', 'try_builders']:
        diff = set(homu_builders[builder_set]) - set(buildbot_builders)
        if diff:
            failure_msg += 'Invalid builders for "{}": {}\n' \
                .format(builder_set, diff)

    if failure_msg:
        return Failure("Homu config isn't synced with Buildbot config:",
                       failure_msg)

    return Success('Buildbot and homu configs are synced')
コード例 #2
0
def run():
    failures = list(itertools.chain(*map(check_whitespace, paths())))

    if len(failures) == 0:
        return Success("No trailing whitespace found")
    else:
        output = '\n'.join([display_failure(failure) for failure in failures])
        return Failure("Trailing whitespace found on files and lines:", output)
コード例 #3
0
ファイル: shebang.py プロジェクト: rwaweber/saltfs
def run():
    executables = filter(is_executable, paths())
    failures = list(filter(lambda e: not has_correct_header(e), executables))

    if len(failures) == 0:
        return Success("All executable shebangs are correct")
    else:
        output = '\n'.join([display_path(path) for path in failures])
        return Failure("Bad shebangs found in these files:", output)
コード例 #4
0
ファイル: timezone.py プロジェクト: UK992/saltfs
def run():
    ret = subprocess.run(['date'],
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE)

    stdout = ret.stdout.decode('utf-8')

    if ret.returncode == 0 and 'UTC' in stdout:
        return Success('Date is in UTC')
    else:
        return Failure('Date is not in UTC: ', stdout)
コード例 #5
0
def run():
    proc = subprocess.Popen(['date'],
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE,
                            universal_newlines=True)
    stdout, _ = proc.communicate()

    if proc.returncode != 0 or 'UTC' not in stdout:
        return Failure('Date is not in UTC: ', stdout)

    return Success('Date is in UTC')
コード例 #6
0
def run():
    paths = ['test.py', 'tests']
    paths = [os.path.join(project_path(), path) for path in paths]
    command = ['flake8'] + paths
    ret = subprocess.run(command,
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE,
                         universal_newlines=True)

    if ret.returncode == 0:
        return Success("Tests passed flake8 lint")
    else:
        return Failure("Tests failed flake8 lint:", ret.stdout)
コード例 #7
0
def run():
    paths = ['test.py', 'tests']
    paths = [os.path.join(project_path(), path) for path in paths]
    command = ['flake8'] + paths
    proc = subprocess.Popen(command,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE,
                            universal_newlines=True)
    stdout, _ = proc.communicate()

    if proc.returncode != 0:
        return Failure("Tests failed flake8 lint:", stdout)

    return Success("Tests passed flake8 lint")
コード例 #8
0
def run():
    CONF_DIR = os.path.join(project_path(), 'buildbot', 'master', 'files',
                            'config')
    # Have to specify master.cfg separately because it is not a .py file
    command = ['flake8', CONF_DIR, os.path.join(CONF_DIR, 'master.cfg')]
    ret = subprocess.run(command,
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE,
                         universal_newlines=True)

    if ret.returncode == 0:
        return Success("Buildbot master config passed linting")
    else:
        return Failure("Buildbot master config lint check failed:", ret.stdout)
コード例 #9
0
ファイル: config_lint.py プロジェクト: tetsuharuohzeki/saltfs
def run():
    CONF_DIR = os.path.join(project_path(), 'buildbot', 'master', 'files',
                            'config')
    # Have to specify master.cfg separately because it is not a .py file
    command = ['flake8', CONF_DIR, "/home/servo/buildbot/master/master.cfg"]
    proc = subprocess.Popen(command,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE,
                            universal_newlines=True)
    stdout, _ = proc.communicate()

    if proc.returncode != 0:
        return Failure("Buildbot master config lint check failed:", stdout)

    return Success("Buildbot master config passed linting")
コード例 #10
0
def run():
    repo_cfg = toml.load('/home/servo/homu/cfg.toml')['repo']
    homu_repos = (
        "{}/{}".format(repo['owner'], repo['name'])
        for repo in repo_cfg.values()
    )
    missing_repos = [
        repository for repository in homu_repos
        if not repo_exists(repository)
    ]
    if len(missing_repos) > 0:
        return Failure(
            'Some repos set up for Homu do not exist on GitHub:',
            "\n".join(" - {}".format(repo) for repo in missing_repos)
        )
    return Success('All repos in the Homu config exist on Github')
コード例 #11
0
ファイル: config.py プロジェクト: aneeshusa/servo-saltfs
def run():
    command = [
        'sudo',  # To get access to buildbot files owned by servo
        'buildbot',
        'checkconfig',
        '/home/servo/buildbot/master'
    ]
    ret = subprocess.run(command,
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE,
                         universal_newlines=True)

    if ret.returncode == 0:
        return Success("Buildbot master config passed checkconfig")
    else:
        return Failure("Buildbot master config check failed:", ret.stderr)
コード例 #12
0
def run():
    try:
        urllib.request.urlopen('http://localhost/')
    except urllib.error.URLError as e:
        # Can call e.read() if there was a response but the HTTP status code
        # indicated error; the method is unavailable if a connection could not
        # be made. Nginx is reverse proxying Homu and Buildbot, which will be
        # dead on Travis because the test pillar credentials are not valid.

        # Also, we're 'expecting' a string for e.reason (for the connection
        # refused error case), but it may be another exception instance.
        if not hasattr(e, 'read'):
            return Failure("Nginx is not serving requests:", str(e.reason))

    # No need to catch HTTPError or ContentTooShortError specially here

    return Success("Nginx is serving requests")
コード例 #13
0
ファイル: config.py プロジェクト: tetsuharuohzeki/saltfs
def run():
    command = [
        'sudo',  # To get access to buildbot files owned by servo
        'buildbot',
        'checkconfig',
        '/home/servo/buildbot/master'
    ]
    proc = subprocess.Popen(command,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE,
                            universal_newlines=True)
    _, stderr = proc.communicate()

    if proc.returncode != 0:
        return Failure("Buildbot master config check failed:", stderr)

    return Success("Buildbot master config passed checkconfig")
コード例 #14
0
ファイル: safety.py プロジェクト: tetsuharuohzeki/saltfs
def run():
    pip_proc = subprocess.Popen(['/home/servo/homu/_venv/bin/pip', 'freeze'],
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE,
                                universal_newlines=True)
    safety_proc = subprocess.Popen(
        ['safety', 'check', '--full-report', '--stdin'],
        stdin=pip_proc.stdout,
        stdout=subprocess.PIPE,
        stderr=subprocess.DEVNULL,
        universal_newlines=True)
    pip_proc.stdout.close()
    stdout, _ = safety_proc.communicate()

    if safety_proc.returncode != 0:
        return Failure('Insecure Python packages installed in Homu env:',
                       stdout)

    return Success('No insecure Python packages found in Homu env')
コード例 #15
0
ファイル: sdk.py プロジェクト: tchon/saltfs
def run():
    with open(
            os.path.join(project_path(), 'servo-build-dependencies',
                         'map.jinja')) as jinja_file:
        template = Template(jinja_file.read())

    sdk_vars = template.module.android['sdk']
    failures = []
    checks = {}
    for version, sdk in sdk_vars.items():
        if version == 'current':
            if sdk not in sdk_vars:
                failures.append(
                    'The current SDK is not pointed at any installed SDK')
                continue
            checks[os.path.join(BASE_DIR, 'current')] = {
                'type': 'link',
                'target': os.path.join(BASE_DIR, sdk)
            }
            sdk = sdk_vars[sdk]
        for path_template, spec in CHECKS.items():
            path = path_template.format(os.path.join(BASE_DIR, version), **sdk)
            checks[path] = spec

    for path, spec in sorted(checks.items(), key=lambda kv: kv[0]):
        exists = os.path.lexists(path)
        if spec['type'] == 'absent':
            if exists:
                failures.append('{} should not exist'.format(path))
            continue
        if not exists:
            failures.append('{} does not exist but should'.format(path))
            continue
        info = os.stat(path).st_mode
        if spec['type'] == 'directory':
            if not (os.path.isdir(path) and not os.path.islink(path)):
                failures.append('{} should be a directory'.format(path))
            if not has_perms(0o700, info):
                failures.append(
                    '{} should have at least perms 700'.format(path))
        elif spec['type'] == 'file':
            if not (os.path.isfile(path) and not os.path.islink(path)):
                failures.append('{} should be a file'.format(path))
            perms = 0o700 if spec['executable'] else 0o600
            if not has_perms(perms, info):
                failures.append('{} should have at least perms {:o}'.format(
                    path, perms))
        elif spec['type'] == 'link':
            if not os.path.islink(path):
                failures.append('{} should be a symlink'.format(path))
            if not os.path.realpath(path) == spec['target']:
                failures.append('{} should be a link to {}'.format(
                    path, spec['target']))

        else:
            failures.append('Unknown spec for path {}'.format(path))

    if failures:
        output = '\n'.join(('- {}'.format(f) for f in failures))
        return Failure('Android SDK(s) not installed properly:', output)

    return Success('Android SDK(s) are properly installed')
コード例 #16
0
def run():
    try:
        toml.load('/home/servo/homu/cfg.toml')
    except Exception as e:
        return Failure('Homu config file is not valid TOML:', str(e))
    return Success('Homu config file is valid TOML')