diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3d479a436..fc2355c90 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,13 +9,9 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Check for broken Markdown links - uses: gaurav-nelson/github-action-markdown-link-check@v1 - with: - use-quiet-mode: 'yes' - use-verbose-mode: 'yes' - folder-path: 'crates, installers' - file-path: './README.md' + - uses: actions/setup-node@v2 + with: + node-version: '16' - name: Install Rust run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index dfaec1c25..a2830bc9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -514,7 +514,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm [issue/449]: https://github.com/apollographql/rover/issues/449 [pull/519]: https://github.com/apollographql/rover/pull/519 -- **`--routing-url` is now an optional argument to `rover subgraph publish` - [EverlastingBusgtopper], [issue/169] [pull/484]** +- **`--routing-url` is now an optional argument to `rover subgraph publish` - [EverlastingBugstopper], [issue/169] [pull/484]** When publishing a subgraph, it is important to include a routing URL for that subgraph, so your graph router knows where to route requests for types in a subgraph. Previously, you had to specify this argument on @@ -522,7 +522,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm `rover subgraph publish`, but subsequent publishes will retain the existing routing URL for a subgraph if `--routing-url` is not specified. - [EverlastingBusgtopper]: https://github.com/EverlastingBusgtopper + [EverlastingBugstopper]: https://github.com/EverlastingBugstopper [pull/484]: https://github.com/apollographql/rover/pull/484 [issue/169]: https://github.com/apollographql/rover/issues/169 @@ -1369,7 +1369,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - **Document Git Context - [JakeDawkins], [pull/262]** We added documentation for how Rover provides Git Context to Apollo Studio. - You can read all about it [here](https://apollo-cli-docs.netlify.app/docs/rover/configuring/#git-context). + You can read all about it [here](https://apollographql.com/docs/rover/configuring/#git-context). [JakeDawkins]: https://github.com/JakeDawkins [pull/262]: https://github.com/apollographql/rover/pull/262 diff --git a/crates/rover-client/package-lock.json b/crates/rover-client/package-lock.json index beda08a06..f4075eff7 100644 --- a/crates/rover-client/package-lock.json +++ b/crates/rover-client/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "rover-client", "version": "0.0.0", "devDependencies": { "@graphql-eslint/eslint-plugin": ">=1.1.4", diff --git a/xtask/src/tools/npm.rs b/xtask/src/tools/npm.rs index 8a6d79b87..98b4315c3 100644 --- a/xtask/src/tools/npm.rs +++ b/xtask/src/tools/npm.rs @@ -1,7 +1,7 @@ use anyhow::{anyhow, Context, Result}; use camino::Utf8PathBuf; -use std::str; +use std::{convert::TryFrom, fs, str}; use crate::{ tools::Runner, @@ -11,7 +11,7 @@ use crate::{ pub(crate) struct NpmRunner { runner: Runner, npm_installer_package_directory: Utf8PathBuf, - npm_lint_directory: Utf8PathBuf, + rover_client_lint_directory: Utf8PathBuf, } impl NpmRunner { @@ -19,7 +19,7 @@ impl NpmRunner { let runner = Runner::new("npm", verbose)?; let project_root = PKG_PROJECT_ROOT.clone(); - let npm_lint_directory = project_root.join("crates").join("rover-client"); + let rover_client_lint_directory = project_root.join("crates").join("rover-client"); let npm_installer_package_directory = project_root.join("installers").join("npm"); if !npm_installer_package_directory.exists() { @@ -29,17 +29,17 @@ impl NpmRunner { )); } - if !npm_lint_directory.exists() { + if !rover_client_lint_directory.exists() { return Err(anyhow!( "Rover's GraphQL linter package does not seem to be located here:\n{}", - &npm_lint_directory + &rover_client_lint_directory )); } Ok(Self { runner, npm_installer_package_directory, - npm_lint_directory, + rover_client_lint_directory, }) } @@ -64,13 +64,32 @@ impl NpmRunner { } pub(crate) fn update_linter(&self) -> Result<()> { - self.npm_exec(&["update"], &self.npm_lint_directory)?; + self.npm_exec(&["update"], &self.rover_client_lint_directory)?; Ok(()) } pub(crate) fn lint(&self) -> Result<()> { - self.npm_exec(&["install"], &self.npm_lint_directory)?; - self.npm_exec(&["run", "lint"], &self.npm_lint_directory)?; + self.npm_exec(&["install"], &self.rover_client_lint_directory)?; + self.npm_exec(&["run", "lint"], &self.rover_client_lint_directory)?; + + let files = get_md_files(); + + crate::utils::info(&format!("{:?}", files)); + + for file in files { + self.npm_exec( + &[ + "exec", + "--", + "markdown-link-check", + file.as_str(), + "--config=mlc_config.json", + "-v", + ], + &PKG_PROJECT_ROOT, + )?; + } + Ok(()) } @@ -131,3 +150,44 @@ fn assert_publish_includes(output: &CommandOutput) -> Result<()> { )) } } + +fn get_md_files() -> Vec { + let mut md_files = Vec::new(); + + walk_dir(PKG_PROJECT_ROOT.as_str(), &mut md_files); + + md_files +} + +fn walk_dir(base_dir: &str, md_files: &mut Vec) { + if let Ok(entries) = fs::read_dir(base_dir) { + for entry in entries.flatten() { + if let Ok(file_type) = entry.file_type() { + if file_type.is_file() { + if let Ok(file_name) = entry.file_name().into_string() { + // the CHANGELOG is simply too large to be running this check on every PR + if file_name.ends_with(".md") && !file_name.contains("CHANGELOG") { + if let Ok(entry_path) = Utf8PathBuf::try_from(entry.path()) { + md_files.push(entry_path) + } + } + } + } else if file_type.is_dir() { + if let Ok(dir_name) = entry.file_name().into_string() { + // we can't do much if a link is broken in node_modules (and it's big!) + if dir_name != "node_modules" + // we don't need to check the Rust compiler's output for broken links + && dir_name != "target" + // the docs have their own link checker, no need to check twice + && dir_name != "docs" + // also no need to recurse through hidden directories + && !dir_name.starts_with('.') + { + walk_dir(&dir_name, md_files); + } + } + } + } + } + } +}