예제 #1
0
def push_pyup_requirements_commit():
    """Because pyup updates each package individually, it can create a
    requirements.txt with an incompatible set of versions.

    Depending on the changes, pyup might also have introduced
    whitespace errors.

    If we've recompiled requirements.txt in Travis and made changes,
    and this is a PR where pyup is running, push a consistent set of
    versions as a new commit to the PR.
    """
    if is_pyup_branch():
        print("Pushing new requirements, as this is a pyup pull request")

        print("Decrypting secrets")
        tools.decrypt_secrets()
        tools.configure_git()

        print("Creating commit")
        tools.git("add", "--update", "requirements")
        tools.git("commit", "-m", "Bump requirements for pyup pull request")

        print("Pushing to GitHub")
        subprocess.check_call([
            "ssh-agent",
            "sh",
            "-c",
            "ssh-add %s && " % (shlex.quote(tools.DEPLOY_KEY), ) +
            "git push ssh-origin HEAD:%s" %
            (os.environ["TRAVIS_PULL_REQUEST_BRANCH"], ),
        ])
예제 #2
0
def push_pyup_requirements_commit():
    """Because pyup updates each package individually, it can create a
    requirements.txt with an incompatible set of versions.

    Depending on the changes, pyup might also have introduced
    whitespace errors.

    If we've recompiled requirements.txt in Travis and made changes,
    and this is a PR where pyup is running, push a consistent set of
    versions as a new commit to the PR.
    """
    if is_pyup_branch():
        print('Pushing new requirements, as this is a pyup pull request')

        print('Decrypting secrets')
        tools.decrypt_secrets()
        tools.configure_git()

        print('Creating commit')
        tools.git('add', '--update', 'requirements')
        tools.git(
            'commit', '-m',
            'Bump requirements for pyup pull request'
        )

        print('Pushing to GitHub')
        subprocess.check_call([
            'ssh-agent', 'sh', '-c',
            'ssh-add %s && ' % (shlex.quote(tools.DEPLOY_KEY),) +
            'git push ssh-origin HEAD:%s' % (
                os.environ['TRAVIS_PULL_REQUEST_BRANCH'],
            )
        ])
예제 #3
0
def push_pyup_requirements_commit():
    """Because pyup updates each package individually, it can create a
    requirements.txt with an incompatible set of versions.

    Depending on the changes, pyup might also have introduced
    whitespace errors.

    If we've recompiled requirements.txt in Travis and made changes,
    and this is a PR where pyup is running, push a consistent set of
    versions as a new commit to the PR.
    """
    if is_pyup_branch():
        print("Pushing new requirements, as this is a pyup pull request")

        print("Decrypting secrets")
        tools.decrypt_secrets()
        tools.configure_git()

        print("Creating commit")
        tools.git("add", "--update", "requirements")
        tools.git("commit", "-m", "Bump requirements for pyup pull request")

        print("Pushing to GitHub")
        subprocess.check_call(
            [
                "ssh-agent",
                "sh",
                "-c",
                "ssh-add %s && " % (shlex.quote(tools.DEPLOY_KEY),)
                + "git push ssh-origin HEAD:%s"
                % (os.environ["TRAVIS_PULL_REQUEST_BRANCH"],),
            ]
        )
예제 #4
0
def commit_pending_release(project):
    """Create a commit with the new release."""
    tools.git('add', '-u', project.BASE_DIR)

    tools.git(
        'commit', '-m',
        'Bump %s version to %s and update changelog'
        '\n\n[skip ci]' % (project.PACKAGE_NAME, project.current_version(),)
    )
예제 #5
0
def ensure_ruby():
    if not os.path.exists(scripts.RBENV_ROOT):
        git('clone', 'https://github.com/rbenv/rbenv.git', scripts.RBENV_ROOT)

    if not os.path.exists(RUBY_BUILD):
        git('clone', 'https://github.com/rbenv/ruby-build.git', RUBY_BUILD)

    if not os.path.exists(
            os.path.join(scripts.RBENV_ROOT, 'versions',
                         scripts.RBENV_VERSION)):
        subprocess.check_call(
            [RBENV_COMMAND, 'install', scripts.RBENV_VERSION])

    if not (os.path.exists(BUNDLER_EXECUTABLE)
            and subprocess.call([BUNDLER_EXECUTABLE, 'version']) == 0):
        subprocess.check_call([GEM_EXECUTABLE, 'install', 'bundler'])

    assert os.path.exists(BUNDLER_EXECUTABLE)
