Beispiel #1
0
    def test_package_baseqt_2019_dict(self):
        r = releaser.Releaser(
            self.build_info,
            groupinfo.GroupInfo(
                names=["base1"],
                versions=["2019"],
                type_=constants.ImageType.PACKAGE,
                targets=["boost"],
            ),
            sha=utils.get_current_sha(),
        )
        r.gh.repo.create_git_tag_and_release = mock.MagicMock()

        class U:
            name = "testuser"
            email = "*****@*****.**"

        r.gh.github.get_user = mock.MagicMock(return_value=U())

        r.gather()
        r.release(dry_run=False)
        boost_version = list(index.Index().iter_versions(
            constants.ImageType.PACKAGE, "boost"))[1]
        r.gh.repo.create_git_tag_and_release.assert_called_once_with(
            tag=f"aswflocaltesting/ci-package-boost/{boost_version}",
            draft=False,
            object=utils.get_current_sha(),
            prerelease=False,
            release_message=
            f"Inspect released Docker image here: https://hub.docker.com/r/aswflocaltesting/ci-package-boost/tags?name={boost_version}",
            release_name=f"aswflocaltesting/ci-package-boost:{boost_version}",
            tag_message=f"aswflocaltesting/ci-package-boost:{boost_version}",
            type="commit",
            tagger=mock.ANY,
        )
Beispiel #2
0
    def test_migrate_cli(self):
        current_version = list(index.Index().iter_versions(
            constants.ImageType.PACKAGE, "boost"))[1]
        runner = CliRunner()
        result = runner.invoke(
            aswfdocker.cli,
            [
                "release",
                "-n",
                f"aswf/ci-package-boost:{current_version}",
                "--sha",
                utils.get_current_sha(),
                "--dry-run",
            ],
            input="y\n",
        )
        self.assertFalse(result.exception)
        self.assertEqual(result.exit_code, 0)
        self.assertEqual(
            result.output,
            f"""Are you sure you want to create the following 1 release on sha={utils.get_current_sha()}?
aswf/ci-package-boost:{current_version}
 [y/N]: y
INFO:aswfdocker.releaser:Would create this GitHub release on current commit: aswf/ci-package-boost:{current_version}
Release done.
""",
        )
Beispiel #3
0
def release(
    build_info,
    ci_image_type,
    group,
    version,
    full_name,
    target,
    sha,
    github_org,
    docker_org,
    message,
    dry_run,
):
    """Creates a GitHub release for a ci-package or ci-image Docker image.
    """

    # Disable SSL unclosed ResourceWarning coming from GitHub
    warnings.filterwarnings(action="ignore",
                            message="unclosed",
                            category=ResourceWarning)

    if not sha:
        if utils.get_current_branch() != "master":
            click.secho(
                "Cannot release from non-master branch! Specify --sha to create a release on a given commit.",
                fg="red",
            )
            sys.exit(1)
        sha = utils.get_current_sha()
    if docker_org:
        build_info.docker_org = docker_org

    group_info = get_group_info(build_info, ci_image_type, group, version,
                                full_name, target)

    r = releaser.Releaser(
        github_org=github_org,
        build_info=build_info,
        group_info=group_info,
        message=message,
        sha=sha,
    )
    r.gather()
    if not click.confirm(
            "Are you sure you want to create the following {} release on sha={}?\n{}\n"
            .format(
                len(r.release_list),
                r.sha,
                "\n".join(tag for _, _, tag in r.release_list),
            )):
        click.echo("Release cancelled.")
        return
    r.release(dry_run=dry_run)
    click.echo("Release done.")
Beispiel #4
0
 def __init__(
     self,
     repo_uri: str = "",
     source_branch: str = "",
     aswf_version: str = "",
     repo_root: str = "",
 ):
     self.aswf_version = aswf_version
     self.repo_uri = repo_uri
     self.source_branch = source_branch
     self.docker_org = utils.get_docker_org(repo_uri, source_branch)
     self.repo_root = repo_root
     if self.docker_org == constants.FAKE_DOCKER_ORG:
         self.package_org = constants.TESTING_DOCKER_ORG
     else:
         self.package_org = self.docker_org
     if self.docker_org == constants.PUBLISH_DOCKER_ORG:
         self.vcs_ref = utils.get_current_sha()
         self.build_date = utils.get_current_date()
     else:
         self.vcs_ref = constants.DEV_BUILD_DATE
         self.build_date = constants.DEV_BUILD_DATE