Skip to content

Commit

Permalink
Auto merge of #62759 - mark-i-m:rustc-guide-toolstate-check, r=kennytm
Browse files Browse the repository at this point in the history
Actually add rustc-guide to toolstate, don't fail builds for the guide

cc @ehuss

r? @kennytm
  • Loading branch information
bors committed Jul 28, 2019
2 parents 9a239ef + 11a3b74 commit f3ad8ef
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
12 changes: 11 additions & 1 deletion src/ci/docker/x86_64-gnu-tools/checkregression.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

## This script has two purposes: detect any tool that *regressed*, which is used
## during the week before the beta branches to reject PRs; and detect any tool
## that *changed* to see if we need to update the toolstate repo.

import sys
import json

# Regressions for these tools during the beta cutoff week do not cause failure.
# See `status_check` in `checktools.sh` for tools that have to pass on the
# beta/stable branches.
REGRESSION_OK = ["rustc-guide", "miri", "embedded-book"]

if __name__ == '__main__':
os_name = sys.argv[1]
toolstate_file = sys.argv[2]
Expand Down Expand Up @@ -32,7 +41,8 @@
'The state of "{}" has {} from "{}" to "{}"'
.format(tool, verb, state, new_state)
)
regressed = True
if not (verb == 'regressed' and tool in REGRESSION_OK):
regressed = True

if regressed:
sys.exit(1)
19 changes: 15 additions & 4 deletions src/ci/docker/x86_64-gnu-tools/checktools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ python2.7 "$X_PY" test --no-fail-fast \
src/doc/rust-by-example \
src/doc/embedded-book \
src/doc/edition-guide \
src/doc/rustc-guide \
src/tools/clippy \
src/tools/rls \
src/tools/rustfmt \
Expand All @@ -41,7 +42,7 @@ check_tool_failed() {
}

# This function checks that if a tool's submodule changed, the tool's state must improve
verify_status() {
verify_submodule_changed() {
echo "Verifying status of $1..."
if echo "$CHANGED_FILES" | grep -q "^M[[:blank:]]$2$"; then
echo "This PR updated '$2', verifying if status is 'test-pass'..."
Expand All @@ -66,7 +67,7 @@ verify_status() {
check_dispatch() {
if [ "$1" = submodule_changed ]; then
# ignore $2 (branch id)
verify_status $3 $4
verify_submodule_changed $3 $4
elif [ "$2" = beta ]; then
echo "Requiring test passing for $3..."
if check_tool_failed "$3"; then
Expand All @@ -75,7 +76,12 @@ check_dispatch() {
fi
}

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

CHECK_NOT="$(readlink -f "$(dirname $0)/checkregression.py")"
# This callback is called by `commit_toolstate_change`, see `repo.sh`.
change_toolstate() {
# only update the history
if python2.7 "$CHECK_NOT" "$OS" "$TOOLSTATE_FILE" "_data/latest.json" changed; then
echo 'Toolstate is not changed. Not updating.'
else
if [ $SIX_WEEK_CYCLE -ge 35 ]; then
# Reject any regressions during the week before beta cutoff.
python2.7 "$CHECK_NOT" "$OS" "$TOOLSTATE_FILE" "_data/latest.json" regressed
fi
sed -i "1 a\\
Expand Down
7 changes: 7 additions & 0 deletions src/ci/docker/x86_64-gnu-tools/repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ commit_toolstate_change() {
MESSAGE_FILE="$1"
shift
for RETRY_COUNT in 1 2 3 4 5; do
# Call the callback.
# - If we are in the `auto` branch (pre-landing), this is called from `checktools.sh` and
# the callback is `change_toolstate` in that file. The purpose of this is to publish the
# test results (the new commit-to-toolstate mapping) in the toolstate repo.
# - If we are in the `master` branch (post-landing), this is called by the CI pipeline
# and the callback is `src/tools/publish_toolstate.py`. The purpose is to publish
# the new "current" toolstate in the toolstate repo.
"$@"
# `git commit` failing means nothing to commit.
FAILURE=0
Expand Down
6 changes: 6 additions & 0 deletions src/tools/publish_toolstate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

import sys
import re
import os
Expand Down

0 comments on commit f3ad8ef

Please sign in to comment.