예제 #6
0
def ensure_ruby():
    if not os.path.exists(scripts.RBENV_ROOT):
        git("clone", "https://github.com/rbenv/rbenv.git", scripts.RBENV_ROOT)

    if not os.path.exists(RUBY_BUILD):
        git("clone", "https://github.com/rbenv/ruby-build.git", RUBY_BUILD)

    if not os.path.exists(
            os.path.join(scripts.RBENV_ROOT, "versions",
                         scripts.RBENV_VERSION)):
        subprocess.check_call(
            [RBENV_COMMAND, "install", scripts.RBENV_VERSION])

    subprocess.check_call([GEM_EXECUTABLE, "update", "--system"])

    if not (os.path.exists(BUNDLER_EXECUTABLE)
            and subprocess.call([BUNDLER_EXECUTABLE, "version"]) == 0):
        subprocess.check_call([GEM_EXECUTABLE, "install", "bundler"])

    assert os.path.exists(BUNDLER_EXECUTABLE)
예제 #7
0
def test_release_file_exists_and_is_valid(project, monkeypatch):
    assert not tools.has_uncommitted_changes(project.BASE_DIR)

    monkeypatch.setattr(tools, "create_tag", lambda *args, **kwargs: None)
    monkeypatch.setattr(tools, "push_tag", lambda name: None)
    monkeypatch.setattr(rm, "commit_pending_release", lambda p: None)
    monkeypatch.setattr(project, "upload_distribution", lambda: None)
    monkeypatch.setattr(project, "IN_TEST", True, raising=False)

    try:
        main.do_release(project)

        with open(project.CHANGELOG_FILE) as i:
            changelog = i.read()
        assert project.current_version() in changelog
        assert rm.release_date_string() in changelog

    finally:
        tools.git("checkout", project.BASE_DIR)
        os.chdir(tools.ROOT)
def test_release_file_exists_and_is_valid(project, monkeypatch):
    assert not tools.has_uncommitted_changes(project.BASE_DIR)

    monkeypatch.setattr(tools, "create_tag", lambda *args, **kwargs: None)
    monkeypatch.setattr(tools, "push_tag", lambda name: None)
    monkeypatch.setattr(rm, "commit_pending_release", lambda p: None)
    monkeypatch.setattr(project, "upload_distribution", lambda: None)
    monkeypatch.setattr(project, "IN_TEST", True, raising=False)

    try:
        main.do_release(project)

        with open(project.CHANGELOG_FILE) as i:
            changelog = i.read()
        assert project.current_version() in changelog
        assert rm.release_date_string() in changelog

    finally:
        tools.git("checkout", project.BASE_DIR)
        os.chdir(tools.ROOT)
예제 #9
0
def ensure_ruby():
    if not os.path.exists(scripts.RBENV_ROOT):
        git('clone', 'https://github.com/rbenv/rbenv.git', scripts.RBENV_ROOT)

    if not os.path.exists(RUBY_BUILD):
        git('clone', 'https://github.com/rbenv/ruby-build.git', RUBY_BUILD)

    if not os.path.exists(
        os.path.join(scripts.RBENV_ROOT, 'versions', scripts.RBENV_VERSION)
    ):
        subprocess.check_call(
            [RBENV_COMMAND, 'install', scripts.RBENV_VERSION])

    if not (
        os.path.exists(BUNDLER_EXECUTABLE) and
        subprocess.call([BUNDLER_EXECUTABLE, 'version']) == 0
    ):
        subprocess.check_call(
            [GEM_EXECUTABLE, 'install', 'bundler']
        )

    assert os.path.exists(BUNDLER_EXECUTABLE)
예제 #10
0
def commit_pending_release(project):
    """Create a commit with the new release."""
    tools.git('rm', project.RELEASE_FILE)
    tools.git('add', '-u', project.BASE_DIR)

    tools.git(
        'commit', '-m',
        'Bump %s version to %s and update changelog'
        '\n\n[skip ci]' % (project.PACKAGE_NAME, project.current_version(),)
    )
