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

Remove properly tracked config file from .gitignore & add support for skipping of link-checking #2023

Merged
merged 4 commits into from
Dec 29, 2024
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
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
book

# prevent accidental changes
book.toml

ci/date-check/target/

# Generated by check-in.sh
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,21 @@ The build files are found in the `book/html` directory.
We use `mdbook-linkcheck2` to validate URLs included in our documentation.
`linkcheck` will be run automatically when you build with the instructions in the section above.

> [!NOTE]
> The link validation can be skipped by setting the following environment variable:
> `SKIP_LINKCHECK=1 mdbook ...`

### Table of Contents

We use `mdbook-toc` to auto-generate TOCs for long sections. You can invoke the preprocessor by
including the `<!-- toc -->` marker at the place where you want the TOC.

## How to fix toolstate failures

> **NOTE**: Currently, we do not track the rustc-dev-guide toolstate due to
[spurious failures](https://github.com/rust-lang/rust/pull/71731),
but we leave these instructions for when we do it again in the future.
> [!NOTE]
> Currently, we do not track the rustc-dev-guide toolstate due to
> [spurious failures](https://github.com/rust-lang/rust/pull/71731),
> but we leave these instructions for when we do it again in the future.

1. You will get a ping from the toolstate commit. e.g. https://github.com/rust-lang-nursery/rust-toolstate/commit/8ffa0e4c30ac9ba8546b7046e5c4ccc2b96ebdd4

Expand Down
13 changes: 10 additions & 3 deletions ci/linkcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
set -e
set -o pipefail

LINKCHECK_BINARY=mdbook-linkcheck2

set_github_token() {
jq '.config.output.linkcheck."http-headers"."github\\.com" = ["Authorization: Bearer $GITHUB_TOKEN"]'
}

if [ ! -z "$SKIP_LINKCHECK" ] ; then
echo "Skipping link check."
exit 0
fi

# https://docs.github.com/en/actions/reference/environment-variables
if [ "$GITHUB_EVENT_NAME" = "schedule" ] ; then # running in scheduled job
FLAGS=""
Expand All @@ -32,10 +39,10 @@ else # running locally
echo "Checking files changed in $COMMIT_RANGE: $CHANGED_FILES"
fi

echo "exec mdbook-linkcheck2 $FLAGS"
echo "exec $LINKCHECK_BINARY $FLAGS"
if [ "$USE_TOKEN" = 1 ]; then
config=$(set_github_token)
exec mdbook-linkcheck2 $FLAGS <<<"$config"
exec $LINKCHECK_BINARY $FLAGS <<<"$config"
else
exec mdbook-linkcheck2 $FLAGS
exec $LINKCHECK_BINARY $FLAGS
fi
Loading