-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(xtask): refactor tool runners & e2e test supergraph demo (#629)
- Loading branch information
1 parent
b6d8497
commit ec747e8
Showing
18 changed files
with
299 additions
and
165 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
mod commands; | ||
|
||
pub(crate) mod target; | ||
pub(crate) mod tools; | ||
pub(crate) mod utils; | ||
|
||
use ansi_term::Colour::Green; | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use crate::tools::Runner; | ||
|
||
use std::convert::TryFrom; | ||
|
||
use anyhow::{Context, Result}; | ||
use assert_fs::TempDir; | ||
use camino::Utf8PathBuf; | ||
|
||
pub(crate) struct GitRunner { | ||
temp_dir_path: Utf8PathBuf, | ||
runner: Runner, | ||
|
||
// we store _temp_dir here since its Drop implementation deletes the directory | ||
_temp_dir: TempDir, | ||
} | ||
|
||
impl GitRunner { | ||
pub(crate) fn new(verbose: bool) -> Result<Self> { | ||
let runner = Runner::new("git", verbose)?; | ||
let temp_dir = TempDir::new().with_context(|| "Could not create temp directory")?; | ||
let temp_dir_path = Utf8PathBuf::try_from(temp_dir.path().to_path_buf()) | ||
.with_context(|| "Temp directory was not valid Utf-8")?; | ||
|
||
Ok(GitRunner { | ||
runner, | ||
temp_dir_path, | ||
_temp_dir: temp_dir, | ||
}) | ||
} | ||
|
||
pub(crate) fn clone_supergraph_demo(&self) -> Result<Utf8PathBuf> { | ||
let repo_name = "supergraph-demo"; | ||
let repo_url = format!("https://github.com/apollographql/{}", repo_name); | ||
self.runner | ||
.exec(&["clone", &repo_url], &self.temp_dir_path, None)?; | ||
|
||
let repo_path = self.temp_dir_path.join(repo_name); | ||
Ok(repo_path) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use std::collections::HashMap; | ||
|
||
use crate::tools::Runner; | ||
use crate::utils::CommandOutput; | ||
|
||
use anyhow::{anyhow, Context, Result}; | ||
use camino::{Utf8Path, Utf8PathBuf}; | ||
|
||
pub(crate) struct MakeRunner { | ||
runner: Runner, | ||
rover_exe: Utf8PathBuf, | ||
} | ||
|
||
impl MakeRunner { | ||
pub(crate) fn new(verbose: bool, rover_exe: Utf8PathBuf) -> Result<Self> { | ||
let runner = Runner::new("make", verbose)?; | ||
|
||
Ok(MakeRunner { runner, rover_exe }) | ||
} | ||
|
||
pub(crate) fn test_supergraph_demo(&self, base_dir: &Utf8Path) -> Result<()> { | ||
let mut env = HashMap::new(); | ||
env.insert("ROVER_BIN".to_string(), self.rover_exe.to_string()); | ||
let output = self.runner.exec(&["ci"], base_dir, Some(env))?; | ||
assert_demo_includes(&output) | ||
.with_context(|| "There were problems with the output of 'make ci'.") | ||
} | ||
} | ||
|
||
fn assert_demo_includes(output: &CommandOutput) -> Result<()> { | ||
let necessary_stdout = vec!["🚀 Graph Router ready at http://localhost:4000/"]; | ||
let necessary_stderr = vec!["allProducts", "Removing network"]; | ||
|
||
let mut missing_strings = Vec::with_capacity(necessary_stderr.len() + necessary_stdout.len()); | ||
for necessary_string in necessary_stdout { | ||
if !output.stdout.contains(necessary_string) { | ||
missing_strings.push(necessary_string); | ||
} | ||
} | ||
for necessary_string in necessary_stderr { | ||
if !output.stderr.contains(necessary_string) { | ||
missing_strings.push(necessary_string); | ||
} | ||
} | ||
|
||
if missing_strings.is_empty() { | ||
Ok(()) | ||
} else { | ||
Err(anyhow!( | ||
"The output from 'make` is missing the following strings: {:?}", | ||
missing_strings | ||
)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
mod cargo; | ||
mod git; | ||
mod make; | ||
mod npm; | ||
mod runner; | ||
mod strip; | ||
|
||
pub(crate) use cargo::CargoRunner; | ||
pub(crate) use git::GitRunner; | ||
pub(crate) use make::MakeRunner; | ||
pub(crate) use npm::NpmRunner; | ||
pub(crate) use runner::Runner; | ||
pub(crate) use strip::StripRunner; |
Oops, something went wrong.