示例#1
0
def create_github_repo(args):
    token = gh_token()
    meta = conda_build.api.render(
        args.feedstock_directory,
        permit_undefined_jinja=True,
        finalize=False,
        bypass_env_check=True,
        trim_skip=False,
    )[0][0]

    feedstock_name = get_feedstock_name_from_meta(meta)

    gh = Github(token)
    user_or_org = None
    if args.user is not None:
        pass
        # User has been defined, and organization has not.
        user_or_org = gh.get_user()
    else:
        # Use the organization provided.
        user_or_org = gh.get_organization(args.organization)

    repo_name = "{}-feedstock".format(feedstock_name)
    try:
        gh_repo = user_or_org.create_repo(
            repo_name,
            has_wiki=False,
            private=args.private,
            description="A conda-smithy repository for {}.".format(
                feedstock_name),
        )
        print("Created {} on github".format(gh_repo.full_name))
    except GithubException as gh_except:
        if (gh_except.data.get("errors", [{}])[0].get("message", "") !=
                u"name already exists on this account"):
            raise
        gh_repo = user_or_org.get_repo(repo_name)
        print("Github repository already exists.")

    # Now add this new repo as a remote on the local clone.
    repo = Repo(args.feedstock_directory)
    remote_name = args.remote_name.strip()
    if remote_name:
        if remote_name in [remote.name for remote in repo.remotes]:
            existing_remote = repo.remotes[remote_name]
            if existing_remote.url != gh_repo.ssh_url:
                print("Remote {} already exists, and doesn't point to {} "
                      "(it points to {}).".format(remote_name, gh_repo.ssh_url,
                                                  existing_remote.url))
        else:
            repo.create_remote(remote_name, gh_repo.ssh_url)

    if args.extra_admin_users is not None:
        for user in args.extra_admin_users:
            gh_repo.add_to_collaborators(user, "admin")

    if args.add_teams:
        if isinstance(user_or_org, Organization):
            configure_github_team(meta, gh_repo, user_or_org, feedstock_name)
def list_recipes():
    if os.path.isdir(recipe_directory_name):
        recipes = os.listdir(recipe_directory_name)
    else:
        recipes = []

    for recipe_dir in recipes:
        # We don't list the "example" feedstock. It is an example, and is there
        # to be helpful.
        if recipe_dir == 'example':
            continue
        path = os.path.abspath(os.path.join(recipe_directory_name, recipe_dir))
        yield path, get_feedstock_name_from_meta(MetaData(path))
示例#3
0
def list_recipes():
    if os.path.isdir(recipe_directory_name):
        recipes = os.listdir(recipe_directory_name)
    else:
        recipes = []

    for recipe_dir in recipes:
        # We don't list the "example" feedstock. It is an example, and is there
        # to be helpful.
        # .DS_Store is created by macOS to store custom attributes of its
        # containing folder.
        if recipe_dir in ['example', '.DS_Store']:
            continue
        path = os.path.abspath(os.path.join(recipe_directory_name, recipe_dir))
        yield path, get_feedstock_name_from_meta(MetaData(path))
