summaryrefslogtreecommitdiffstats
path: root/src/doc/rustc-dev-guide/ci
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
commit631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch)
treea1b87c8f8cad01cf18f7c5f57a08f102771ed303 /src/doc/rustc-dev-guide/ci
parentAdding debian version 1.69.0+dfsg1-1. (diff)
downloadrustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz
rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/doc/rustc-dev-guide/ci')
-rwxr-xr-xsrc/doc/rustc-dev-guide/ci/lengthcheck.sh (renamed from src/doc/rustc-dev-guide/ci/check_line_lengths.sh)8
-rwxr-xr-xsrc/doc/rustc-dev-guide/ci/linkcheck.sh16
2 files changed, 17 insertions, 7 deletions
diff --git a/src/doc/rustc-dev-guide/ci/check_line_lengths.sh b/src/doc/rustc-dev-guide/ci/lengthcheck.sh
index 31cda5c65..76d677be7 100755
--- a/src/doc/rustc-dev-guide/ci/check_line_lengths.sh
+++ b/src/doc/rustc-dev-guide/ci/lengthcheck.sh
@@ -1,5 +1,7 @@
#!/usr/bin/env bash
+# Check files for lines that are too long.
+
if [ "$1" == "--help" ]; then
echo 'Usage:' "[MAX_LINE_LENGTH=n] $0 [file ...]"
exit 1
@@ -10,8 +12,7 @@ if [ "$MAX_LINE_LENGTH" == "" ]; then
fi
if [ "$1" == "" ]; then
- shopt -s globstar
- files=( src/**/*.md )
+ files=( src/*.md src/*/*.md src/*/*/*.md )
else
files=( "$@" )
fi
@@ -22,7 +23,6 @@ echo "Offending files and lines:"
(( bad_lines = 0 ))
(( inside_block = 0 ))
for file in "${files[@]}"; do
- echo "$file"
(( line_no = 0 ))
while IFS="" read -r line || [[ -n "$line" ]] ; do
(( line_no++ ))
@@ -34,7 +34,7 @@ for file in "${files[@]}"; do
&& ! [[ "$line" =~ " | "|"-|-"|"://"|"]:"|\[\^[^\ ]+\]: ]] \
&& (( "${#line}" > $MAX_LINE_LENGTH )) ; then
(( bad_lines++ ))
- echo -e "\t$line_no : $line"
+ echo -e "\t$file:$line_no : $line"
fi
done < "$file"
done
diff --git a/src/doc/rustc-dev-guide/ci/linkcheck.sh b/src/doc/rustc-dev-guide/ci/linkcheck.sh
index 5d49d1337..133e22239 100755
--- a/src/doc/rustc-dev-guide/ci/linkcheck.sh
+++ b/src/doc/rustc-dev-guide/ci/linkcheck.sh
@@ -3,12 +3,16 @@
set -e
set -o pipefail
+set_github_token() {
+ jq '.config.output.linkcheck."http-headers"."github\\.com" = ["Authorization: Bearer $GITHUB_TOKEN"]'
+}
+
# https://docs.github.com/en/actions/reference/environment-variables
if [ "$GITHUB_EVENT_NAME" = "schedule" ] ; then # running in scheduled job
FLAGS=""
+ USE_TOKEN=1
echo "Doing full link check."
- set -x
elif [ "$GITHUB_EVENT_NAME" = "pull_request" ] ; then # running in PR CI build
if [ -z "$BASE_SHA" ]; then
echo "error: unexpected state: BASE_SHA must be non-empty in CI"
@@ -17,9 +21,9 @@ elif [ "$GITHUB_EVENT_NAME" = "pull_request" ] ; then # running in PR CI build
CHANGED_FILES=$(git diff --name-only $BASE_SHA... | tr '\n' ' ')
FLAGS="--no-cache -f $CHANGED_FILES"
+ USE_TOKEN=1
echo "Checking files changed since $BASE_SHA: $CHANGED_FILES"
- set -x
else # running locally
COMMIT_RANGE=master...
CHANGED_FILES=$(git diff --name-only $COMMIT_RANGE | tr '\n' ' ')
@@ -28,4 +32,10 @@ else # running locally
echo "Checking files changed in $COMMIT_RANGE: $CHANGED_FILES"
fi
-exec mdbook-linkcheck $FLAGS
+echo "exec mdbook-linkcheck $FLAGS"
+if [ "$USE_TOKEN" = 1 ]; then
+ config=$(set_github_token)
+ exec mdbook-linkcheck $FLAGS <<<"$config"
+else
+ exec mdbook-linkcheck $FLAGS
+fi