6 TOOLSTATE_FILE="$(realpath $2)"
8 COMMIT="$(git rev-parse HEAD)"
9 CHANGED_FILES="$(git diff --name-status HEAD HEAD^)"
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.
16 touch "$TOOLSTATE_FILE"
18 # Try to test all the tools and store the build/test success in the TOOLSTATE_FILE
21 python2.7 "$X_PY" test --no-fail-fast \
25 src/doc/rust-by-example \
26 src/doc/embedded-book \
27 src/doc/edition-guide \
38 # This function checks if a particular tool is *not* in status "test-pass".
40 grep -vq '"'"$1"'":"test-pass"' "$TOOLSTATE_FILE"
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 check_tool_failed "$1"; 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.
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".
67 if [ "$1" = submodule_changed ]; then
68 # ignore $2 (branch id)
70 elif [ "$2" = beta ]; then
71 echo "Requiring test passing for $3..."
72 if check_tool_failed "$3"; then
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
84 check_dispatch $1 beta edition-guide src/doc/edition-guide
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
88 # these tools are not required for beta to successfully branch
89 check_dispatch $1 nightly miri src/tools/miri
90 check_dispatch $1 nightly embedded-book src/doc/embedded-book
91 check_dispatch $1 nightly rustc-guide src/doc/rustc-guide
94 # If this PR is intended to update one of these tools, do not let the build pass
95 # when they do not test-pass.
97 status_check "submodule_changed"
99 CHECK_NOT="$(readlink -f "$(dirname $0)/checkregression.py")"
101 # only update the history
102 if python2.7 "$CHECK_NOT" "$OS" "$TOOLSTATE_FILE" "_data/latest.json" changed; then
103 echo 'Toolstate is not changed. Not updating.'
105 if [ $SIX_WEEK_CYCLE -ge 35 ]; then
106 python2.7 "$CHECK_NOT" "$OS" "$TOOLSTATE_FILE" "_data/latest.json" regressed
109 $COMMIT\t$(cat "$TOOLSTATE_FILE")
114 if [ "$RUST_RELEASE_CHANNEL" = nightly ]; then
115 if [ -n "${TOOLSTATE_PUBLISH+is_set}" ]; then
116 . "$(dirname $0)/repo.sh"
117 MESSAGE_FILE=$(mktemp -t msg.XXXXXX)
118 echo "($OS CI update)" > "$MESSAGE_FILE"
119 commit_toolstate_change "$MESSAGE_FILE" change_toolstate
120 rm -f "$MESSAGE_FILE"
125 # abort compilation if an important tool doesn't build
126 # (this code is reachable if not on the nightly channel)
127 status_check "beta_required"