controllers.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:sample-platform 作者: CCExtractor 项目源码 文件源码
def queue_test(db, gh_commit, commit, test_type, branch="master", pr_nr=0):
    """
    Function to store test details into Test model separately for various
    vm. Post status to GitHub
    """
    from run import log
    fork = Fork.query.filter(Fork.github.like(
        "%/CCExtractor/ccextractor.git")).first()
    if test_type == TestType.pull_request:
        branch = "pull_request"
    # Create Linux test entry
    linux = Test(TestPlatform.linux, test_type, fork.id, branch, commit,
                 pr_nr)
    db.add(linux)
    # Create Windows test entry
    windows = Test(TestPlatform.windows, test_type, fork.id, branch,
                   commit, pr_nr)
    db.add(windows)
    db.commit()
    # Update statuses on GitHub
    if gh_commit is not None:
        test_ids = [linux.id, windows.id]
        ci_names = [linux.platform.value, windows.platform.value]
        for idx in range(len(ci_names)):
            try:
                gh_commit.post(
                    state=Status.PENDING, description="Tests queued",
                    context="CI - {name}".format(name=ci_names[idx]),
                    target_url=url_for(
                        'test.by_id', test_id=test_ids[idx], _external=True))
            except ApiError as a:
                log.critical(
                    'Could not post to GitHub! Response: {res}'.format(
                        res=a.response)
                )

    # We wait for the cron to kick off the CI VM's
    log.debug("Created tests, waiting for cron...")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号