about summary refs log tree commit diff
path: root/src/doc/rustc-dev-guide
diff options
context:
space:
mode:
authorjyn <github@jyn.dev>2023-03-26 10:28:07 -0500
committerGitHub <noreply@github.com>2023-03-27 00:28:07 +0900
commit56c1d301b492440d5d40ce21fef6a60ca73a23be (patch)
treea5e4d73b8d7c27ca84e3920dd824909ffe68c47c /src/doc/rustc-dev-guide
parent52dd6d812a077624d20faed8ba7674c52f8a375e (diff)
downloadrust-56c1d301b492440d5d40ce21fef6a60ca73a23be.tar.gz
rust-56c1d301b492440d5d40ce21fef6a60ca73a23be.zip
Don't require $GITHUB_TOKEN to build locally (#1652)
Diffstat (limited to 'src/doc/rustc-dev-guide')
-rw-r--r--src/doc/rustc-dev-guide/README.md4
-rw-r--r--src/doc/rustc-dev-guide/book.toml3
-rwxr-xr-xsrc/doc/rustc-dev-guide/ci/linkcheck.sh16
3 files changed, 15 insertions, 8 deletions
diff --git a/src/doc/rustc-dev-guide/README.md b/src/doc/rustc-dev-guide/README.md
index e501c91615f..b2b538ffb65 100644
--- a/src/doc/rustc-dev-guide/README.md
+++ b/src/doc/rustc-dev-guide/README.md
@@ -49,10 +49,10 @@ To build a local static HTML site, install [`mdbook`](https://github.com/rust-la
 and execute the following command in the root of the repository:
 
 ```
-> mdbook build
+> mdbook build --open
 ```
 
-The build files are found in the `book` directory.
+The build files are found in the `book/html` directory.
 
 ### Link Validations
 
diff --git a/src/doc/rustc-dev-guide/book.toml b/src/doc/rustc-dev-guide/book.toml
index 96b9e3fe1f5..203bfd61ea7 100644
--- a/src/doc/rustc-dev-guide/book.toml
+++ b/src/doc/rustc-dev-guide/book.toml
@@ -43,9 +43,6 @@ exclude = [
 cache-timeout = 86400
 warning-policy = "error"
 
-[output.linkcheck.http-headers]
-'github\.com' = ["Authorization: Bearer $GITHUB_TOKEN"]
-
 [output.html.redirect]
 "/compiletest.html" = "tests/compiletest.html"
 "/diagnostics/sessiondiagnostic.html" = "diagnostic-structs.html"
diff --git a/src/doc/rustc-dev-guide/ci/linkcheck.sh b/src/doc/rustc-dev-guide/ci/linkcheck.sh
index 5d49d133726..133e2223970 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