示例#4
0
    def __call__(self, args):
        from conda_smithy import ci_register

        owner = args.user or args.organization
        meta = conda_build.api.render(
            args.feedstock_directory,
            permit_undefined_jinja=True,
            finalize=False,
            bypass_env_check=True,
            trim_skip=False,
        )[0][0]
        feedstock_name = get_feedstock_name_from_meta(meta)
        repo = "{}-feedstock".format(feedstock_name)

        if args.feedstock_config is None:
            args.feedstock_config = default_feedstock_config_path(
                args.feedstock_directory)

        print("CI Summary for {}/{} (can take ~30s):".format(owner, repo))

        if not args.anaconda_token:
            print("Warning: By not registering an Anaconda/Binstar token"
                  "your feedstock CI may not be able to upload packages"
                  "to anaconda.org by default. It is recommended to set"
                  "`upload_packages: False` per provider field in"
                  "conda-forge.yml to disable package uploads.")
        if args.travis:
            # Assume that the user has enabled travis-ci.com service
            # user-wide or org-wide for all repos
            # ci_register.add_project_to_travis(owner, repo)
            time.sleep(1)
            ci_register.travis_configure(owner, repo)
            if args.anaconda_token:
                ci_register.add_token_to_travis(owner, repo)
            # Assume that the user has enabled travis-ci.com service
            # user-wide or org-wide for all repos
            # ci_register.travis_cleanup(owner, repo)
        else:
            print("Travis registration disabled.")
        if args.circle:
            ci_register.add_project_to_circle(owner, repo)
            if args.anaconda_token:
                ci_register.add_token_to_circle(owner, repo)
        else:
            print("Circle registration disabled.")
        if args.azure:
            from conda_smithy import azure_ci_utils

            if azure_ci_utils.default_config.token is None:
                print(
                    "No azure token. Create a token at https://dev.azure.com/"
                    "conda-forge/_usersSettings/tokens and\n"
                    "put it in ~/.conda-smithy/azure.token")
            ci_register.add_project_to_azure(owner, repo)
        else:
            print("Azure registration disabled.")
        if args.appveyor:
            ci_register.add_project_to_appveyor(owner, repo)
            if args.anaconda_token:
                ci_register.appveyor_encrypt_binstar_token(
                    args.feedstock_config, owner, repo)
            ci_register.appveyor_configure(owner, repo)
        else:
            print("Appveyor registration disabled.")

        if args.drone:
            from conda_smithy.ci_register import drone_default_endpoint

            drone_endpoints = args.drone_endpoints
            if drone_endpoints is None:
                drone_endpoints = [drone_default_endpoint]
            for drone_endpoint in drone_endpoints:
                ci_register.add_project_to_drone(owner,
                                                 repo,
                                                 drone_endpoint=drone_endpoint)
                if args.anaconda_token:
                    ci_register.add_token_to_drone(
                        owner, repo, drone_endpoint=drone_endpoint)
        else:
            print("Drone registration disabled.")

        if args.webservice:
            ci_register.add_conda_forge_webservice_hooks(owner, repo)
        else:
            print("Heroku webservice registration disabled.")
        print(
            "\nCI services have been enabled. You may wish to regenerate the feedstock.\n"
            "Any changes will need commiting to the repo.")
示例#5
0
    def __call__(self, args):
        from conda_smithy import ci_register

        owner = args.user or args.organization
        meta = conda_build.api.render(
            args.feedstock_directory,
            permit_undefined_jinja=True,
            finalize=False,
            bypass_env_check=True,
            trim_skip=False,
        )[0][0]
        feedstock_name = get_feedstock_name_from_meta(meta)
        repo = "{}-feedstock".format(feedstock_name)

        print("CI Summary for {}/{} (can take ~30s):".format(owner, repo))
        if args.travis:
            # Assume that the user has enabled travis-ci.com service
            # user-wide or org-wide for all repos
            # ci_register.add_project_to_travis(owner, repo)
            time.sleep(1)
            ci_register.travis_configure(owner, repo)
            ci_register.add_token_to_travis(owner, repo)
            # Assume that the user has enabled travis-ci.com service
            # user-wide or org-wide for all repos
            # ci_register.travis_cleanup(owner, repo)
        else:
            print("Travis registration disabled.")
        if args.circle:
            ci_register.add_project_to_circle(owner, repo)
            ci_register.add_token_to_circle(owner, repo)
        else:
            print("Circle registration disabled.")
        if args.azure:
            from conda_smithy import azure_ci_utils

            if azure_ci_utils.default_config.token is None:
                print(
                    "No azure token. Create a token at https://dev.azure.com/"
                    "conda-forge/_usersSettings/tokens and\n"
                    "put it in ~/.conda-smithy/azure.token"
                )
            ci_register.add_project_to_azure(owner, repo)
        else:
            print("Azure registration disabled.")
        if args.appveyor:
            ci_register.add_project_to_appveyor(owner, repo)
            ci_register.appveyor_encrypt_binstar_token(
                args.feedstock_directory, owner, repo
            )
            ci_register.appveyor_configure(owner, repo)
        else:
            print("Appveyor registration disabled.")

        if args.drone:
            ci_register.add_project_to_drone(owner, repo)
            ci_register.add_token_to_drone(owner, repo)
        else:
            print("Drone registration disabled.")

        if args.webservice:
            ci_register.add_conda_forge_webservice_hooks(owner, repo)
        else:
            print("Heroku webservice registration disabled.")
        print(
            "\nCI services have been enabled. You may wish to regenerate the feedstock.\n"
            "Any changes will need commiting to the repo."
        )