]>
Commit | Line | Data |
---|---|---|
ff7c6d11 XL |
1 | #!/bin/sh |
2 | ||
ff7c6d11 XL |
3 | set -eu |
4 | ||
5 | X_PY="$1" | |
6 | TOOLSTATE_FILE="$(realpath $2)" | |
7 | OS="$3" | |
8 | COMMIT="$(git rev-parse HEAD)" | |
9 | CHANGED_FILES="$(git diff --name-status HEAD HEAD^)" | |
b7449926 XL |
10 | SIX_WEEK_CYCLE="$(( ($(date +%s) / 86400 - 20) % 42 ))" |
11 | # ^ Number of days after the last promotion of beta. | |
12 | # Its value is 41 on the Tuesday where "Promote master to beta (T-2)" happens. | |
13 | # The Wednesday after this has value 0. | |
14 | # We track this value to prevent regressing tools in the last week of the 6-week cycle. | |
ff7c6d11 XL |
15 | |
16 | touch "$TOOLSTATE_FILE" | |
17 | ||
94b46f34 XL |
18 | # Try to test all the tools and store the build/test success in the TOOLSTATE_FILE |
19 | ||
ff7c6d11 XL |
20 | set +e |
21 | python2.7 "$X_PY" test --no-fail-fast \ | |
0531ce1d XL |
22 | src/doc/book \ |
23 | src/doc/nomicon \ | |
24 | src/doc/reference \ | |
25 | src/doc/rust-by-example \ | |
9fa01778 | 26 | src/doc/embedded-book \ |
532ac7d7 | 27 | src/doc/edition-guide \ |
8faf50e0 | 28 | src/tools/clippy \ |
ff7c6d11 | 29 | src/tools/rls \ |
94b46f34 XL |
30 | src/tools/rustfmt \ |
31 | src/tools/miri \ | |
8faf50e0 | 32 | |
ff7c6d11 XL |
33 | set -e |
34 | ||
35 | cat "$TOOLSTATE_FILE" | |
0531ce1d | 36 | echo |
ff7c6d11 | 37 | |
dc9dc135 XL |
38 | # This function checks if a particular tool is *not* in status "test-pass". |
39 | check_tool_failed() { | |
40 | grep -vq '"'"$1"'":"test-pass"' "$TOOLSTATE_FILE" | |
41 | } | |
42 | ||
94b46f34 | 43 | # This function checks that if a tool's submodule changed, the tool's state must improve |
0531ce1d XL |
44 | verify_status() { |
45 | echo "Verifying status of $1..." | |
46 | if echo "$CHANGED_FILES" | grep -q "^M[[:blank:]]$2$"; then | |
47 | echo "This PR updated '$2', verifying if status is 'test-pass'..." | |
dc9dc135 | 48 | if check_tool_failed "$1"; then |
ff7c6d11 | 49 | echo |
0531ce1d | 50 | echo "⚠️ We detected that this PR updated '$1', but its tests failed." |
ff7c6d11 | 51 | echo |
0531ce1d | 52 | echo "If you do intend to update '$1', please check the error messages above and" |
ff7c6d11 XL |
53 | echo "commit another update." |
54 | echo | |
0531ce1d XL |
55 | echo "If you do NOT intend to update '$1', please ensure you did not accidentally" |
56 | echo "change the submodule at '$2'. You may ask your reviewer for the" | |
ff7c6d11 XL |
57 | echo "proper steps." |
58 | exit 3 | |
59 | fi | |
60 | fi | |
0531ce1d XL |
61 | } |
62 | ||
dc9dc135 XL |
63 | # deduplicates the submodule check and the assertion that on beta some tools MUST be passing. |
64 | # $1 should be "submodule_changed" to only check tools that got changed by this PR, | |
65 | # or "beta_required" to check all tools that have $2 set to "beta". | |
94b46f34 XL |
66 | check_dispatch() { |
67 | if [ "$1" = submodule_changed ]; then | |
68 | # ignore $2 (branch id) | |
69 | verify_status $3 $4 | |
70 | elif [ "$2" = beta ]; then | |
71 | echo "Requiring test passing for $3..." | |
dc9dc135 | 72 | if check_tool_failed "$3"; then |
94b46f34 XL |
73 | exit 4 |
74 | fi | |
75 | fi | |
76 | } | |
77 | ||
78 | # list all tools here | |
79 | status_check() { | |
80 | check_dispatch $1 beta book src/doc/book | |
81 | check_dispatch $1 beta nomicon src/doc/nomicon | |
82 | check_dispatch $1 beta reference src/doc/reference | |
83 | check_dispatch $1 beta rust-by-example src/doc/rust-by-example | |
532ac7d7 | 84 | check_dispatch $1 beta edition-guide src/doc/edition-guide |
8faf50e0 XL |
85 | check_dispatch $1 beta rls src/tools/rls |
86 | check_dispatch $1 beta rustfmt src/tools/rustfmt | |
87 | check_dispatch $1 beta clippy-driver src/tools/clippy | |
94b46f34 | 88 | # these tools are not required for beta to successfully branch |
8faf50e0 | 89 | check_dispatch $1 nightly miri src/tools/miri |
532ac7d7 | 90 | check_dispatch $1 nightly embedded-book src/doc/embedded-book |
94b46f34 XL |
91 | } |
92 | ||
0531ce1d XL |
93 | # If this PR is intended to update one of these tools, do not let the build pass |
94 | # when they do not test-pass. | |
95 | ||
94b46f34 | 96 | status_check "submodule_changed" |
ff7c6d11 | 97 | |
94b46f34 XL |
98 | CHECK_NOT="$(readlink -f "$(dirname $0)/checkregression.py")" |
99 | change_toolstate() { | |
100 | # only update the history | |
101 | if python2.7 "$CHECK_NOT" "$OS" "$TOOLSTATE_FILE" "_data/latest.json" changed; then | |
102 | echo 'Toolstate is not changed. Not updating.' | |
103 | else | |
b7449926 | 104 | if [ $SIX_WEEK_CYCLE -ge 35 ]; then |
94b46f34 XL |
105 | python2.7 "$CHECK_NOT" "$OS" "$TOOLSTATE_FILE" "_data/latest.json" regressed |
106 | fi | |
ff7c6d11 XL |
107 | sed -i "1 a\\ |
108 | $COMMIT\t$(cat "$TOOLSTATE_FILE") | |
109 | " "history/$OS.tsv" | |
0531ce1d | 110 | fi |
94b46f34 XL |
111 | } |
112 | ||
8faf50e0 XL |
113 | if [ "$RUST_RELEASE_CHANNEL" = nightly ]; then |
114 | if [ -n "${TOOLSTATE_REPO_ACCESS_TOKEN+is_set}" ]; then | |
115 | . "$(dirname $0)/repo.sh" | |
116 | MESSAGE_FILE=$(mktemp -t msg.XXXXXX) | |
117 | echo "($OS CI update)" > "$MESSAGE_FILE" | |
118 | commit_toolstate_change "$MESSAGE_FILE" change_toolstate | |
119 | rm -f "$MESSAGE_FILE" | |
120 | fi | |
ff7c6d11 XL |
121 | exit 0 |
122 | fi | |
123 | ||
94b46f34 XL |
124 | # abort compilation if an important tool doesn't build |
125 | # (this code is reachable if not on the nightly channel) | |
126 | status_check "beta_required" |