예제 #1
0
def find_rev_by_timestamp(timestamp, repo_name, refspec):
    base_args = ["git", "log", "-1", "--format=%H",
                 '--before=' + timestamp]
    # Prefer the most-recent change _made by swift-ci_ before the timestamp,
    # falling back to most-recent in general if there is none by swift-ci.
    rev = shell.capture(base_args + ['--author', 'swift-ci', refspec]).strip()
    if rev:
        return rev
    rev = shell.capture(base_args + [refspec]).strip()
    if rev:
        return rev
    else:
        raise RuntimeError('No rev in %s before timestamp %s' %
                           (repo_name, timestamp))
예제 #2
0
def get_timestamp_to_match(args):
    if not args.match_timestamp:
        return None
    with shell.pushd(os.path.join(SWIFT_SOURCE_ROOT, "swift"),
                     dry_run=False, echo=False):
        return shell.capture(["git", "log", "-1", "--format=%cI"],
                             echo=False).strip()
예제 #3
0
def confirm_tag_in_repo(tag, repo_name):
    tag_exists = shell.capture(['git', 'ls-remote', '--tags',
                                'origin', tag], echo=False)
    if not tag_exists:
        print("Tag '" + tag + "' does not exist for '" +
              repo_name + "', just updating regularly")
        tag = None
    return tag
예제 #4
0
def get_branch_for_repo(config, repo_name, scheme_name, scheme_map,
                        cross_repos_pr):
    cross_repo = False
    repo_branch = scheme_name
    if scheme_map:
        scheme_branch = scheme_map[repo_name]
        repo_branch = scheme_branch
        remote_repo_id = config['repos'][repo_name]['remote']['id']
        if remote_repo_id in cross_repos_pr:
            cross_repo = True
            pr_id = cross_repos_pr[remote_repo_id]
            repo_branch = "ci_pr_{0}".format(pr_id)
            shell.run(["git", "checkout", scheme_branch],
                      echo=True)
            shell.capture(["git", "branch", "-D", repo_branch],
                          echo=True, allow_non_zero_exit=True)
            shell.run(["git", "fetch", "origin",
                       "pull/{0}/merge:{1}"
                       .format(pr_id, repo_branch)], echo=True)
    return repo_branch, cross_repo
예제 #5
0
def dump_repo_hashes(config):
    max_len = reduce(lambda acc, x: max(acc, len(x)),
                     config['repos'].keys(), 0)
    fmt = "{:<%r}{}" % (max_len + 5)
    for repo_name, repo_info in sorted(config['repos'].items(),
                                       key=lambda x: x[0]):
        with shell.pushd(os.path.join(SWIFT_SOURCE_ROOT, repo_name),
                         dry_run=False,
                         echo=False):
            h = shell.capture(["git", "log", "--oneline", "-n", "1"],
                              echo=False).strip()
            print(fmt.format(repo_name, h))
예제 #6
0
    def test_capture(self):
        self.assertEqual(shell.capture(["echo", "hi"]), "hi\n")

        with self.assertRaises(SystemExit):
            shell.capture(["false"])

        self.assertIsNone(shell.capture(["false"], optional=True))

        self.assertEqual(
            shell.capture(["sh", "-c", "echo foo && false"],
                          allow_non_zero_exit=True), "foo\n")

        with self.assertRaises(SystemExit):
            shell.capture(["**not-a-command**"], optional=False)

        self.assertIsNone(shell.capture(["**not-a-command**"], optional=True))
예제 #7
0
    def test_capture(self):
        self.assertEqual(shell.capture(["echo", "hi"]), "hi\n")

        with self.assertRaises(SystemExit):
            shell.capture(["false"])

        self.assertIsNone(shell.capture(["false"], optional=True))

        self.assertEqual(
            shell.capture(["sh", "-c", "echo foo && false"],
                          allow_non_zero_exit=True), "foo\n")

        with self.assertRaises(SystemExit):
            shell.capture(["**not-a-command**"], optional=False)

        self.assertIsNone(shell.capture(["**not-a-command**"], optional=True))
