Skip to content

Commit 29e59f4

Browse files
committed
add support for GitHub Checks
1 parent 505f364 commit 29e59f4

File tree

4 files changed

+44
-5
lines changed

4 files changed

+44
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ the name of the repository you are configuring homu for.
107107
- Payload URL: `http://HOST:PORT/github`
108108
- Content type: `application/json`
109109
- Secret: The same as `repo.NAME.github.secret` in `cfg.toml`
110-
- Events: `Issue Comment`, `Pull Request`, `Push`, `Status`
110+
- Events: `Issue Comment`, `Pull Request`, `Push`, `Status`, `Check runs`
111111

112112
6. Add a Webhook to your continuous integration service, if necessary. You don't
113113
need this if using Travis/Appveyor.

cfg.sample.toml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ secret = ""
120120
#]
121121

122122
# Travis integration. Don't forget to allow Travis to test the `auto` branch!
123-
[repo.NAME.status.travis]
124-
# String label set by status updates. Don't touch this unless you really know
125-
# what you're doing.
126-
context = 'continuous-integration/travis-ci/push'
123+
[repo.NAME.checks.travis]
124+
# Name of the Checks API run. Don't touch this unless you really know what
125+
# you're doing.
126+
name = "Travis CI - Branch"
127127

128128
# Appveyor integration. Don't forget to allow Appveyor to test the `auto` branch!
129129
#[repo.NAME.status.appveyor]
@@ -144,6 +144,13 @@ context = 'continuous-integration/travis-ci/push'
144144
# only used if status_based_exemption is true.
145145
#pr_context = ""
146146

147+
# Generic GitHub Checks API support. You don't need this if you're using the
148+
# above examples for Travis/Appveyor.
149+
#[repo.NAME.checks.LABEL]
150+
#
151+
# String name of the Checks run.
152+
#name = ""
153+
147154
# Use buildbot for running tests
148155
#[repo.NAME.buildbot]
149156
#

homu/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,9 @@ def start_build(state, repo_cfgs, buildbot_slots, logger, db, git_cfg):
12361236

12371237
if found_travis_context and len(builders) == 1:
12381238
can_try_travis_exemption = True
1239+
if 'checks' in repo_cfg:
1240+
builders += ['checks-' + key for key, value in repo_cfg['checks'].items() if 'name' in value] # noqa
1241+
only_status_builders = False
12391242

12401243
if len(builders) is 0:
12411244
raise RuntimeError('Invalid configuration')
@@ -1680,6 +1683,8 @@ def main():
16801683
builders += ['travis']
16811684
if 'status' in repo_cfg:
16821685
builders += ['status-' + key for key, value in repo_cfg['status'].items() if 'context' in value] # noqa
1686+
if 'checks' in repo_cfg:
1687+
builders += ['checks-' + key for key, value in repo_cfg['checks'].items() if 'name' in value] # noqa
16831688
if len(builders) is 0:
16841689
raise RuntimeError('Invalid configuration')
16851690

homu/server.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,33 @@ def fail(err):
517517
report_build_res(info['state'] == 'success', info['target_url'],
518518
'status-' + status_name, state, logger, repo_cfg)
519519

520+
elif event_type == 'check_run':
521+
try:
522+
state, repo_label = find_state(info['check_run']['head_sha'])
523+
except ValueError:
524+
return 'OK'
525+
526+
current_run_name = info['check_run']['name']
527+
checks_name = None
528+
if 'checks' in repo_cfg:
529+
for name, value in repo_cfg['checks'].items():
530+
if 'name' in value and value['name'] == current_run_name:
531+
checks_name = name
532+
if checks_name is None:
533+
return 'OK'
534+
535+
if info['check_run']['status'] != 'completed':
536+
return 'OK'
537+
if info['check_run']['conclusion'] is None:
538+
return 'OK'
539+
540+
report_build_res(
541+
info['check_run']['conclusion'] == 'success',
542+
info['check_run']['details_url'],
543+
'checks-' + checks_name,
544+
state, logger, repo_cfg,
545+
)
546+
520547
return 'OK'
521548

522549

0 commit comments

Comments
 (0)