Rollup merge of #62950 - mati865:linkcheck, r=alexcrichton
Check rustbook links on all platforms when running locally cc https://github.com/rust-lang/rust/issues/62739
This commit is contained in:
commit
a03872645f
4 changed files with 36 additions and 13 deletions
|
@ -9,7 +9,7 @@ use build_helper::t;
|
||||||
use crate::Mode;
|
use crate::Mode;
|
||||||
use crate::Compiler;
|
use crate::Compiler;
|
||||||
use crate::builder::{Step, RunConfig, ShouldRun, Builder};
|
use crate::builder::{Step, RunConfig, ShouldRun, Builder};
|
||||||
use crate::util::{exe, add_lib_path};
|
use crate::util::{exe, add_lib_path, CiEnv};
|
||||||
use crate::compile;
|
use crate::compile;
|
||||||
use crate::channel::GitInfo;
|
use crate::channel::GitInfo;
|
||||||
use crate::channel;
|
use crate::channel;
|
||||||
|
@ -279,11 +279,26 @@ pub fn prepare_tool_cargo(
|
||||||
cargo
|
cargo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn rustbook_features() -> Vec<String> {
|
||||||
|
let mut features = Vec::new();
|
||||||
|
|
||||||
|
// Due to CI budged and risk of spurious failures we want to limit jobs running this check.
|
||||||
|
// At same time local builds should run it regardless of the platform.
|
||||||
|
// `CiEnv::None` means it's local build and `CHECK_LINKS` is defined in x86_64-gnu-tools to
|
||||||
|
// explicitly enable it on single job
|
||||||
|
if CiEnv::current() == CiEnv::None || env::var("CHECK_LINKS").is_ok() {
|
||||||
|
features.push("linkcheck".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
features
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! bootstrap_tool {
|
macro_rules! bootstrap_tool {
|
||||||
($(
|
($(
|
||||||
$name:ident, $path:expr, $tool_name:expr
|
$name:ident, $path:expr, $tool_name:expr
|
||||||
$(,llvm_tools = $llvm:expr)*
|
$(,llvm_tools = $llvm:expr)*
|
||||||
$(,is_external_tool = $external:expr)*
|
$(,is_external_tool = $external:expr)*
|
||||||
|
$(,features = $features:expr)*
|
||||||
;
|
;
|
||||||
)+) => {
|
)+) => {
|
||||||
#[derive(Copy, PartialEq, Eq, Clone)]
|
#[derive(Copy, PartialEq, Eq, Clone)]
|
||||||
|
@ -350,7 +365,12 @@ macro_rules! bootstrap_tool {
|
||||||
} else {
|
} else {
|
||||||
SourceType::InTree
|
SourceType::InTree
|
||||||
},
|
},
|
||||||
extra_features: Vec::new(),
|
extra_features: {
|
||||||
|
// FIXME(#60643): avoid this lint by using `_`
|
||||||
|
let mut _tmp = Vec::new();
|
||||||
|
$(_tmp.extend($features);)*
|
||||||
|
_tmp
|
||||||
|
},
|
||||||
}).expect("expected to build -- essential tool")
|
}).expect("expected to build -- essential tool")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,7 +379,7 @@ macro_rules! bootstrap_tool {
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrap_tool!(
|
bootstrap_tool!(
|
||||||
Rustbook, "src/tools/rustbook", "rustbook";
|
Rustbook, "src/tools/rustbook", "rustbook", features = rustbook_features();
|
||||||
UnstableBookGen, "src/tools/unstable-book-gen", "unstable-book-gen";
|
UnstableBookGen, "src/tools/unstable-book-gen", "unstable-book-gen";
|
||||||
Tidy, "src/tools/tidy", "tidy";
|
Tidy, "src/tools/tidy", "tidy";
|
||||||
Linkchecker, "src/tools/linkchecker", "linkchecker";
|
Linkchecker, "src/tools/linkchecker", "linkchecker";
|
||||||
|
|
|
@ -21,6 +21,9 @@ COPY x86_64-gnu-tools/checkregression.py /tmp/
|
||||||
COPY x86_64-gnu-tools/checktools.sh /tmp/
|
COPY x86_64-gnu-tools/checktools.sh /tmp/
|
||||||
COPY x86_64-gnu-tools/repo.sh /tmp/
|
COPY x86_64-gnu-tools/repo.sh /tmp/
|
||||||
|
|
||||||
|
# Run rustbook with `linkcheck` feature enabled
|
||||||
|
ENV CHECK_LINKS 1
|
||||||
|
|
||||||
ENV RUST_CONFIGURE_ARGS \
|
ENV RUST_CONFIGURE_ARGS \
|
||||||
--build=x86_64-unknown-linux-gnu \
|
--build=x86_64-unknown-linux-gnu \
|
||||||
--save-toolstates=/tmp/toolstates.json
|
--save-toolstates=/tmp/toolstates.json
|
||||||
|
|
|
@ -5,14 +5,15 @@ version = "0.1.0"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
linkcheck = ["mdbook-linkcheck"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "2.25.0"
|
clap = "2.25.0"
|
||||||
failure = "0.1"
|
failure = "0.1"
|
||||||
|
mdbook-linkcheck = { version = "0.3.0", optional = true }
|
||||||
|
|
||||||
[dependencies.mdbook]
|
[dependencies.mdbook]
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["search"]
|
features = ["search"]
|
||||||
|
|
||||||
[target.'cfg(all(target_arch = "x86_64", target_os = "linux"))'.dependencies]
|
|
||||||
mdbook-linkcheck = "0.3.0"
|
|
||||||
|
|
|
@ -8,10 +8,9 @@ use clap::{App, ArgMatches, SubCommand, AppSettings};
|
||||||
use mdbook::MDBook;
|
use mdbook::MDBook;
|
||||||
use mdbook::errors::{Result as Result3};
|
use mdbook::errors::{Result as Result3};
|
||||||
|
|
||||||
#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
|
#[cfg(feature = "linkcheck")]
|
||||||
use mdbook::renderer::RenderContext;
|
use mdbook::renderer::RenderContext;
|
||||||
|
#[cfg(feature = "linkcheck")]
|
||||||
#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
|
|
||||||
use mdbook_linkcheck::{self, errors::BrokenLinks};
|
use mdbook_linkcheck::{self, errors::BrokenLinks};
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ fn main() {
|
||||||
if let Err(err) = linkcheck(sub_matches) {
|
if let Err(err) = linkcheck(sub_matches) {
|
||||||
eprintln!("Error: {}", err);
|
eprintln!("Error: {}", err);
|
||||||
|
|
||||||
#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
|
#[cfg(feature = "linkcheck")]
|
||||||
{
|
{
|
||||||
if let Ok(broken_links) = err.downcast::<BrokenLinks>() {
|
if let Ok(broken_links) = err.downcast::<BrokenLinks>() {
|
||||||
for cause in broken_links.links().iter() {
|
for cause in broken_links.links().iter() {
|
||||||
|
@ -68,7 +67,7 @@ fn main() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
|
#[cfg(feature = "linkcheck")]
|
||||||
pub fn linkcheck(args: &ArgMatches<'_>) -> Result<(), Error> {
|
pub fn linkcheck(args: &ArgMatches<'_>) -> Result<(), Error> {
|
||||||
let book_dir = get_book_dir(args);
|
let book_dir = get_book_dir(args);
|
||||||
let book = MDBook::load(&book_dir).unwrap();
|
let book = MDBook::load(&book_dir).unwrap();
|
||||||
|
@ -78,9 +77,9 @@ pub fn linkcheck(args: &ArgMatches<'_>) -> Result<(), Error> {
|
||||||
mdbook_linkcheck::check_links(&render_ctx)
|
mdbook_linkcheck::check_links(&render_ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(all(target_arch = "x86_64", target_os = "linux")))]
|
#[cfg(not(feature = "linkcheck"))]
|
||||||
pub fn linkcheck(_args: &ArgMatches<'_>) -> Result<(), Error> {
|
pub fn linkcheck(_args: &ArgMatches<'_>) -> Result<(), Error> {
|
||||||
println!("mdbook-linkcheck only works on x86_64 linux targets.");
|
println!("mdbook-linkcheck is disabled.");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue