Esempio n. 1
0
def status(verbose, logger=LOGGER, config=CONFIG):
    """shows upcoming prerequisites and inflight human tasks
    """
    ###
    if not validate_data_repo_updated(logger, config):
        sys.exit(1)

    # upcoming prerequisites
    upcoming_releases = get_releases(config, logger, inflight=False, filter=incomplete_filter)
    if verbose:
        upcoming_releases = get_releases(config, logger, inflight=False, filter=no_filter)
    upcoming_releases = sorted(upcoming_releases, key=lambda x: x["date"], reverse=True)
    logger.info("UPCOMING RELEASES...")
    if not upcoming_releases:
        logger.info("=" * 79)
        logger.info("[no upcoming releases with prerequisite tasks to do]")
    for release in upcoming_releases:
        remaining_prereqs = get_remaining_items(release["preflight"]["human_tasks"])

        logger.info("=" * 79)
        logger.info("Upcoming Release: %s %s", release["product"], release["version"])
        logger.info("Expected GTB: %s", release["date"])
        logger.info("\tIncomplete prerequisites:")
        for prereq in remaining_prereqs:
            logger.info("\t\t* ID: %s, deadline: %s, bug %s - %s", prereq['id'], prereq['deadline'],
                        prereq["bug"], prereq["description"])
        if not remaining_prereqs:
            logger.info("\t\t* none")

    ###

    ###
    # releases in flight
    incomplete_releases = [release for release in get_releases(config, logger, filter=incomplete_filter)]
    logger.info("")
    logger.info("INFLIGHT RELEASES...")
    if not incomplete_releases:
        logger.info("=" * 79)
        logger.info("[no inflight releases with human tasks to do]")
    for release in incomplete_releases:
        log_release_status(release, logger)
    ###

    ###
    # completed releases (unresolved issues)
    if verbose:
        complete_releases = [release for release in get_releases(config, logger, filter=complete_filter)]
        logger.info("")
        logger.info("COMPLETED RELEASES...")
        if not complete_releases:
            logger.info("=" * 79)
            logger.info("[all completed releases have been archived]")
        for release in complete_releases:
            log_release_status(release, logger)
Esempio n. 2
0
def postmortem(date, logger=LOGGER, config=CONFIG):
    """creates a postmortem file based on completed releases and their unresolved issues.
    archives release files that are completed
    using the same date will only append and archive releases as they are updated

    argument: date of planned postmortem. format: YYYY-MM-DD
    """

    if not date:
        logger.critical("For now, you must be explicit and specify --date")
        sys.exit(1)

    date = sanitize_date_input(date, logger)

    completed_releases = [release for release in get_releases(config, logger, filter=complete_filter)]
    postmortem_data_path = os.path.join(config["releasewarrior_data_repo"], config["postmortems"],
                                        "{}.json".format(date))
    postmortem_wiki_path = os.path.join(config["releasewarrior_data_repo"], config["postmortems"],
                                        "{}.md".format(date))
    wiki_template = config['templates']["wiki"]["postmortem"]

    # validate
    validate_rw_repo(logger, config)
    if not completed_releases:
        logger.warning("No recently completed releases. Nothing to do!")
        sys.exit(1)
    # make sure archive and postmortem dirs exist
    for product in config['releases']['archive']:
        os.makedirs(
            os.path.join(config['releasewarrior_data_repo'], config['releases']['archive'][product]),
            exist_ok=True
        )
    os.makedirs(os.path.join(config['releasewarrior_data_repo'], config['postmortems']), exist_ok=True)

    # get existing postmortem data
    postmortem_data = {
        "date": date,
        "complete_releases": []
    }
    if os.path.exists(postmortem_data_path):
        postmortem_data = load_json(postmortem_data_path)

    # archive completed releases
    for release in completed_releases:
        _, data_path, wiki_path = get_release_info(release["product"], release["version"],
                                                   logger, config)
        # add release to postmortem data
        postmortem_data["complete_releases"].append(generate_release_postmortem_data(release))
        # archive release
        archive_dir = os.path.join(config["releasewarrior_data_repo"],
                                   config["releases"]["archive"][release["product"]])
        git.move(data_path, os.path.join(archive_dir, os.path.basename(data_path)), logger, config)
        git.move(wiki_path, os.path.join(archive_dir, os.path.basename(wiki_path)), logger, config)

    commit_msg = "updates {} postmortem".format(date)
    postmortem_data["complete_releases"] = sorted(postmortem_data["complete_releases"],
                                                  key=lambda x: x["date"])
    write_and_commit(postmortem_data, postmortem_data_path, postmortem_wiki_path,
                     commit_msg, logger, config, wiki_template=wiki_template)