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.
21 # List of people to ping when the status of a tool changed.
23 'miri': '@oli-obk @RalfJung @eddyb',
24 'clippy-driver': '@Manishearth @llogiq @mcarton @oli-obk',
30 def read_current_status(current_commit, path):
31 '''Reads build status of `current_commit` from content of `history/*.tsv`
33 with open(path, 'rU') as f:
35 (commit, status) = line.split('\t', 1)
36 if commit == current_commit:
37 return json.loads(status)
41 def update_latest(current_commit, relevant_pr_number, current_datetime):
42 '''Updates `_data/latest.json` to match build result of the given commit.
44 with open('_data/latest.json', 'rb+') as f:
45 latest = json.load(f, object_pairs_hook=collections.OrderedDict)
48 os: read_current_status(current_commit, 'history/' + os + '.tsv')
49 for os in ['windows', 'linux']
52 slug = 'rust-lang/rust'
53 message = '📣 Toolstate changed by {}!\n\nTested on commit {}@{}.\n\n' \
54 .format(relevant_pr_number, slug, current_commit)
55 anything_changed = False
60 for os, s in current_status.items():
62 new = s.get(tool, old)
66 message += '🎉 {} on {}: {} → {}.\n' \
67 .format(tool, os, old, new)
70 message += '💔 {} on {}: {} → {} (cc {}).\n' \
71 .format(tool, os, old, new, MAINTAINERS[tool])
74 status['commit'] = current_commit
75 status['datetime'] = current_datetime
76 anything_changed = True
78 if not anything_changed:
83 json.dump(latest, f, indent=4, separators=(',', ': '))
87 if __name__ == '__main__':
88 cur_commit = sys.argv[1]
89 cur_datetime = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')
90 cur_commit_msg = sys.argv[2]
91 save_message_to_path = sys.argv[3]
93 relevant_pr_match = re.search('#[0-9]+', cur_commit_msg)
95 relevant_pr_number = 'rust-lang/rust' + relevant_pr_match.group(0)
97 relevant_pr_number = '<unknown PR>'
99 message = update_latest(cur_commit, relevant_pr_number, cur_datetime)
102 with open(save_message_to_path, 'w') as f:
105 print('<Nothing changed>')