2 # -*- coding: utf-8 -*-
4 # Copyright 2017 The Rust Project Developers. See the COPYRIGHT
5 # file at the top-level directory of this distribution and at
6 # http://rust-lang.org/COPYRIGHT.
8 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
9 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
10 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
11 # option. This file may not be copied, modified, or distributed
12 # except according to those terms.
22 # List of people to ping when the status of a tool changed.
24 'miri': '@oli-obk @RalfJung @eddyb',
25 'clippy-driver': '@Manishearth @llogiq @mcarton @oli-obk',
31 def read_current_status(current_commit, path):
32 '''Reads build status of `current_commit` from content of `history/*.tsv`
34 with open(path, 'rU') as f:
36 (commit, status) = line.split('\t', 1)
37 if commit == current_commit:
38 return json.loads(status)
48 '''Updates `_data/latest.json` to match build result of the given commit.
50 with open('_data/latest.json', 'rb+') as f:
51 latest = json.load(f, object_pairs_hook=collections.OrderedDict)
54 os: read_current_status(current_commit, 'history/' + os + '.tsv')
55 for os in ['windows', 'linux']
58 slug = 'rust-lang/rust'
59 message = textwrap.dedent('''\
60 📣 Toolstate changed by {}!
62 Tested on commit {}@{}.
63 Direct link to PR: <{}>
65 ''').format(relevant_pr_number, slug, current_commit, relevant_pr_url)
66 anything_changed = False
71 for os, s in current_status.items():
73 new = s.get(tool, old)
77 message += '🎉 {} on {}: {} → {}.\n' \
78 .format(tool, os, old, new)
81 message += '💔 {} on {}: {} → {} (cc {}).\n' \
82 .format(tool, os, old, new, MAINTAINERS[tool])
85 status['commit'] = current_commit
86 status['datetime'] = current_datetime
87 anything_changed = True
89 if not anything_changed:
94 json.dump(latest, f, indent=4, separators=(',', ': '))
98 if __name__ == '__main__':
99 cur_commit = sys.argv[1]
100 cur_datetime = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')
101 cur_commit_msg = sys.argv[2]
102 save_message_to_path = sys.argv[3]
104 relevant_pr_match = re.search('#([0-9]+)', cur_commit_msg)
105 if relevant_pr_match:
106 number = relevant_pr_match.group(1)
107 relevant_pr_number = 'rust-lang/rust#' + number
108 relevant_pr_url = 'https://github.com/rust-lang/rust/pull/' + number
110 relevant_pr_number = '<unknown PR>'
111 relevant_pr_url = '<unknown>'
113 message = update_latest(
121 with open(save_message_to_path, 'w') as f:
124 print('<Nothing changed>')