easybuild.tools.github module¶
Utility module for working with github
| author: | Jens Timmerman (Ghent University) |
|---|---|
| author: | Kenneth Hoste (Ghent University) |
| author: | Toon Willems (Ghent University) |
-
exception
easybuild.tools.github.GithubError¶ Bases:
exceptions.ExceptionError raised by the Githubfs
-
class
easybuild.tools.github.Githubfs(githubuser, reponame, branchname='master', username=None, password=None, token=None)¶ Bases:
objectThis class implements some higher level functionality on top of the Github api
-
get_path(path)¶ returns the path as a Github object (from agithub)
-
get_repo()¶ Returns the repo as a Github object (from agithub)
-
static
isdir(githubobj)¶ Check if this path points to a directory
-
static
isfile(githubobj)¶ Check if this path points to a file
-
static
join(*args)¶ This method joins ‘paths’ inside a github repository
-
listdir(path)¶ List the contents of a directory
-
read(path, api=True)¶ Read the contents of a file and return it Or, if api=False it will download the file and return the location of the downloaded file
-
walk(top=None, topdown=True)¶ Walk the github repo in an os.walk like fashion.
-
-
easybuild.tools.github.check_github()¶ Check status of GitHub integration, and report back. * check whether GitHub username is available * check whether a GitHub token is available, and whether it works * check whether git and GitPython are available * check whether push access to own GitHub repositories works * check whether creating gists works * check whether location to local working directories for Git repositories is available (not strictly needed)
-
easybuild.tools.github.check_pr_eligible_to_merge(pr_data)¶ Check whether PR is eligible for merging.
Parameters: pr_data – PR data obtained through GitHub API Returns: boolean value indicates whether PR is eligible
-
easybuild.tools.github.close_pr(pr, motivation_msg=None)¶ Close specified pull request
Parameters: - pr – PR number
- motivation_msg – string containing motivation for closing the PR
-
easybuild.tools.github.create_gist(txt, fn, descr=None, github_user=None)¶ Create a gist with the provided text.
-
easybuild.tools.github.det_patch_specs(patch_paths, file_info, ec_dirs)¶ Determine software names for patch files
-
easybuild.tools.github.download_repo(repo='easybuild-easyconfigs', branch='master', account='easybuilders', path=None, github_user=None)¶ Download entire GitHub repo as a tar.gz archive, and extract it into specified path. :param repo: repo to download :param branch: branch to download :param account: GitHub account to download repo from :param path: path to extract to :param github_user: name of GitHub user to use
-
easybuild.tools.github.fetch_easyconfigs_from_pr(pr, path=None, github_user=None)¶ Fetch patched easyconfig files for a particular PR.
-
easybuild.tools.github.fetch_github_token(user)¶ Fetch GitHub token for specified user from keyring.
-
easybuild.tools.github.fetch_latest_commit_sha(repo, account, branch='master', github_user=None, token=None)¶ Fetch latest SHA1 for a specified repository and branch. :param repo: GitHub repository :param account: GitHub account :param branch: branch to fetch latest SHA1 for :param github_user: name of GitHub user to use :param token: GitHub token to use :return: latest SHA1
-
easybuild.tools.github.fetch_pr_data(pr, pr_target_account, pr_target_repo, github_user, full=False, **parameters)¶ Fetch PR data from GitHub
-
easybuild.tools.github.find_easybuild_easyconfig(github_user=None)¶ Fetches the latest EasyBuild version eb file from GitHub
Parameters: github_user – name of GitHub user to use when querying GitHub
-
easybuild.tools.github.find_software_name_for_patch(patch_name, ec_dirs)¶ Scan all easyconfigs in the robot path(s) to determine which software a patch file belongs to
Parameters: - patch_name – name of the patch file
- ecs_dirs – list of directories to consider when looking for easyconfigs
Returns: name of the software that this patch file belongs to (if found)
-
easybuild.tools.github.github_api_get_request(request_f, github_user=None, token=None, **kwargs)¶ Helper method, for performing get requests to GitHub API. :param request_f: function that should be called to compose request, providing a RestClient instance :param github_user: GitHub user name (to try and obtain matching GitHub token if none is provided) :param token: GitHub token to use :return: tuple with return status and data
-
easybuild.tools.github.github_api_put_request(request_f, github_user=None, token=None, **kwargs)¶ Helper method, for performing put requests to GitHub API. :param request_f: function that should be called to compose request, providing a RestClient instance :param github_user: GitHub user name (to try and obtain matching GitHub token if none is provided) :param token: GitHub token to use :return: tuple with return status and data
-
easybuild.tools.github.init_repo(path, repo_name, silent=False)¶ Initialize a new Git repository at the specified location.
Parameters: - path – location where Git repository should be initialized
- repo_name – name of Git repository
- silent – keep quiet (don’t print any messages)
-
easybuild.tools.github.is_patch_for(patch_name, ec)¶ Check whether specified patch matches any patch in the provided EasyConfig instance.
-
easybuild.tools.github.list_prs(params, per_page=100, github_user=None)¶ List pull requests according to specified selection/order parameters
Parameters: params – 3-tuple with selection parameters for PRs (<state>, <sort>, <direction>), see https://developer.github.com/v3/pulls/#parameters
-
easybuild.tools.github.merge_pr(pr)¶ Merge specified pull request
-
easybuild.tools.github.post_comment_in_issue(issue, txt, account='easybuilders', repo='easybuild-easyconfigs', github_user=None)¶ Post a comment in the specified PR.
-
easybuild.tools.github.reasons_for_closing(pr_data)¶ Look for valid reasons to close PR by comparing with existing easyconfigs.
-
easybuild.tools.github.setup_repo(git_repo, target_account, target_repo, branch_name, silent=False, git_only=False)¶ Set up repository by checking out specified branch for specfied GitHub account/repository.
Parameters: - git_repo – git.Repo instance
- target_account – name of GitHub account that owns GitHub repository
- target_repo – name of GitHib repository
- branch_name – name of branch to check out
- silent – keep quiet (don’t print any messages)
- git_only – only use git@github.com repo URL, skip trying https://github.com first
-
easybuild.tools.github.setup_repo_from(git_repo, github_url, target_account, branch_name, silent=False)¶ Set up repository by checking out specified branch from repository at specified URL.
Parameters: - git_repo – git.Repo instance
- github_url – URL to GitHub repository
- target_account – name of GitHub account that owns GitHub repository at specified URL
- branch_name – name of branch to check out
- silent – keep quiet (don’t print any messages)
-
easybuild.tools.github.validate_github_token(token, github_user)¶ Check GitHub token: * see if it conforms expectations (only [a-f]+[0-9] characters, length of 40) * see if it can be used for authenticated access