]>
Commit | Line | Data |
---|---|---|
0531ce1d XL |
1 | #!/usr/bin/env python |
2 | # -*- coding: utf-8 -*- | |
3 | ||
416331ca XL |
4 | ## This script has two purposes: detect any tool that *regressed*, which is used |
5 | ## during the week before the beta branches to reject PRs; and detect any tool | |
6 | ## that *changed* to see if we need to update the toolstate repo. | |
7 | ||
0531ce1d XL |
8 | import sys |
9 | import json | |
10 | ||
416331ca XL |
11 | # Regressions for these tools during the beta cutoff week do not cause failure. |
12 | # See `status_check` in `checktools.sh` for tools that have to pass on the | |
13 | # beta/stable branches. | |
14 | REGRESSION_OK = ["rustc-guide", "miri", "embedded-book"] | |
15 | ||
0531ce1d XL |
16 | if __name__ == '__main__': |
17 | os_name = sys.argv[1] | |
18 | toolstate_file = sys.argv[2] | |
19 | current_state = sys.argv[3] | |
94b46f34 | 20 | verb = sys.argv[4] # 'regressed' or 'changed' |
0531ce1d XL |
21 | |
22 | with open(toolstate_file, 'r') as f: | |
23 | toolstate = json.load(f) | |
24 | with open(current_state, 'r') as f: | |
25 | current = json.load(f) | |
26 | ||
27 | regressed = False | |
28 | for cur in current: | |
29 | tool = cur['tool'] | |
30 | state = cur[os_name] | |
31 | new_state = toolstate.get(tool, '') | |
94b46f34 XL |
32 | if verb == 'regressed': |
33 | updated = new_state < state | |
34 | elif verb == 'changed': | |
35 | updated = new_state != state | |
36 | else: | |
37 | print('Unknown verb {}'.format(updated)) | |
38 | sys.exit(2) | |
39 | if updated: | |
0531ce1d | 40 | print( |
94b46f34 XL |
41 | 'The state of "{}" has {} from "{}" to "{}"' |
42 | .format(tool, verb, state, new_state) | |
0531ce1d | 43 | ) |
416331ca XL |
44 | if not (verb == 'regressed' and tool in REGRESSION_OK): |
45 | regressed = True | |
0531ce1d XL |
46 | |
47 | if regressed: | |
48 | sys.exit(1) |