2017-12-04 08:31:57 -06:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2020-03-04 03:17:15 -06:00
|
|
|
# This script computes the new "current" toolstate for the toolstate repo (not to be
|
|
|
|
# confused with publishing the test results, which happens in `src/bootstrap/toolstate.rs`).
|
|
|
|
# It gets called from `src/ci/publish_toolstate.sh` when a new commit lands on `master`
|
|
|
|
# (i.e., after it passed all checks on `auto`).
|
2019-07-23 03:50:45 -05:00
|
|
|
|
2019-09-03 04:33:29 -05:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2017-12-04 08:31:57 -06:00
|
|
|
import sys
|
|
|
|
import re
|
2019-06-12 09:59:20 -05:00
|
|
|
import os
|
2017-12-04 08:31:57 -06:00
|
|
|
import json
|
|
|
|
import datetime
|
|
|
|
import collections
|
2018-02-21 08:25:12 -06:00
|
|
|
import textwrap
|
2018-02-21 08:58:06 -06:00
|
|
|
try:
|
|
|
|
import urllib2
|
2021-02-20 12:23:46 -06:00
|
|
|
from urllib2 import HTTPError
|
2018-02-21 08:58:06 -06:00
|
|
|
except ImportError:
|
|
|
|
import urllib.request as urllib2
|
2021-02-20 12:23:46 -06:00
|
|
|
from urllib.error import HTTPError
|
|
|
|
try:
|
|
|
|
import typing
|
|
|
|
except ImportError:
|
|
|
|
pass
|
2017-12-04 08:31:57 -06:00
|
|
|
|
2019-03-09 00:28:25 -06:00
|
|
|
# List of people to ping when the status of a tool or a book changed.
|
2019-09-03 04:33:29 -05:00
|
|
|
# These should be collaborators of the rust-lang/rust repository (with at least
|
|
|
|
# read privileges on it). CI will fail otherwise.
|
2017-12-04 08:31:57 -06:00
|
|
|
MAINTAINERS = {
|
2019-09-04 03:21:23 -05:00
|
|
|
'miri': {'oli-obk', 'RalfJung', 'eddyb'},
|
|
|
|
'rls': {'Xanewok'},
|
2020-07-19 13:10:38 -05:00
|
|
|
'rustfmt': {'topecongiro', 'calebcartwright'},
|
2019-09-04 03:21:23 -05:00
|
|
|
'book': {'carols10cents', 'steveklabnik'},
|
2020-12-04 21:05:03 -06:00
|
|
|
'nomicon': {'frewsxcv', 'Gankra', 'JohnTitor'},
|
2019-09-04 03:21:23 -05:00
|
|
|
'reference': {'steveklabnik', 'Havvy', 'matthewjasper', 'ehuss'},
|
2019-09-09 09:03:57 -05:00
|
|
|
'rust-by-example': {'steveklabnik', 'marioidival'},
|
2020-08-12 06:53:50 -05:00
|
|
|
'embedded-book': {'adamgreig', 'andre-richter', 'jamesmunns', 'therealprof'},
|
2020-04-15 11:19:02 -05:00
|
|
|
'edition-guide': {'ehuss', 'steveklabnik'},
|
2020-10-12 13:13:00 -05:00
|
|
|
'rustc-dev-guide': {'spastorino', 'amanjeev', 'JohnTitor'},
|
2017-12-04 08:31:57 -06:00
|
|
|
}
|
|
|
|
|
2020-05-20 15:14:47 -05:00
|
|
|
LABELS = {
|
|
|
|
'miri': ['A-miri', 'C-bug'],
|
|
|
|
'rls': ['A-rls', 'C-bug'],
|
2020-08-05 04:03:08 -05:00
|
|
|
'rustfmt': ['A-rustfmt', 'C-bug'],
|
2020-05-20 15:14:47 -05:00
|
|
|
'book': ['C-bug'],
|
|
|
|
'nomicon': ['C-bug'],
|
|
|
|
'reference': ['C-bug'],
|
|
|
|
'rust-by-example': ['C-bug'],
|
|
|
|
'embedded-book': ['C-bug'],
|
|
|
|
'edition-guide': ['C-bug'],
|
|
|
|
'rustc-dev-guide': ['C-bug'],
|
|
|
|
}
|
|
|
|
|
2018-12-19 10:44:46 -06:00
|
|
|
REPOS = {
|
2019-02-21 12:26:45 -06:00
|
|
|
'miri': 'https://github.com/rust-lang/miri',
|
2018-12-19 10:44:46 -06:00
|
|
|
'rls': 'https://github.com/rust-lang/rls',
|
|
|
|
'rustfmt': 'https://github.com/rust-lang/rustfmt',
|
|
|
|
'book': 'https://github.com/rust-lang/book',
|
2019-11-17 09:47:38 -06:00
|
|
|
'nomicon': 'https://github.com/rust-lang/nomicon',
|
|
|
|
'reference': 'https://github.com/rust-lang/reference',
|
2018-12-19 10:44:46 -06:00
|
|
|
'rust-by-example': 'https://github.com/rust-lang/rust-by-example',
|
2019-03-09 00:28:25 -06:00
|
|
|
'embedded-book': 'https://github.com/rust-embedded/book',
|
2019-11-17 09:47:38 -06:00
|
|
|
'edition-guide': 'https://github.com/rust-lang/edition-guide',
|
2020-03-10 15:22:25 -05:00
|
|
|
'rustc-dev-guide': 'https://github.com/rust-lang/rustc-dev-guide',
|
2018-12-19 10:44:46 -06:00
|
|
|
}
|
|
|
|
|
2019-11-21 06:57:40 -06:00
|
|
|
def load_json_from_response(resp):
|
2021-02-20 12:23:46 -06:00
|
|
|
# type: (typing.Any) -> typing.Any
|
2019-11-21 06:57:40 -06:00
|
|
|
content = resp.read()
|
|
|
|
if isinstance(content, bytes):
|
2021-02-20 12:23:46 -06:00
|
|
|
content_str = content.decode('utf-8')
|
2019-11-21 06:57:40 -06:00
|
|
|
else:
|
|
|
|
print("Refusing to decode " + str(type(content)) + " to str")
|
2021-02-20 12:23:46 -06:00
|
|
|
return json.loads(content_str)
|
2017-12-04 08:31:57 -06:00
|
|
|
|
2019-09-03 04:33:29 -05:00
|
|
|
def validate_maintainers(repo, github_token):
|
2021-02-20 12:23:46 -06:00
|
|
|
# type: (str, str) -> None
|
2019-09-03 04:33:29 -05:00
|
|
|
'''Ensure all maintainers are assignable on a GitHub repo'''
|
|
|
|
next_link_re = re.compile(r'<([^>]+)>; rel="next"')
|
|
|
|
|
|
|
|
# Load the list of assignable people in the GitHub repo
|
2021-02-20 12:23:46 -06:00
|
|
|
assignable = [] # type: typing.List[str]
|
|
|
|
url = 'https://api.github.com/repos/' \
|
|
|
|
+ '%s/collaborators?per_page=100' % repo # type: typing.Optional[str]
|
2019-09-03 04:33:29 -05:00
|
|
|
while url is not None:
|
|
|
|
response = urllib2.urlopen(urllib2.Request(url, headers={
|
|
|
|
'Authorization': 'token ' + github_token,
|
|
|
|
# Properly load nested teams.
|
|
|
|
'Accept': 'application/vnd.github.hellcat-preview+json',
|
|
|
|
}))
|
2019-11-21 06:57:40 -06:00
|
|
|
assignable.extend(user['login'] for user in load_json_from_response(response))
|
2019-09-03 04:33:29 -05:00
|
|
|
# Load the next page if available
|
2019-09-04 03:08:54 -05:00
|
|
|
url = None
|
|
|
|
link_header = response.headers.get('Link')
|
|
|
|
if link_header:
|
|
|
|
matches = next_link_re.match(link_header)
|
2019-09-03 04:33:29 -05:00
|
|
|
if matches is not None:
|
|
|
|
url = matches.group(1)
|
|
|
|
|
|
|
|
errors = False
|
|
|
|
for tool, maintainers in MAINTAINERS.items():
|
2019-09-04 03:21:23 -05:00
|
|
|
for maintainer in maintainers:
|
2019-09-03 04:33:29 -05:00
|
|
|
if maintainer not in assignable:
|
|
|
|
errors = True
|
|
|
|
print(
|
|
|
|
"error: %s maintainer @%s is not assignable in the %s repo"
|
|
|
|
% (tool, maintainer, repo),
|
|
|
|
)
|
|
|
|
|
|
|
|
if errors:
|
|
|
|
print()
|
|
|
|
print(" To be assignable, a person needs to be explicitly listed as a")
|
|
|
|
print(" collaborator in the repository settings. The simple way to")
|
|
|
|
print(" fix this is to ask someone with 'admin' privileges on the repo")
|
|
|
|
print(" to add the person or whole team as a collaborator with 'read'")
|
|
|
|
print(" privileges. Those privileges don't grant any extra permissions")
|
|
|
|
print(" so it's safe to apply them.")
|
|
|
|
print()
|
|
|
|
print("The build will fail due to this.")
|
|
|
|
exit(1)
|
|
|
|
|
2020-02-07 21:30:11 -06:00
|
|
|
|
2017-12-04 08:31:57 -06:00
|
|
|
def read_current_status(current_commit, path):
|
2021-02-20 12:23:46 -06:00
|
|
|
# type: (str, str) -> typing.Mapping[str, typing.Any]
|
2017-12-04 08:31:57 -06:00
|
|
|
'''Reads build status of `current_commit` from content of `history/*.tsv`
|
|
|
|
'''
|
2021-02-20 12:23:46 -06:00
|
|
|
with open(path, 'r') as f:
|
2017-12-04 08:31:57 -06:00
|
|
|
for line in f:
|
|
|
|
(commit, status) = line.split('\t', 1)
|
|
|
|
if commit == current_commit:
|
|
|
|
return json.loads(status)
|
|
|
|
return {}
|
|
|
|
|
2020-02-07 21:30:11 -06:00
|
|
|
|
2019-06-12 09:59:20 -05:00
|
|
|
def gh_url():
|
2021-02-20 12:23:46 -06:00
|
|
|
# type: () -> str
|
2019-06-12 09:59:20 -05:00
|
|
|
return os.environ['TOOLSTATE_ISSUES_API_URL']
|
|
|
|
|
2020-02-07 21:30:11 -06:00
|
|
|
|
2019-06-12 09:59:20 -05:00
|
|
|
def maybe_delink(message):
|
2021-02-20 12:23:46 -06:00
|
|
|
# type: (str) -> str
|
2019-06-12 09:59:20 -05:00
|
|
|
if os.environ.get('TOOLSTATE_SKIP_MENTIONS') is not None:
|
|
|
|
return message.replace("@", "")
|
|
|
|
return message
|
|
|
|
|
2020-02-07 21:30:11 -06:00
|
|
|
|
2018-12-18 06:33:02 -06:00
|
|
|
def issue(
|
|
|
|
tool,
|
2019-06-18 14:57:31 -05:00
|
|
|
status,
|
2019-09-04 03:21:23 -05:00
|
|
|
assignees,
|
2018-12-18 06:33:02 -06:00
|
|
|
relevant_pr_number,
|
|
|
|
relevant_pr_user,
|
2020-05-20 15:14:47 -05:00
|
|
|
labels,
|
2021-02-20 12:23:46 -06:00
|
|
|
github_token,
|
2018-12-18 06:33:02 -06:00
|
|
|
):
|
2021-02-20 12:23:46 -06:00
|
|
|
# type: (str, str, typing.Iterable[str], str, str, typing.List[str], str) -> None
|
|
|
|
'''Open an issue about the toolstate failure.'''
|
2019-06-18 14:57:31 -05:00
|
|
|
if status == 'test-fail':
|
|
|
|
status_description = 'has failing tests'
|
|
|
|
else:
|
|
|
|
status_description = 'no longer builds'
|
2019-06-21 06:46:46 -05:00
|
|
|
request = json.dumps({
|
|
|
|
'body': maybe_delink(textwrap.dedent('''\
|
|
|
|
Hello, this is your friendly neighborhood mergebot.
|
|
|
|
After merging PR {}, I observed that the tool {} {}.
|
|
|
|
A follow-up PR to the repository {} is needed to fix the fallout.
|
2018-12-18 06:33:02 -06:00
|
|
|
|
2019-06-21 06:46:46 -05:00
|
|
|
cc @{}, do you think you would have time to do the follow-up work?
|
|
|
|
If so, that would be great!
|
|
|
|
''').format(
|
|
|
|
relevant_pr_number, tool, status_description,
|
2020-02-24 18:02:28 -06:00
|
|
|
REPOS.get(tool), relevant_pr_user
|
2019-06-21 06:46:46 -05:00
|
|
|
)),
|
|
|
|
'title': '`{}` no longer builds after {}'.format(tool, relevant_pr_number),
|
2019-09-04 03:21:23 -05:00
|
|
|
'assignees': list(assignees),
|
2020-05-20 15:14:47 -05:00
|
|
|
'labels': labels,
|
2019-06-21 06:46:46 -05:00
|
|
|
})
|
|
|
|
print("Creating issue:\n{}".format(request))
|
|
|
|
response = urllib2.urlopen(urllib2.Request(
|
|
|
|
gh_url(),
|
2021-02-20 12:23:46 -06:00
|
|
|
request.encode(),
|
2018-12-18 06:33:02 -06:00
|
|
|
{
|
|
|
|
'Authorization': 'token ' + github_token,
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
}
|
|
|
|
))
|
|
|
|
response.read()
|
2017-12-04 08:31:57 -06:00
|
|
|
|
2020-02-07 21:30:11 -06:00
|
|
|
|
2018-02-21 08:25:12 -06:00
|
|
|
def update_latest(
|
|
|
|
current_commit,
|
|
|
|
relevant_pr_number,
|
|
|
|
relevant_pr_url,
|
2018-12-18 06:33:02 -06:00
|
|
|
relevant_pr_user,
|
2018-12-19 10:44:46 -06:00
|
|
|
pr_reviewer,
|
2021-02-20 12:23:46 -06:00
|
|
|
current_datetime,
|
|
|
|
github_token,
|
2018-02-21 08:25:12 -06:00
|
|
|
):
|
2021-02-20 12:23:46 -06:00
|
|
|
# type: (str, str, str, str, str, str, str) -> str
|
2017-12-04 08:31:57 -06:00
|
|
|
'''Updates `_data/latest.json` to match build result of the given commit.
|
|
|
|
'''
|
2019-11-21 06:57:40 -06:00
|
|
|
with open('_data/latest.json', 'r+') as f:
|
2017-12-04 08:31:57 -06:00
|
|
|
latest = json.load(f, object_pairs_hook=collections.OrderedDict)
|
|
|
|
|
|
|
|
current_status = {
|
|
|
|
os: read_current_status(current_commit, 'history/' + os + '.tsv')
|
|
|
|
for os in ['windows', 'linux']
|
|
|
|
}
|
|
|
|
|
|
|
|
slug = 'rust-lang/rust'
|
2018-12-15 07:57:17 -06:00
|
|
|
message = textwrap.dedent('''\
|
|
|
|
📣 Toolstate changed by {}!
|
|
|
|
|
2018-02-21 08:25:12 -06:00
|
|
|
Tested on commit {}@{}.
|
|
|
|
Direct link to PR: <{}>
|
|
|
|
|
2018-12-15 07:57:17 -06:00
|
|
|
''').format(relevant_pr_number, slug, current_commit, relevant_pr_url)
|
2017-12-04 08:31:57 -06:00
|
|
|
anything_changed = False
|
|
|
|
for status in latest:
|
|
|
|
tool = status['tool']
|
|
|
|
changed = False
|
2020-02-07 21:30:11 -06:00
|
|
|
create_issue_for_status = None # set to the status that caused the issue
|
2017-12-04 08:31:57 -06:00
|
|
|
|
|
|
|
for os, s in current_status.items():
|
|
|
|
old = status[os]
|
|
|
|
new = s.get(tool, old)
|
|
|
|
status[os] = new
|
2020-04-04 13:11:01 -05:00
|
|
|
maintainers = ' '.join('@'+name for name in MAINTAINERS.get(tool, ()))
|
2019-09-16 04:29:10 -05:00
|
|
|
# comparing the strings, but they are ordered appropriately:
|
|
|
|
# "test-pass" > "test-fail" > "build-fail"
|
|
|
|
if new > old:
|
2018-12-19 09:37:16 -06:00
|
|
|
# things got fixed or at least the status quo improved
|
2017-12-04 08:31:57 -06:00
|
|
|
changed = True
|
2020-02-20 18:46:09 -06:00
|
|
|
message += '🎉 {} on {}: {} → {} (cc {}).\n' \
|
2019-09-04 03:21:23 -05:00
|
|
|
.format(tool, os, old, new, maintainers)
|
2017-12-04 08:31:57 -06:00
|
|
|
elif new < old:
|
2018-12-19 09:37:16 -06:00
|
|
|
# tests or builds are failing and were not failing before
|
2017-12-04 08:31:57 -06:00
|
|
|
changed = True
|
2018-12-18 06:33:02 -06:00
|
|
|
title = '💔 {} on {}: {} → {}' \
|
|
|
|
.format(tool, os, old, new)
|
2020-02-20 18:46:09 -06:00
|
|
|
message += '{} (cc {}).\n' \
|
2019-09-04 03:21:23 -05:00
|
|
|
.format(title, maintainers)
|
2019-09-16 04:29:10 -05:00
|
|
|
# See if we need to create an issue.
|
|
|
|
if tool == 'miri':
|
|
|
|
# Create issue if tests used to pass before. Don't open a *second*
|
|
|
|
# issue when we regress from "test-fail" to "build-fail".
|
|
|
|
if old == 'test-pass':
|
|
|
|
create_issue_for_status = new
|
|
|
|
else:
|
|
|
|
# Create issue if things no longer build.
|
|
|
|
# (No issue for mere test failures to avoid spurious issues.)
|
|
|
|
if new == 'build-fail':
|
|
|
|
create_issue_for_status = new
|
2018-12-19 08:54:51 -06:00
|
|
|
|
2019-06-21 06:07:44 -05:00
|
|
|
if create_issue_for_status is not None:
|
2019-02-12 07:48:53 -06:00
|
|
|
try:
|
|
|
|
issue(
|
2021-02-20 12:23:46 -06:00
|
|
|
tool, create_issue_for_status, MAINTAINERS.get(tool, ()),
|
|
|
|
relevant_pr_number, relevant_pr_user, LABELS.get(tool, []),
|
|
|
|
github_token,
|
2019-02-12 07:48:53 -06:00
|
|
|
)
|
2021-02-20 12:23:46 -06:00
|
|
|
except HTTPError as e:
|
2019-02-12 07:48:53 -06:00
|
|
|
# network errors will simply end up not creating an issue, but that's better
|
|
|
|
# than failing the entire build job
|
2021-02-20 12:23:46 -06:00
|
|
|
print("HTTPError when creating issue for status regression: {0}\n{1!r}"
|
2019-06-21 13:47:42 -05:00
|
|
|
.format(e, e.read()))
|
2019-06-21 12:22:46 -05:00
|
|
|
except IOError as e:
|
2019-06-21 06:40:57 -05:00
|
|
|
print("I/O error when creating issue for status regression: {0}".format(e))
|
2019-02-12 07:48:53 -06:00
|
|
|
except:
|
2019-06-21 07:07:20 -05:00
|
|
|
print("Unexpected error when creating issue for status regression: {0}"
|
|
|
|
.format(sys.exc_info()[0]))
|
2019-02-12 07:48:53 -06:00
|
|
|
raise
|
2017-12-04 08:31:57 -06:00
|
|
|
|
|
|
|
if changed:
|
|
|
|
status['commit'] = current_commit
|
|
|
|
status['datetime'] = current_datetime
|
|
|
|
anything_changed = True
|
|
|
|
|
|
|
|
if not anything_changed:
|
|
|
|
return ''
|
|
|
|
|
|
|
|
f.seek(0)
|
|
|
|
f.truncate(0)
|
|
|
|
json.dump(latest, f, indent=4, separators=(',', ': '))
|
|
|
|
return message
|
|
|
|
|
|
|
|
|
2020-08-26 16:22:13 -05:00
|
|
|
# Warning: Do not try to add a function containing the body of this try block.
|
|
|
|
# There are variables declared within that are implicitly global; it is unknown
|
|
|
|
# which ones precisely but at least this is true for `github_token`.
|
|
|
|
try:
|
|
|
|
if __name__ != '__main__':
|
|
|
|
exit(0)
|
2019-09-04 03:08:54 -05:00
|
|
|
repo = os.environ.get('TOOLSTATE_VALIDATE_MAINTAINERS_REPO')
|
|
|
|
if repo:
|
|
|
|
github_token = os.environ.get('TOOLSTATE_REPO_ACCESS_TOKEN')
|
|
|
|
if github_token:
|
2021-09-15 11:25:06 -05:00
|
|
|
# FIXME: This is currently broken. Starting on 2021-09-15, GitHub
|
|
|
|
# seems to have changed it so that to list the collaborators
|
|
|
|
# requires admin permissions. I think this will probably just need
|
|
|
|
# to be removed since we are probably not going to use an admin
|
|
|
|
# token, and I don't see another way to do this.
|
|
|
|
print('maintainer validation disabled')
|
|
|
|
# validate_maintainers(repo, github_token)
|
2019-09-03 04:33:29 -05:00
|
|
|
else:
|
|
|
|
print('skipping toolstate maintainers validation since no GitHub token is present')
|
2019-09-04 03:08:54 -05:00
|
|
|
# When validating maintainers don't run the full script.
|
2019-09-03 04:33:29 -05:00
|
|
|
exit(0)
|
|
|
|
|
2017-12-04 08:31:57 -06:00
|
|
|
cur_commit = sys.argv[1]
|
|
|
|
cur_datetime = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')
|
|
|
|
cur_commit_msg = sys.argv[2]
|
|
|
|
save_message_to_path = sys.argv[3]
|
2018-02-21 08:58:06 -06:00
|
|
|
github_token = sys.argv[4]
|
2017-12-04 08:31:57 -06:00
|
|
|
|
2018-12-19 09:37:16 -06:00
|
|
|
# assume that PR authors are also owners of the repo where the branch lives
|
2018-12-20 07:29:42 -06:00
|
|
|
relevant_pr_match = re.search(
|
2019-02-17 09:19:47 -06:00
|
|
|
r'Auto merge of #([0-9]+) - ([^:]+):[^,]+, r=(\S+)',
|
2018-12-20 07:29:42 -06:00
|
|
|
cur_commit_msg,
|
|
|
|
)
|
2017-12-04 08:31:57 -06:00
|
|
|
if relevant_pr_match:
|
2018-02-21 08:25:12 -06:00
|
|
|
number = relevant_pr_match.group(1)
|
2018-12-18 06:33:02 -06:00
|
|
|
relevant_pr_user = relevant_pr_match.group(2)
|
2018-02-21 08:25:12 -06:00
|
|
|
relevant_pr_number = 'rust-lang/rust#' + number
|
|
|
|
relevant_pr_url = 'https://github.com/rust-lang/rust/pull/' + number
|
2018-12-19 10:44:46 -06:00
|
|
|
pr_reviewer = relevant_pr_match.group(3)
|
2017-12-04 08:31:57 -06:00
|
|
|
else:
|
2018-02-21 08:58:06 -06:00
|
|
|
number = '-1'
|
2019-02-17 09:19:47 -06:00
|
|
|
relevant_pr_user = 'ghost'
|
2017-12-04 08:31:57 -06:00
|
|
|
relevant_pr_number = '<unknown PR>'
|
2018-02-21 08:25:12 -06:00
|
|
|
relevant_pr_url = '<unknown>'
|
2019-02-17 09:19:47 -06:00
|
|
|
pr_reviewer = 'ghost'
|
2018-02-21 08:25:12 -06:00
|
|
|
|
|
|
|
message = update_latest(
|
|
|
|
cur_commit,
|
|
|
|
relevant_pr_number,
|
|
|
|
relevant_pr_url,
|
2018-12-18 06:33:02 -06:00
|
|
|
relevant_pr_user,
|
2018-12-19 10:44:46 -06:00
|
|
|
pr_reviewer,
|
2021-02-20 12:23:46 -06:00
|
|
|
cur_datetime,
|
|
|
|
github_token,
|
2018-02-21 08:25:12 -06:00
|
|
|
)
|
2018-02-21 08:58:06 -06:00
|
|
|
if not message:
|
2017-12-04 08:31:57 -06:00
|
|
|
print('<Nothing changed>')
|
2018-02-21 08:58:06 -06:00
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
print(message)
|
2018-12-15 09:44:46 -06:00
|
|
|
|
|
|
|
if not github_token:
|
|
|
|
print('Dry run only, not committing anything')
|
|
|
|
sys.exit(0)
|
|
|
|
|
2018-02-21 08:58:06 -06:00
|
|
|
with open(save_message_to_path, 'w') as f:
|
|
|
|
f.write(message)
|
|
|
|
|
|
|
|
# Write the toolstate comment on the PR as well.
|
2019-06-12 09:59:20 -05:00
|
|
|
issue_url = gh_url() + '/{}/comments'.format(number)
|
2018-02-21 08:58:06 -06:00
|
|
|
response = urllib2.urlopen(urllib2.Request(
|
2019-06-12 09:59:20 -05:00
|
|
|
issue_url,
|
2021-02-20 12:23:46 -06:00
|
|
|
json.dumps({'body': maybe_delink(message)}).encode(),
|
2018-02-21 08:58:06 -06:00
|
|
|
{
|
|
|
|
'Authorization': 'token ' + github_token,
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
}
|
|
|
|
))
|
|
|
|
response.read()
|
2021-02-20 12:23:46 -06:00
|
|
|
except HTTPError as e:
|
|
|
|
print("HTTPError: %s\n%r" % (e, e.read()))
|
2020-08-26 16:22:13 -05:00
|
|
|
raise
|