예제 #11
0
def commit_pending_release(project):
    """Create a commit with the new release."""
    tools.git("rm", project.RELEASE_FILE)
    tools.git("add", "-u", project.BASE_DIR)

    tools.git(
        "commit",
        "-m",
        f"Bump {project.PACKAGE_NAME} version to {project.current_version()} "
        + "and update changelog\n\n[skip ci]",
    )
def commit_pending_release(project):
    """Create a commit with the new release."""
    tools.git("rm", project.RELEASE_FILE)
    tools.git("add", "-u", project.BASE_DIR)

    tools.git(
        "commit",
        "-m",
        "Bump %s version to %s and update changelog"
        "\n\n[skip ci]" % (project.PACKAGE_NAME, project.current_version()),
    )
예제 #13
0
def push_pyup_requirements_commit():
    """Because pyup updates each package individually, it can create a
    requirements.txt with an incompatible set of versions.

    Depending on the changes, pyup might also have introduced
    whitespace errors.

    If we've recompiled requirements.txt in Travis and made changes,
    and this is a PR where pyup is running, push a consistent set of
    versions as a new commit to the PR.
    """
    if is_pyup_branch():
        print("Pushing new requirements, as this is a pyup pull request")
        print("Creating commit")
        tools.configure_git()
        tools.git("add", "--update", "requirements")
        tools.git("commit", "-m", "Bump requirements for pyup pull request")

        print("Pushing to GitHub")
        tools.git("push", "origin", f"HEAD:{os.environ['GITHUB_HEAD_REF']}")
예제 #14
0
if __name__ == '__main__':
    make('format')

    # https://graysonkoonce.com/getting-the-current-branch-name-during-a-pull-request-in-travis-ci/
    if os.environ['TRAVIS_PULL_REQUEST'] == 'false':
        branch = os.environ['TRAVIS_BRANCH']
    else:
        branch = os.environ['TRAVIS_PULL_REQUEST_BRANCH']

    if changed_files():
        print(
            '*** There were changes from formatting, creating a commit',
            flush=True)

        git('config', 'user.name', 'Travis CI on behalf of Wellcome')
        git('config', 'user.email', '*****@*****.**')
        git('config', 'core.sshCommand', 'ssh -i deploy_key')

        git(
            'remote', 'add', 'ssh-origin',
            '[email protected]:wellcometrust/terraform-modules.git'
        )

        # Unencrypt the SSH key.
        subprocess.check_call([
            'openssl', 'aes-256-cbc',
            '-K', os.environ['encrypted_83630750896a_key'],
            '-iv', os.environ['encrypted_83630750896a_iv'],
            '-in', 'deploy_key.enc',
            '-out', 'deploy_key', '-d'
예제 #15
0
DIST = os.path.join(tools.ROOT, 'dist')


PENDING_STATUS = ('started', 'created')


if __name__ == '__main__':
    last_release = tools.latest_version()

    print('Current version: %s. Latest released version: %s' % (
        tools.__version__, last_release
    ))

    tools.add_ssh_origin()
    tools.git("fetch", "ssh-origin")

    HEAD = tools.hash_for_name('HEAD')
    MAIN = tools.hash_for_name('ssh-origin/main')
    print('Current head:  ', HEAD)
    print('Current main:', MAIN)

    on_main = tools.is_ancestor(HEAD, MAIN)
    has_release = tools.has_release()

    if has_release:
        print('Updating changelog and version')
        tools.update_for_pending_release()

    print('Building an sdist...')
예제 #16
0
import hypothesistooling as tools


ROOT = subprocess.check_output([
    "git", "rev-parse", "--show-toplevel"]).decode("utf8").strip()

NAME = "weco-deploy"


def docker(*args):
    subprocess.check_call(["docker"] + list(args))


if __name__ == '__main__':
    tools.git('config', 'user.name', 'Buildkite on behalf of Wellcome Collection')
    tools.git('config', 'user.email', '*****@*****.**')
    tools.add_ssh_origin()

    # Get latest metadata (can't pull here as need to keep RELEASE.rst to signify release)
    tools.git('fetch')

    HEAD = tools.hash_for_name('HEAD')
    MAIN = tools.hash_for_name('origin/main')

    on_main = tools.is_ancestor(HEAD, MAIN)
    has_release = tools.has_release()

    major, minor, patch = tuple(map(int, tools.latest_version().split(".")))
    tags = [
        f"{major}.{minor}.{patch}",