예제 #8
0
    def test_capture(self):
        self.assertEqual(shell.capture(["echo", "hi"]), "hi\n")

        with self.assertRaises(SystemExit):
            shell.capture(["false"])

        self.assertIsNone(shell.capture(["false"], optional=True))

        with self.assertRaises(SystemExit):
            shell.capture(["**not-a-command**"], optional=True)
예제 #9
0
def dump_hashes_config(args, config):
    branch_scheme_name = args.dump_hashes_config
    new_config = {}
    config_copy_keys = ['ssh-clone-pattern', 'https-clone-pattern', 'repos']
    for config_copy_key in config_copy_keys:
        new_config[config_copy_key] = config[config_copy_key]
    repos = {}
    branch_scheme = {'aliases': [branch_scheme_name], 'repos': repos}
    new_config['branch-schemes'] = {args.dump_hashes_config: branch_scheme}
    for repo_name, repo_info in sorted(config['repos'].items(),
                                       key=lambda x: x[0]):
        with shell.pushd(os.path.join(SWIFT_SOURCE_ROOT, repo_name),
                         dry_run=False,
                         echo=False):
            h = shell.capture(["git", "rev-parse", "HEAD"],
                              echo=False).strip()
            repos[repo_name] = str(h)
    print(json.dumps(new_config, indent=4))
예제 #10
0
import os
import pipes
import sys

from multiprocessing import Process


# Allow importing swift_build_support.
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..',
                             'swift_build_support'))
from swift_build_support import shell  # noqa (E402)
from swift_build_support.toolchain import host_toolchain  # noqa (E402)

toolchain = host_toolchain()
LLVM_PROFDATA_PATH = toolchain.llvm_profdata
_profdata_help = shell.capture([LLVM_PROFDATA_PATH, 'merge', '-help'],
                               echo=False)
LLVM_PROFDATA_SUPPORTS_SPARSE = 'sparse' in _profdata_help


class ProfdataMergerProcess(Process):
    def __init__(self, config, file_queue):
        super(ProfdataMergerProcess, self).__init__()
        self.config = config
        self.file_queue = file_queue
        self.filename_buffer = []
        self.profdata_path = os.path.join(config.tmp_dir,
                                          "%s.profdata" % self.name)
        self.profdata_tmp_path = self.profdata_path + ".copy"

    def report(self, msg, level=logging.INFO):
        """Convenience method for reporting status from the workers."""
예제 #11
0
import os
import pipes
import sys

from multiprocessing import Process


# Allow importing swift_build_support.
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..',
                             'swift_build_support'))
from swift_build_support import shell  # noqa (E402)
from swift_build_support.toolchain import host_toolchain  # noqa (E402)

toolchain = host_toolchain()
LLVM_PROFDATA_PATH = toolchain.llvm_profdata
_profdata_help = shell.capture([LLVM_PROFDATA_PATH, 'merge', '-help'],
                               echo=False)
LLVM_PROFDATA_SUPPORTS_SPARSE = 'sparse' in _profdata_help


class ProfdataMergerProcess(Process):
    def __init__(self, config, file_queue):
        super(ProfdataMergerProcess, self).__init__()
        self.config = config
        self.file_queue = file_queue
        self.filename_buffer = []
        self.profdata_path = os.path.join(config.tmp_dir,
                                          "%s.profdata" % self.name)
        self.profdata_tmp_path = self.profdata_path + ".copy"

    def report(self, msg, level=logging.INFO):
        """Convenience method for reporting status from the workers."""
예제 #12
0
    def test_capture(self):
        self.assertEqual(shell.capture(["echo", "hi"]), "hi\n")

        with self.assertRaises(SystemExit):
            shell.capture(["false"])