Beispiel #1
0
def test_pr(num, post_results=True):
    # Get Github authorisation first, so that the user is prompted straight away
    # if their login is needed.
    if post_results:
        gh_api.get_auth_token()

    testrun = TestRun(num)

    testrun.get_branch()

    testrun.run()

    testrun.dump_results()

    testrun.save_logs()
    testrun.print_results()

    if post_results:
        results_urls = testrun.post_logs()
        testrun.post_results_comment()
        print("(Posted to Github)")
    else:
        post_script = os.path.join(os.path.dirname(sys.argv[0]),
                                   "post_pr_test.py")
        print("To post the results to Github, run", post_script)
Beispiel #2
0
def test_pr(num, post_results=True, extra_args=None):
    # Get Github authorisation first, so that the user is prompted straight away
    # if their login is needed.
    if post_results:
        gh_api.get_auth_token()

    testrun = TestRun(num, extra_args or [])

    testrun.get_branch()

    testrun.run()

    testrun.dump_results()

    testrun.save_logs()
    testrun.print_results()

    if post_results:
        testrun.post_logs()
        testrun.post_results_comment()
        print("(Posted to Github)")
    else:
        post_script = os.path.join(
            os.path.dirname(sys.argv[0]), "post_pr_test.py")
        print("To post the results to Github, run", post_script)
Beispiel #3
0
def test_pr(num, post_results=True):
    # Get Github authorisation first, so that the user is prompted straight away
    # if their login is needed.
    if post_results:
        gh_api.get_auth_token()

    setup()
    pr = gh_api.get_pull_request(gh_project, num)
    get_branch(
        repo=pr['head']['repo']['clone_url'],
        branch=pr['head']['ref'],
        owner=pr['head']['repo']['owner']['login'],
        mergeable=pr['mergeable'],
    )

    results = []
    for py, venv in venvs:
        tic = time.time()
        passed, log = run_tests(venv)
        elapsed = int(time.time() - tic)
        print("Ran tests with %s in %is" % (py, elapsed))
        missing_libraries = get_missing_libraries(log)
        if passed:
            results.append((py, True, None, missing_libraries))
        else:
            results.append((py, False, log, missing_libraries))

    dump_results(num, results, pr)

    results_paths = save_logs(results, pr)
    print_results(pr, results_paths)

    if post_results:
        results_urls = post_logs(results)
        post_results_comment(pr, results_urls, num)
        print("(Posted to Github)")
    else:
        post_script = os.path.join(os.path.dirname(sys.argv[0]),
                                   "post_pr_test.py")
        print("To post the results to Github, run", post_script)
Beispiel #4
0
def test_pr(num, post_results=True):
    # Get Github authorisation first, so that the user is prompted
    # straight away if their login is needed.
    if post_results:
        gh_api.get_auth_token()

    setup()
    pr = gh_api.get_pull_request(gh_project, num)
    get_branch(repo=pr['head']['repo']['clone_url'],
                 branch=pr['head']['ref'],
                 owner=pr['head']['repo']['owner']['login'],
                 mergeable=pr['mergeable'],
              )

    results = []
    for py, venv in venvs:
        tic = time.time()
        passed, log = run_tests(venv)
        elapsed = int(time.time() - tic)
        print("Ran tests with %s in %is" % (py, elapsed))
        missing_libraries = get_missing_libraries(log)
        if passed:
            results.append((py, True, None, missing_libraries))
        else:
            results.append((py, False, log, missing_libraries))

    dump_results(num, results, pr)

    results_paths = save_logs(results, pr)
    print_results(pr, results_paths)

    if post_results:
        results_urls = post_logs(results)
        post_results_comment(pr, results_urls, num)
        print("(Posted to Github)")
    else:
        post_script = os.path.join(os.path.dirname(sys.argv[0]),
             "post_pr_test.py")
        print("To post the results to Github, run", post_script)