Skip to content

Commit 56c83c3

Browse files
authored
Rollup merge of rust-lang#62759 - mark-i-m:rustc-guide-toolstate-check, r=kennytm
Actually add rustc-guide to toolstate, don't fail builds for the guide cc @ehuss r? @kennytm
2 parents ef2d8c9 + 11a3b74 commit 56c83c3

File tree

4 files changed

+39
-5
lines changed

4 files changed

+39
-5
lines changed

src/ci/docker/x86_64-gnu-tools/checkregression.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

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+
48
import sys
59
import json
610

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.
14+
REGRESSION_OK = ["rustc-guide", "miri", "embedded-book"]
15+
716
if __name__ == '__main__':
817
os_name = sys.argv[1]
918
toolstate_file = sys.argv[2]
@@ -32,7 +41,8 @@
3241
'The state of "{}" has {} from "{}" to "{}"'
3342
.format(tool, verb, state, new_state)
3443
)
35-
regressed = True
44+
if not (verb == 'regressed' and tool in REGRESSION_OK):
45+
regressed = True
3646

3747
if regressed:
3848
sys.exit(1)

src/ci/docker/x86_64-gnu-tools/checktools.sh

+15-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ python2.7 "$X_PY" test --no-fail-fast \
2525
src/doc/rust-by-example \
2626
src/doc/embedded-book \
2727
src/doc/edition-guide \
28+
src/doc/rustc-guide \
2829
src/tools/clippy \
2930
src/tools/rls \
3031
src/tools/rustfmt \
@@ -41,7 +42,7 @@ check_tool_failed() {
4142
}
4243

4344
# This function checks that if a tool's submodule changed, the tool's state must improve
44-
verify_status() {
45+
verify_submodule_changed() {
4546
echo "Verifying status of $1..."
4647
if echo "$CHANGED_FILES" | grep -q "^M[[:blank:]]$2$"; then
4748
echo "This PR updated '$2', verifying if status is 'test-pass'..."
@@ -66,7 +67,7 @@ verify_status() {
6667
check_dispatch() {
6768
if [ "$1" = submodule_changed ]; then
6869
# ignore $2 (branch id)
69-
verify_status $3 $4
70+
verify_submodule_changed $3 $4
7071
elif [ "$2" = beta ]; then
7172
echo "Requiring test passing for $3..."
7273
if check_tool_failed "$3"; then
@@ -75,7 +76,12 @@ check_dispatch() {
7576
fi
7677
}
7778

78-
# list all tools here
79+
# List all tools here.
80+
# This function gets called with "submodule_changed" for each PR that changed a submodule,
81+
# and with "beta_required" for each PR that lands on beta/stable.
82+
# The purpose of this function is to *reject* PRs if a tool is not "test-pass" and
83+
# (a) the tool's submodule has been updated, or (b) we landed on beta/stable and the
84+
# tool has to "test-pass" on that branch.
7985
status_check() {
8086
check_dispatch $1 beta book src/doc/book
8187
check_dispatch $1 beta nomicon src/doc/nomicon
@@ -85,7 +91,10 @@ status_check() {
8591
check_dispatch $1 beta rls src/tools/rls
8692
check_dispatch $1 beta rustfmt src/tools/rustfmt
8793
check_dispatch $1 beta clippy-driver src/tools/clippy
88-
# these tools are not required for beta to successfully branch
94+
# These tools are not required on the beta/stable branches, but they *do* cause
95+
# PRs to fail if a submodule update does not fix them.
96+
# They will still cause failure during the beta cutoff week, unless `checkregression.py`
97+
# exempts them from that.
8998
check_dispatch $1 nightly miri src/tools/miri
9099
check_dispatch $1 nightly embedded-book src/doc/embedded-book
91100
check_dispatch $1 nightly rustc-guide src/doc/rustc-guide
@@ -97,12 +106,14 @@ status_check() {
97106
status_check "submodule_changed"
98107

99108
CHECK_NOT="$(readlink -f "$(dirname $0)/checkregression.py")"
109+
# This callback is called by `commit_toolstate_change`, see `repo.sh`.
100110
change_toolstate() {
101111
# only update the history
102112
if python2.7 "$CHECK_NOT" "$OS" "$TOOLSTATE_FILE" "_data/latest.json" changed; then
103113
echo 'Toolstate is not changed. Not updating.'
104114
else
105115
if [ $SIX_WEEK_CYCLE -ge 35 ]; then
116+
# Reject any regressions during the week before beta cutoff.
106117
python2.7 "$CHECK_NOT" "$OS" "$TOOLSTATE_FILE" "_data/latest.json" regressed
107118
fi
108119
sed -i "1 a\\

src/ci/docker/x86_64-gnu-tools/repo.sh

+7
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ commit_toolstate_change() {
4242
MESSAGE_FILE="$1"
4343
shift
4444
for RETRY_COUNT in 1 2 3 4 5; do
45+
# Call the callback.
46+
# - If we are in the `auto` branch (pre-landing), this is called from `checktools.sh` and
47+
# the callback is `change_toolstate` in that file. The purpose of this is to publish the
48+
# test results (the new commit-to-toolstate mapping) in the toolstate repo.
49+
# - If we are in the `master` branch (post-landing), this is called by the CI pipeline
50+
# and the callback is `src/tools/publish_toolstate.py`. The purpose is to publish
51+
# the new "current" toolstate in the toolstate repo.
4552
"$@"
4653
# `git commit` failing means nothing to commit.
4754
FAILURE=0

src/tools/publish_toolstate.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4+
## This script publishes the new "current" toolstate in the toolstate repo (not to be
5+
## confused with publishing the test results, which happens in
6+
## `src/ci/docker/x86_64-gnu-tools/checktools.sh`).
7+
## It is set as callback for `src/ci/docker/x86_64-gnu-tools/repo.sh` by the CI scripts
8+
## when a new commit lands on `master` (i.e., after it passed all checks on `auto`).
9+
410
import sys
511
import re
612
import os

0 commit comments

Comments
 (0)