diff --git a/.github/workflows/copyright.yml b/.github/workflows/copyright.yml index 75786b852bb2..558b959f0ef3 100644 --- a/.github/workflows/copyright.yml +++ b/.github/workflows/copyright.yml @@ -15,7 +15,8 @@ jobs: - name: Get paths for files added id: git-diff run: | - files=$(git diff --name-only --diff-filter=A ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -v -E '(expected|ignore|gitignore)$' | xargs) + ignore='(.md|expected|ignore|gitignore)$' + files=$(git diff --name-only --diff-filter=A ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -v -E $ignore | xargs) echo "::set-output name=paths::$files" - name: Execute copyright check diff --git a/.gitignore b/.gitignore index e1e73a4b5316..2b8e3f25edac 100644 --- a/.gitignore +++ b/.gitignore @@ -77,5 +77,3 @@ src/test/rustdoc-gui/src/**.lock # Before adding new lines, see the comment at the top. /src/test/ref -/src/tools/dashboard/Cargo.lock -/src/tools/dashboard/target diff --git a/Cargo.lock b/Cargo.lock index 7fd05360f205..a5f58f93f4ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -885,6 +885,13 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "dashboard" +version = "0.1.0" +dependencies = [ + "pulldown-cmark 0.8.0", +] + [[package]] name = "datafrog" version = "2.0.1" diff --git a/Cargo.toml b/Cargo.toml index 142ca97225cb..d80890011229 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ members = [ "src/tools/clippy", "src/tools/clippy/clippy_dev", "src/tools/compiletest", + "src/tools/dashboard", "src/tools/error_index_generator", "src/tools/linkchecker", "src/tools/lint-docs", @@ -49,7 +50,6 @@ exclude = [ "src/tools/x", # stdarch has its own Cargo workspace "library/stdarch", - "src/tools/dashboard", ] [profile.release.package.compiler_builtins] diff --git a/scripts/display-dashboard.sh b/scripts/display-dashboard.sh deleted file mode 100755 index f90d1a65a921..000000000000 --- a/scripts/display-dashboard.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 OR MIT - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -RUST_DIR=$SCRIPT_DIR/.. -export PATH=$SCRIPT_DIR:$PATH - -cargo build --manifest-path src/tools/dashboard/Cargo.toml -cargo run --manifest-path src/tools/dashboard/Cargo.toml diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 4b4df8557b47..46d4285a1b5e 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -372,6 +372,7 @@ impl<'a> Builder<'a> { tool::Linkchecker, tool::CargoTest, tool::Compiletest, + tool::Dashboard, tool::RemoteTestServer, tool::RemoteTestClient, tool::RustInstaller, @@ -523,7 +524,7 @@ impl<'a> Builder<'a> { install::Src, install::Rustc ), - Kind::Run => describe!(run::ExpandYamlAnchors, run::BuildManifest), + Kind::Run => describe!(run::Dashboard, run::ExpandYamlAnchors, run::BuildManifest), } } diff --git a/src/bootstrap/run.rs b/src/bootstrap/run.rs index 7c64e5a0aadc..5964f6b050fd 100644 --- a/src/bootstrap/run.rs +++ b/src/bootstrap/run.rs @@ -4,6 +4,33 @@ use crate::tool::Tool; use build_helper::output; use std::process::Command; +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub struct Dashboard; + +impl Step for Dashboard { + type Output = (); + + /// Runs the `dashboard` tool. + /// + /// This tool in `src/tools` extracts examples from books, runs them through + /// RMC, and displays their results. + fn run(self, builder: &Builder<'_>) { + builder.info("Generating confidence dashboard"); + try_run( + builder, + &mut builder.tool_cmd(Tool::Dashboard).env("TRIPLE", builder.config.build.triple), + ); + } + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.path("src/tools/dashboard") + } + + fn make_run(run: RunConfig<'_>) { + run.builder.ensure(Dashboard); + } +} + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct ExpandYamlAnchors; diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index aa7fe658df32..135ab04c69cf 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -369,6 +369,7 @@ bootstrap_tool!( Linkchecker, "src/tools/linkchecker", "linkchecker"; CargoTest, "src/tools/cargotest", "cargotest"; Compiletest, "src/tools/compiletest", "compiletest", is_unstable_tool = true; + Dashboard, "src/tools/dashboard", "dashboard"; BuildManifest, "src/tools/build-manifest", "build-manifest"; RemoteTestClient, "src/tools/remote-test-client", "remote-test-client"; RustInstaller, "src/tools/rust-installer", "fabricate", is_external_tool = true; diff --git a/src/tools/dashboard/README.md b/src/tools/dashboard/README.md new file mode 100644 index 000000000000..3e3a809e3f2b --- /dev/null +++ b/src/tools/dashboard/README.md @@ -0,0 +1,10 @@ +# Confidence Dashboard + +This tool generates a dashboard of the Rust features supported by RMC. It +does so by extracting examples from Rust books, running RMC on them, and +displaying the results in the dashboard. + +Run the following command to build this tool and generate the dashboard: +```bash +./x.py run -i --stage 1 dashboard +``` diff --git a/src/tools/dashboard/src/reference.rs b/src/tools/dashboard/src/reference.rs index 75e7ff7e9ae3..f38077eb4db2 100644 --- a/src/tools/dashboard/src/reference.rs +++ b/src/tools/dashboard/src/reference.rs @@ -111,7 +111,7 @@ fn organize_examples(map: &HashMap, book_dir: &Path, from_dir: /// `map`. fn copy(from: &Path, map: &HashMap) { // The path specified by `from` has the form: - // `src/tools/dashboard/target/ref/__/rust_out` + // `build//dashboard/ref/__/rust_out` // We copy the file in this path to a new path of the form: // `src/test//.rs // where `map[] == `. We omit because all tests have @@ -259,8 +259,10 @@ fn display_dashboard(dashboard: dashboard::Tree) { pub fn display_reference_dashboard() { let summary_path: PathBuf = ["src", "doc", "reference", "src", "SUMMARY.md"].iter().collect(); let ref_dir: PathBuf = ["src", "doc", "reference", "src"].iter().collect(); - let gen_dir: PathBuf = ["src", "tools", "dashboard", "target", "ref"].iter().collect(); - let log_path: PathBuf = ["src", "tools", "dashboard", "target", "ref.log"].iter().collect(); + let build_dir = &env::var("BUILD_DIR").unwrap(); + let triple = &env::var("TRIPLE").unwrap(); + let gen_dir: PathBuf = [build_dir, triple, "dashboard", "ref"].iter().collect(); + let log_path: PathBuf = [build_dir, triple, "dashboard", "ref.log"].iter().collect(); // Parse the chapter/section hierarchy from the table of contents in The // Rust Reference. let map = parse_hierarchy(&summary_path);