]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/x86_64-gnu-tools/checktools.sh
Auto merge of #47956 - retep998:is-nibbles, r=BurntSushi
[rust.git] / src / ci / docker / x86_64-gnu-tools / checktools.sh
1 #!/bin/sh
2
3 # Copyright 2017 The Rust Project Developers. See the COPYRIGHT
4 # file at the top-level directory of this distribution and at
5 # http://rust-lang.org/COPYRIGHT.
6 #
7 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
9 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
10 # option. This file may not be copied, modified, or distributed
11 # except according to those terms.
12
13 set -eu
14
15 X_PY="$1"
16 TOOLSTATE_FILE="$(realpath $2)"
17 OS="$3"
18 COMMIT="$(git rev-parse HEAD)"
19 CHANGED_FILES="$(git diff --name-status HEAD HEAD^)"
20
21 touch "$TOOLSTATE_FILE"
22
23 set +e
24 python2.7 "$X_PY" test --no-fail-fast \
25     src/tools/rls \
26     src/tools/rustfmt \
27     src/tools/miri \
28     src/tools/clippy
29 set -e
30
31 cat "$TOOLSTATE_FILE"
32
33 # If this PR is intended to update one of these tools, do not let the build pass
34 # when they do not test-pass.
35 for TOOL in rls rustfmt clippy; do
36     echo "Verifying status of $TOOL..."
37     if echo "$CHANGED_FILES" | grep -q "^M[[:blank:]]src/tools/$TOOL$"; then
38         echo "This PR updated 'src/tools/$TOOL', verifying if status is 'test-pass'..."
39         if grep -vq '"'"$TOOL"'[^"]*":"test-pass"' "$TOOLSTATE_FILE"; then
40             echo
41             echo "⚠️ We detected that this PR updated '$TOOL', but its tests failed."
42             echo
43             echo "If you do intend to update '$TOOL', please check the error messages above and"
44             echo "commit another update."
45             echo
46             echo "If you do NOT intend to update '$TOOL', please ensure you did not accidentally"
47             echo "change the submodule at 'src/tools/$TOOL'. You may ask your reviewer for the"
48             echo "proper steps."
49             exit 3
50         fi
51     fi
52 done
53
54 if [ "$RUST_RELEASE_CHANNEL" = nightly -a -n "${TOOLSTATE_REPO_ACCESS_TOKEN+is_set}" ]; then
55     . "$(dirname $0)/repo.sh"
56     MESSAGE_FILE=$(mktemp -t msg.XXXXXX)
57     echo "($OS CI update)" > "$MESSAGE_FILE"
58     commit_toolstate_change "$MESSAGE_FILE" \
59         sed -i "1 a\\
60 $COMMIT\t$(cat "$TOOLSTATE_FILE")
61 " "history/$OS.tsv"
62     rm -f "$MESSAGE_FILE"
63     exit 0
64 fi
65
66 if grep -q fail "$TOOLSTATE_FILE"; then
67     exit 4
68 fi