Ejemplo n.º 1
0
import combine
import configuration

os.chdir(configuration.current_dir)

# 接收邮箱
email_address_list = configuration.email_address_list

# 统计并生成报告
statistics

# 合并报告(当生成了多个报告时,合并成一个)
combine

# 生成图表
for filename in os.listdir():
    if filename.startswith('XXX-' + configuration.project_name):
        charts.generate_charts(filename)

# 发送邮件
filenames = []
for filename in os.listdir():
    if filename.startswith('XXX-' + configuration.project_name):
        filenames.append(filename)

send_email.send_email(filenames, email_address_list)

# 删除本地文件
for filename in os.listdir():
    if filename.endswith('-测试日报.xlsx'):
        send2trash.send2trash(filename)
Ejemplo n.º 2
0
def main():
    """Entry point to the QA Dashboard."""
    log.setLevel(log.INFO)
    log.info("Setup")
    with log.indent():
        config = Config()
        cli_arguments = cli_parser.parse_args()
        repositories = Repositories(config)

        # some CLI arguments are used to DISABLE given feature of the dashboard,
        # but let's not use double negation everywhere :)
        ci_jobs_table_enabled = not cli_arguments.disable_ci_jobs
        code_quality_table_enabled = not cli_arguments.disable_code_quality
        liveness_table_enabled = not cli_arguments.disable_liveness
        sla_table_enabled = not cli_arguments.disable_sla
        clone_repositories_enabled = cli_arguments.clone_repositories
        cleanup_repositories_enabled = cli_arguments.cleanup_repositories

        log.info("Environment variables check")
        with log.indent():
            check_environment_variables()
        log.success("Environment variables check done")

    log.success("Setup done")

    results = Results()

    # list of repositories to check
    results.repositories = repositories.repolist

    # we need to know which tables are enabled or disabled to proper process the template
    results.sla_table_enabled = sla_table_enabled
    results.liveness_table_enabled = liveness_table_enabled
    results.code_quality_table_enabled = code_quality_table_enabled
    results.ci_jobs_table_enabled = ci_jobs_table_enabled

    results.teams = teams
    results.sprint = config.get_sprint()
    log.info("Sprint: " + results.sprint)

    ci_jobs = CIJobs()

    job_statuses = read_job_statuses(ci_jobs, ci_jobs_table_enabled,
                                     liveness_table_enabled)

    results.smoke_tests_total_builds, results.smoke_tests_success_builds = \
        production_smoketests_status(ci_jobs)

    results.sprint_plan_url = config.get_sprint_plan_url()
    log.info("Sprint plan URL: " + results.sprint_plan_url)
    code_coverage_threshold = get_code_coverage_threshold(
        cli_arguments, config)

    for team in teams:
        results.issues_list_url[team] = config.get_list_of_issues_url(team)

    if liveness_table_enabled:
        prepare_data_for_liveness_table(results, ci_jobs, job_statuses)

    prepare_data_for_repositories(repositories.repolist, results, ci_jobs,
                                  job_statuses, clone_repositories_enabled,
                                  cleanup_repositories_enabled,
                                  code_quality_table_enabled,
                                  ci_jobs_table_enabled,
                                  code_coverage_threshold)

    if sla_table_enabled:
        prepare_data_for_sla_table(results)

    if code_quality_table_enabled and liveness_table_enabled:
        export_into_csv(results, repositories.repolist)

    generate_dashboard(results, ignored_files_for_pylint,
                       ignored_files_for_pydocstyle)
    generate_charts(results)
    generate_quality_labels(results)