Skip to content

Commit 2fe58b9

Browse files
fix maintainer validation message
fix remove token check for maintainers fix: rm validate_maintainers function
1 parent 9714e13 commit 2fe58b9

File tree

2 files changed

+0
-67
lines changed

2 files changed

+0
-67
lines changed

src/ci/docker/host-x86_64/mingw-check/validate-toolstate.sh

-6
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,5 @@ git clone --depth=1 https://github.com/rust-lang-nursery/rust-toolstate.git
99
cd rust-toolstate
1010
python3 "../../src/tools/publish_toolstate.py" "$(git rev-parse HEAD)" \
1111
"$(git log --format=%s -n1 HEAD)" "" ""
12-
# Only check maintainers if this build is supposed to publish toolstate.
13-
# Builds that are not supposed to publish don't have the access token.
14-
if [ -n "${TOOLSTATE_PUBLISH+is_set}" ]; then
15-
TOOLSTATE_VALIDATE_MAINTAINERS_REPO=rust-lang/rust python3 \
16-
"../../src/tools/publish_toolstate.py"
17-
fi
1812
cd ..
1913
rm -rf rust-toolstate

src/tools/publish_toolstate.py

-61
Original file line numberDiff line numberDiff line change
@@ -77,52 +77,6 @@ def load_json_from_response(resp):
7777
print("Refusing to decode " + str(type(content)) + " to str")
7878
return json.loads(content_str)
7979

80-
def validate_maintainers(repo, github_token):
81-
# type: (str, str) -> None
82-
'''Ensure all maintainers are assignable on a GitHub repo'''
83-
next_link_re = re.compile(r'<([^>]+)>; rel="next"')
84-
85-
# Load the list of assignable people in the GitHub repo
86-
assignable = [] # type: typing.List[str]
87-
url = 'https://api.github.com/repos/' \
88-
+ '%s/collaborators?per_page=100' % repo # type: typing.Optional[str]
89-
while url is not None:
90-
response = urllib2.urlopen(urllib2.Request(url, headers={
91-
'Authorization': 'token ' + github_token,
92-
# Properly load nested teams.
93-
'Accept': 'application/vnd.github.hellcat-preview+json',
94-
}))
95-
assignable.extend(user['login'] for user in load_json_from_response(response))
96-
# Load the next page if available
97-
url = None
98-
link_header = response.headers.get('Link')
99-
if link_header:
100-
matches = next_link_re.match(link_header)
101-
if matches is not None:
102-
url = matches.group(1)
103-
104-
errors = False
105-
for tool, maintainers in MAINTAINERS.items():
106-
for maintainer in maintainers:
107-
if maintainer not in assignable:
108-
errors = True
109-
print(
110-
"error: %s maintainer @%s is not assignable in the %s repo"
111-
% (tool, maintainer, repo),
112-
)
113-
114-
if errors:
115-
print()
116-
print(" To be assignable, a person needs to be explicitly listed as a")
117-
print(" collaborator in the repository settings. The simple way to")
118-
print(" fix this is to ask someone with 'admin' privileges on the repo")
119-
print(" to add the person or whole team as a collaborator with 'read'")
120-
print(" privileges. Those privileges don't grant any extra permissions")
121-
print(" so it's safe to apply them.")
122-
print()
123-
print("The build will fail due to this.")
124-
exit(1)
125-
12680

12781
def read_current_status(current_commit, path):
12882
# type: (str, str) -> typing.Mapping[str, typing.Any]
@@ -295,21 +249,6 @@ def update_latest(
295249
try:
296250
if __name__ != '__main__':
297251
exit(0)
298-
repo = os.environ.get('TOOLSTATE_VALIDATE_MAINTAINERS_REPO')
299-
if repo:
300-
github_token = os.environ.get('TOOLSTATE_REPO_ACCESS_TOKEN')
301-
if github_token:
302-
# FIXME: This is currently broken. Starting on 2021-09-15, GitHub
303-
# seems to have changed it so that to list the collaborators
304-
# requires admin permissions. I think this will probably just need
305-
# to be removed since we are probably not going to use an admin
306-
# token, and I don't see another way to do this.
307-
print('maintainer validation disabled')
308-
# validate_maintainers(repo, github_token)
309-
else:
310-
print('skipping toolstate maintainers validation since no GitHub token is present')
311-
# When validating maintainers don't run the full script.
312-
exit(0)
313252

314253
cur_commit = sys.argv[1]
315254
cur_datetime = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')

0 commit comments

Comments
 (0)