Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions homu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def sha_cmp(short, full):
def sha_or_blank(sha):
return sha if re.match(r'^[0-9a-f]+$', sha) else ''

def parse_commands(body, username, repo_cfg, state, my_username, db, *, realtime=False, sha=''):
def parse_commands(body, username, repo_cfg, state, my_username, db, *, realtime=False, sha='', pending=False):
try_only = False
if username not in repo_cfg['reviewers'] and username != my_username:
if username == state.delegate:
Expand Down Expand Up @@ -360,7 +360,11 @@ def parse_commands(body, username, repo_cfg, state, my_username, db, *, realtime
found = False

if found:
if realtime and pending:
state.add_comment('Another test is already running on this repository. This test will begin once the other test is finishied.')
state_changed = True
if state.status == 'pending' and realtime:
state.add_comment('Please wait until the current test finishes before starting the next test.')

words[i] = ''

Expand Down Expand Up @@ -612,12 +616,18 @@ def start_build_or_rebuild(state, repo_cfgs, *args):
def process_queue(states, repos, repo_cfgs, logger, buildbot_slots, db, git_cfg):
for repo_label, repo in repos.items():
repo_states = sorted(states[repo_label].values())

# find out whether a test is running on this repository
pending = False
for s in repo_states:
if s.status == 'pending':
pending = True

for state in repo_states:
if state.status == 'pending' and not state.try_:
break

elif state.status == '' and state.approved_by:
elif state.status == '' and state.approved_by and not pending:
if start_build_or_rebuild(state, repo_cfgs, buildbot_slots, logger, db, git_cfg):
return

Expand All @@ -630,7 +640,7 @@ def process_queue(states, repos, repo_cfgs, logger, buildbot_slots, db, git_cfg)
return

for state in repo_states:
if state.status == '' and state.try_:
if state.status == '' and state.try_ and not pending:
if start_build(state, repo_cfgs, buildbot_slots, logger, db, git_cfg):
return

Expand Down
14 changes: 14 additions & 0 deletions homu/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ def github():

state = g.states[repo_label][pull_num]

pending = False
if state.status != 'pending':
for state in g.states[repo_label].values():
if state.status == 'pending':
pending = True

if parse_commands(
body,
username,
Expand All @@ -227,6 +233,7 @@ def github():
g.db,
realtime=True,
sha=original_commit_id,
pending=pending,
):
state.save()

Expand Down Expand Up @@ -334,6 +341,12 @@ def github():
state.title = info['issue']['title']
state.body = info['issue']['body']

pending = False
if state.status != 'pending':
for state in g.states[repo_label].values():
if state.status == 'pending':
pending = True

if parse_commands(
body,
username,
Expand All @@ -342,6 +355,7 @@ def github():
g.my_username,
g.db,
realtime=True,
pending=pending,
):
state.save()

Expand Down