From 19bf7a29225141152a81dcb2fa0ba90230c0d469 Mon Sep 17 00:00:00 2001 From: AlexD10S Date: Mon, 6 May 2024 10:59:52 +0100 Subject: [PATCH 1/3] fix: print logs for debugging --- crates/pop-parachains/src/up.rs | 2 ++ crates/pop-parachains/src/utils/git.rs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/crates/pop-parachains/src/up.rs b/crates/pop-parachains/src/up.rs index 5f26f2cd..85637f9e 100644 --- a/crates/pop-parachains/src/up.rs +++ b/crates/pop-parachains/src/up.rs @@ -368,8 +368,10 @@ impl Zombienet { async fn latest_polkadot_release() -> Result { let repo = Url::parse(POLKADOT_SDK).expect("repository url valid"); + println!("{:?}", repo); // Fetching latest releases for release in GitHub::get_latest_releases(&repo).await? { + println!("{:?}", release.tag_name); if !release.prerelease && release.tag_name.starts_with("polkadot-v") { return Ok(release .tag_name diff --git a/crates/pop-parachains/src/utils/git.rs b/crates/pop-parachains/src/utils/git.rs index e732c9be..619a6709 100644 --- a/crates/pop-parachains/src/utils/git.rs +++ b/crates/pop-parachains/src/utils/git.rs @@ -150,6 +150,8 @@ impl GitHub { concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")); let client = reqwest::ClientBuilder::new().user_agent(APP_USER_AGENT).build()?; + println!("https://api.github.com/repos/{}/{}/releases", Self::org(repo)?, + Self::name(repo)?); let response = client .get(format!( "https://api.github.com/repos/{}/{}/releases", @@ -158,6 +160,7 @@ impl GitHub { )) .send() .await?; + println!("Response"); Ok(response.json::>().await?) } From d39660f79181849bfdd27f7bb077e3d2bc70ee33 Mon Sep 17 00:00:00 2001 From: AlexD10S Date: Tue, 7 May 2024 09:10:52 +0100 Subject: [PATCH 2/3] fix: return default version if github api fails --- crates/pop-parachains/src/up.rs | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/crates/pop-parachains/src/up.rs b/crates/pop-parachains/src/up.rs index 85637f9e..24735bca 100644 --- a/crates/pop-parachains/src/up.rs +++ b/crates/pop-parachains/src/up.rs @@ -369,18 +369,24 @@ impl Zombienet { async fn latest_polkadot_release() -> Result { let repo = Url::parse(POLKADOT_SDK).expect("repository url valid"); println!("{:?}", repo); - // Fetching latest releases - for release in GitHub::get_latest_releases(&repo).await? { - println!("{:?}", release.tag_name); - if !release.prerelease && release.tag_name.starts_with("polkadot-v") { - return Ok(release - .tag_name - .strip_prefix("polkadot-") - .map_or_else(|| release.tag_name.clone(), |v| v.to_string())); - } + match GitHub::get_latest_releases(&repo).await { + Ok(releases) => { + // Fetching latest releases + for release in releases { + println!("{:?}", release.tag_name); + if !release.prerelease && release.tag_name.starts_with("polkadot-v") { + return Ok(release + .tag_name + .strip_prefix("polkadot-") + .map_or_else(|| release.tag_name.clone(), |v| v.to_string())); + } + } + // It should never reach this point, but in case we download a default version of polkadot + Ok(POLKADOT_DEFAULT_VERSION.to_string()) + }, + // If an error with Github API return the POLKADOT DEFAULT VERSION + Err(_) => Ok(POLKADOT_DEFAULT_VERSION.to_string()), } - // It should never reach this point, but in case we download a default version of polkadot - Ok(POLKADOT_DEFAULT_VERSION.to_string()) } } From 6b5c0e780f75e7d0416339e6f07834f89fe487e5 Mon Sep 17 00:00:00 2001 From: AlexD10S Date: Tue, 7 May 2024 14:09:18 +0100 Subject: [PATCH 3/3] refactor: remove logs --- crates/pop-parachains/src/up.rs | 2 -- crates/pop-parachains/src/utils/git.rs | 3 --- 2 files changed, 5 deletions(-) diff --git a/crates/pop-parachains/src/up.rs b/crates/pop-parachains/src/up.rs index 24735bca..439cfd6d 100644 --- a/crates/pop-parachains/src/up.rs +++ b/crates/pop-parachains/src/up.rs @@ -368,12 +368,10 @@ impl Zombienet { async fn latest_polkadot_release() -> Result { let repo = Url::parse(POLKADOT_SDK).expect("repository url valid"); - println!("{:?}", repo); match GitHub::get_latest_releases(&repo).await { Ok(releases) => { // Fetching latest releases for release in releases { - println!("{:?}", release.tag_name); if !release.prerelease && release.tag_name.starts_with("polkadot-v") { return Ok(release .tag_name diff --git a/crates/pop-parachains/src/utils/git.rs b/crates/pop-parachains/src/utils/git.rs index 619a6709..e732c9be 100644 --- a/crates/pop-parachains/src/utils/git.rs +++ b/crates/pop-parachains/src/utils/git.rs @@ -150,8 +150,6 @@ impl GitHub { concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")); let client = reqwest::ClientBuilder::new().user_agent(APP_USER_AGENT).build()?; - println!("https://api.github.com/repos/{}/{}/releases", Self::org(repo)?, - Self::name(repo)?); let response = client .get(format!( "https://api.github.com/repos/{}/{}/releases", @@ -160,7 +158,6 @@ impl GitHub { )) .send() .await?; - println!("Response"); Ok(response.json::>().await?) }