Skip to content

Commit

Permalink
reset statues on re-start of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smuzaffar committed Nov 11, 2020
1 parent cbaa8ec commit 49a62bb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
14 changes: 13 additions & 1 deletion github_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,20 @@ def get_gh_token(repository=None):
import repo_config
return open(expanduser(repo_config.GH_TOKEN)).read().strip()

def get_combined_statuses(commit, repository, token=None):
if not token: token = get_gh_token(repository)
return github_api("repos/%s/%s/status" % (repository, commit))

def mark_commit_status(commit, repository, context="default", state="pending", url="", description="Test started", token=None):
def mark_commit_status(commit, repository, context="default", state="pending", url="", description="Test started", token=None, reset=False):
if not token: token = get_gh_token(repository)
params = {'state': state, 'target_url': url, 'description': description, 'context': context}
github_api('/repos/%s/statuses/%s' % (repository, commit), token, params)
if reset:
statuses = get_combined_statuses(commit, repository, token)
if 'statuses' not in statuses: return
params = {'state': 'pending', 'target_url': '', 'description': 'Not yet started'}
for s in statuses['statuses']:
if s['context'].startswith(context+"/"):
params['context'] = s['context']
github_api('/repos/%s/statuses/%s' % (repository, commit), token, params)
return
3 changes: 2 additions & 1 deletion mark_commit_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
parser.add_option("-C", "--context", dest="context", help="Status context", type=str, default="default")
parser.add_option("-u", "--url", dest="url", help="Status results URL", type=str, default="")
parser.add_option("-s", "--state", dest="state", help="State of the status e.g. pending, failure, error or success", type=str, default='pending')
parser.add_option("-R", "--reset-all", dest="reset_all", help="Reset all matching contexts", action="store_true", default=False)
opts, args = parser.parse_args()

mark_commit_status(opts.commit, opts.repository, opts.context, opts.state, opts.url, opts.description)
mark_commit_status(opts.commit, opts.repository, opts.context, opts.state, opts.url, opts.description, reset=opts.reset_all)

2 changes: 1 addition & 1 deletion pr_testing/test_multiple_prs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ for PR in ${PULL_REQUESTS}; do
echo "${PR}=${COMMIT}" >> ${WORKSPACE}/prs_commits.txt
done

mark_commit_status_all_prs '' 'pending' -u "${BUILD_URL}" -d 'Setting up build environment' || true
mark_commit_status_all_prs '' 'pending' -u "${BUILD_URL}" -d 'Setting up build environment' --reset || true

COMP_QUEUE=
case $CMSSW_QUEUE in
Expand Down

0 comments on commit 49a62bb

Please sign in to comment.