fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #67350 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum73528e339aa

1.40.0
1.5 KiB48 linesraw
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
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
8import sys
9import json
10
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.
14REGRESSION_OK = ["rustc-guide", "miri", "embedded-book"]
15
16if __name__ == '__main__':
17    os_name = sys.argv[1]
18    toolstate_file = sys.argv[2]
19    current_state = sys.argv[3]
20    verb = sys.argv[4] # 'regressed' or 'changed'
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, '')
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:
40            print(
41                'The state of "{}" has {} from "{}" to "{}"'
42                .format(tool, verb, state, new_state)
43            )
44            if not (verb == 'regressed' and tool in REGRESSION_OK):
45                regressed = True
46
47    if regressed:
48        sys.exit(1)