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...")
评论列表
文章目录