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.
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.
16 TOOLSTATE_FILE="$(realpath $2)"
18 COMMIT="$(git rev-parse HEAD)"
19 CHANGED_FILES="$(git diff --name-status HEAD HEAD^)"
20 SIX_WEEK_CYCLE="$(( ($(date +%s) / 604800 - 3) % 6 ))"
21 # ^ 1970 Jan 1st is a Thursday, and our release dates are also on Thursdays,
22 # thus we could divide by 604800 (7 days in seconds) directly.
24 touch "$TOOLSTATE_FILE"
26 # Try to test all the tools and store the build/test success in the TOOLSTATE_FILE
29 python2.7 "$X_PY" test --no-fail-fast \
33 src/doc/rust-by-example \
43 # This function checks that if a tool's submodule changed, the tool's state must improve
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'..."
48 if grep -vq '"'"$1"'":"test-pass"' "$TOOLSTATE_FILE"; then
50 echo "⚠️ We detected that this PR updated '$1', but its tests failed."
52 echo "If you do intend to update '$1', please check the error messages above and"
53 echo "commit another update."
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"
63 # deduplicates the submodule check and the assertion that on beta some tools MUST be passing
65 if [ "$1" = submodule_changed ]; then
66 # ignore $2 (branch id)
68 elif [ "$2" = beta ]; then
69 echo "Requiring test passing for $3..."
70 if grep -q '"'"$3"'":"\(test\|build\)-fail"' "$TOOLSTATE_FILE"; then
78 check_dispatch $1 beta book src/doc/book
79 check_dispatch $1 beta nomicon src/doc/nomicon
80 check_dispatch $1 beta reference src/doc/reference
81 check_dispatch $1 beta rust-by-example src/doc/rust-by-example
82 check_dispatch $1 beta rls src/tool/rls
83 check_dispatch $1 beta rustfmt src/tool/rustfmt
84 # these tools are not required for beta to successfully branch
85 check_dispatch $1 nightly clippy-driver src/tool/clippy
86 check_dispatch $1 nightly miri src/tool/miri
89 # If this PR is intended to update one of these tools, do not let the build pass
90 # when they do not test-pass.
92 status_check "submodule_changed"
94 CHECK_NOT="$(readlink -f "$(dirname $0)/checkregression.py")"
96 # only update the history
97 if python2.7 "$CHECK_NOT" "$OS" "$TOOLSTATE_FILE" "_data/latest.json" changed; then
98 echo 'Toolstate is not changed. Not updating.'
100 if [ $SIX_WEEK_CYCLE -eq 5 ]; then
101 python2.7 "$CHECK_NOT" "$OS" "$TOOLSTATE_FILE" "_data/latest.json" regressed
104 $COMMIT\t$(cat "$TOOLSTATE_FILE")
109 if [ "$RUST_RELEASE_CHANNEL" = nightly -a -n "${TOOLSTATE_REPO_ACCESS_TOKEN+is_set}" ]; then
110 . "$(dirname $0)/repo.sh"
111 MESSAGE_FILE=$(mktemp -t msg.XXXXXX)
112 echo "($OS CI update)" > "$MESSAGE_FILE"
113 commit_toolstate_change "$MESSAGE_FILE" change_toolstate
114 rm -f "$MESSAGE_FILE"
118 # abort compilation if an important tool doesn't build
119 # (this code is reachable if not on the nightly channel)
120 status_check "beta_required"