Skip to content

Commit

Permalink
debug ci tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NanezX committed Nov 3, 2023
1 parent 0ea6b1f commit 069fce4
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 16 deletions.
4 changes: 4 additions & 0 deletions subgraph/cli/deploy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ pub struct DeployArgs {
}

pub fn deploy_subgraph(config: DeployArgs) -> anyhow::Result<()> {
if config.url.scheme() != "http" && config.url.scheme() != "https" {
return Err(anyhow!("Invalid URL provided"));
}

let subgraph_template = "subgraph.template.yaml";
let output_path = "subgraph.yaml";

Expand Down
48 changes: 33 additions & 15 deletions subgraph/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod deploy;
mod utils;
use clap::{Parser, Subcommand};

// use colored::*;
use colored::*;
use deploy::{deploy_subgraph, DeployArgs};
use utils::run_cmd;

Expand Down Expand Up @@ -31,34 +31,52 @@ fn main() -> Result<(), anyhow::Error> {

match args.subgraph {
Subgraph::Install => {
run_cmd("npm", &["install"]);
let resp = run_cmd("npm", &["install"]);

if !resp {
eprintln!("{}", "Error: Failed at npm install".red());
std::process::exit(1);
}

Ok(())
}

Subgraph::Build => {
run_cmd("npm", &["run", "codegen"]);
run_cmd("npm", &["run", "build"]);
let resp = run_cmd("npm", &["run", "codegen"]);
if !resp {
eprintln!("{}", "Error: Failed at npm run codegen".red());
std::process::exit(1);
}

let resp = run_cmd("npm", &["run", "build"]);
if !resp {
eprintln!("{}", "Error: Failed at npm run build".red());
std::process::exit(1);
}

Ok(())
}

Subgraph::Test => {
run_cmd("nix", &["run", ".#ci-test"]);
let resp = run_cmd("nix", &["run", ".#ci-test"]);
if !resp {
std::process::exit(1);
}

Ok(())
}
Subgraph::Deploy(args) => {
println!("\n🚀 Hello deploy");
let _ = deploy_subgraph(args);

// if args.url.scheme() != "http" && args.url.scheme() != "https" {
// eprintln!("Error: Invalid URL provided");
// std::process::exit(1);
// }

Ok(())

Subgraph::Deploy(args) => {
match deploy_subgraph(args) {
Ok(_) => {
return Ok(());
}
Err(err) => {
// Error occurred, print the error message and exit
eprintln!("Error: {}", err);
std::process::exit(1);
}
}
}
}
}
1 change: 0 additions & 1 deletion subgraph/cli/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::thread;
pub fn run_cmd(main_cmd: &str, args: &[&str]) -> bool {
// Get the current working directory
let current_dir = env::current_dir().expect("Failed to get current directory");
println!("current_dir: {:?}", current_dir.to_str());

// Create a new Command to run
let mut cmd = Command::new(main_cmd);
Expand Down
5 changes: 5 additions & 0 deletions subgraph/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@
# This in case the subgraph schema.graphql have changes when running tests
${gen-sg-schema}
echo "Print root"
ls .
echo "Print query folder"
ls tests/subgraph/query
# Run tests in single thread
cargo test -- --test-threads=1 --nocapture;
'');
Expand Down

0 comments on commit 069fce4

Please sign in to comment.