Example #1
0
def main(rel_type):

    utils.initialize_github()
    g = utils.GITHUB_INSTANCE
    repo = utils.CURRENT_REPO

    # There is a GitHub API capacity of 5000 per hour i.e. that a maximum of 5000 requests can be made to GitHub per hour.
    # Therefore, the following line indicates how many requests are currently still available
    print("Current GitHub API capacity", g.rate_limiting, "at",
          datetime.now().isoformat())

    # If this limit is exceeded, an exception will be raised:
    # github.GithubException.RateLimitExceededException: 403
    # {"message": "API rate limit exceeded for user ID XXX.", "documentation_url":
    # "https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"}

    # TODO: we cache PRs data in a local file. For now, if it exists, it will be used,
    # otherwise it will be recreated. Later, there may be an option to use the cache or
    # to enforce retrieving updated PR details from Github. I think default is to update
    # from GitHub (to get newly merged PRs, updates of labels, PR titles etc., while the
    # cache could be used for testing and polishing the code to generate output )

    # TODO: add some data to the cache, e.g. when the cache is saved.
    # Produce warning if old.

    if os.path.isfile("prscache.json"):
        print("Using cached data from prscache.json ...")
        with open("prscache.json", "r") as read_file:
            prs = json.load(read_file)
    else:
        print("Retrieving data using GitHub API ...")
        prs = get_prs(repo, history_start_date)

    prs = filter_prs(prs, rel_type)
    changes_overview(prs, history_start_date, rel_type)
    print("Remaining GitHub API capacity", g.rate_limiting, "at",
          datetime.now().isoformat())
Example #2
0
# If we do import * from utils, then initialize_github can't overwrite the
# global GITHUB_INSTANCE and CURRENT_REPO variables.
import utils
import github
import os

# Identify GAP release version
try:
    GAPVERSION = utils.get_makefile_var("GAP_BUILD_VERSION")
except:
    utils.error("Could not get GAP version")

utils.notice(f"Detected GAP version {GAPVERSION}")

utils.initialize_github()

# Error if this release has been already created on GitHub
if utils.check_whether_github_release_exists("v"+GAPVERSION):
    utils.error(f"Release v{GAPVERSION} already exists!")

# Create release
CURRENT_BRANCH = utils.get_makefile_var("PKG_BRANCH")
RELEASE_NOTE = f"For an overview of changes in GAP {GAPVERSION} see the " \
    + "[CHANGES.md](https://github.com/gap-system/gap/blob/master/CHANGES.md) file."
utils.notice(f"Creating release v{GAPVERSION}")
RELEASE = utils.CURRENT_REPO.create_git_release("v"+GAPVERSION, "v"+GAPVERSION,
                                                RELEASE_NOTE,
                                                target_commitish=CURRENT_BRANCH,
                                                prerelease=True)
Example #3
0
    error("--push-remote and --pr-remote cannot be empty strings")

if args.tmpdir != None:
    if not os.path.isdir(args.tmpdir) or not os.access(args.tmpdir, os.W_OK):
        error("--tmpdir does not describe a writeable directory")
    tmpdir = args.tmpdir
else:
    tmpdir = tempfile.gettempdir()
if not tmpdir[-1] == "/":
    tmpdir += "/"

################################################################################
# Use the GitHub API to find the appropriate GAP release on GitHub
utils.CURRENT_REPO_NAME = os.environ.get("GITHUB_REPOSITORY",
                                         args.gap_fork + "/gap")
utils.initialize_github(args.token)
if args.tag:
    try:
        release = utils.CURRENT_REPO.get_release(args.tag)
    except:
        error("non-existent or ambiguous release tag name: " + args.tag)
else:
    # Using latest release; therefore ignore drafts and prerelease
    release = [ x for x in utils.CURRENT_REPO.get_releases() if \
                not x.draft and not x.prerelease and is_possible_gap4_release_tag(x.tag_name)]
    try:
        release = release[0]
    except:
        error(
            "cannot determine the latest (non-draft, non-prerelease) v4.X.Y release"
        )