Skip to content
This repository has been archived by the owner on Mar 22, 2021. It is now read-only.

spec: also set required context on PRs #30

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 6 additions & 7 deletions docs/sample.papr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,12 @@ context: 'CI Tester'

# OPTIONAL
# Mark this testsuite as required. This causes a special
# "required" context to be reported to GitHub on branch
# tests. The result is set to successful only if all
# testsuites marked as required are also successful. This is
# useful for integration with merge bots, so that they only
# need to watch for a single status rather than multiple
# (possibly changing) statuses. If omitted, defaults to
# false.
# "required" context to be reported to GitHub. The result is
# set to successful only if all testsuites marked as
# required are also successful. This is useful for grouping
# statuses under a single context to be used by the branch
# protection settings or by a merge bot, rather than dealing
# with multiple (possibly changing) statuses.
required: true

# OPTIONAL
Expand Down
19 changes: 12 additions & 7 deletions papr/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,17 @@ def count_failures(suites):

def update_required_context(suites):

# only send 'required' context for branches
# Prepare a fallback URL in case something goes really wrong in the tester.
# We just link back to the branch/PR for now, though we should probably
# just capture the same text we used to update the commit status.
if 'github_pull_id' in os.environ:
return
fallback_url = ('https://github.com/%s/pull/%s' %
(os.environ['github_repo'],
os.environ['github_pull_id']))
else:
fallback_url = ('https://github.com/%s/commits/%s' %
(os.environ['github_repo'],
os.environ['github_branch']))

# don't send 'required' context if we're only targeting some testsuites
if 'github_contexts' in os.environ:
Expand All @@ -185,11 +193,8 @@ def update_required_context(suites):
with open("state/suite-%d/url" % i) as f:
url = f.read().strip()
else:
# Something went really wrong in the tester. Just link back to the
# branch for now, though we should probably just capture the same
# text we used to update the commit status.
url = ('https://github.com/%s/commits/%s' %
(os.environ['github_repo'], os.environ['github_branch']))
# something went really wrong in the tester, just use fallback url
url = fallback_url
result = (suite['rc'] == 0)
results_suites.append((name, result, url))

Expand Down