Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check to ensure error code explanations are not removed anymore even if not emitted #86623

Merged
merged 2 commits into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ci/docker/host-x86_64/mingw-check/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
COPY host-x86_64/mingw-check/validate-error-codes.sh /scripts/

ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
ENV SCRIPT python3 ../x.py --stage 2 test src/tools/expand-yaml-anchors && \
Expand All @@ -37,6 +38,7 @@ ENV SCRIPT python3 ../x.py --stage 2 test src/tools/expand-yaml-anchors && \
python3 ../x.py test --stage 2 src/tools/tidy && \
python3 ../x.py doc --stage 0 library/test && \
/scripts/validate-toolstate.sh && \
/scripts/validate-error-codes.sh && \
# Runs checks to ensure that there are no ES5 issues in our JS code.
es-check es5 ../src/librustdoc/html/static/*.js && \
eslint ../src/librustdoc/html/static/*.js
20 changes: 20 additions & 0 deletions src/ci/docker/host-x86_64/mingw-check/validate-error-codes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# Checks that no error code explanation is removed.

set -eo pipefail

if [[ -z "$BASE_COMMIT" ]]; then
echo "not checking error code explanations removal"
exit 0
fi

echo "Check if an error code explanation was removed..."

if (git diff "$BASE_COMMIT" --name-status | grep '^D' \
| grep --quiet "compiler/rustc_error_codes/src/error_codes/"); then
echo "Error code explanations should never be removed!"
echo "Take a look at E0001 to see how to handle it."
exit 1
fi

echo "No error code explanation was removed!"
9 changes: 9 additions & 0 deletions src/ci/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ else
command="/checkout/src/ci/run.sh"
fi

if [ "$CI" != "" ]; then
# Get some needed information for $BASE_COMMIT
git fetch "https://github.com/$GITHUB_REPOSITORY" "$GITHUB_BASE_REF"
BASE_COMMIT="$(git merge-base FETCH_HEAD HEAD)"
else
BASE_COMMIT=""
fi

docker \
run \
--workdir /checkout/obj \
Expand All @@ -237,6 +245,7 @@ docker \
--env TOOLSTATE_PUBLISH \
--env RUST_CI_OVERRIDE_RELEASE_CHANNEL \
--env CI_JOB_NAME="${CI_JOB_NAME-$IMAGE}" \
--env BASE_COMMIT="$BASE_COMMIT" \
--init \
--rm \
rust-ci \
Expand Down