diff --git a/homu/main.py b/homu/main.py index 5bb00fe7..76dca037 100644 --- a/homu/main.py +++ b/homu/main.py @@ -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: @@ -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] = '' @@ -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 @@ -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 diff --git a/homu/server.py b/homu/server.py index 4e768cb7..c7679bd3 100644 --- a/homu/server.py +++ b/homu/server.py @@ -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, @@ -227,6 +233,7 @@ def github(): g.db, realtime=True, sha=original_commit_id, + pending=pending, ): state.save() @@ -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, @@ -342,6 +355,7 @@ def github(): g.my_username, g.db, realtime=True, + pending=pending, ): state.save()