-
Notifications
You must be signed in to change notification settings - Fork 182
fix(test): speed up test-release and codecov on CI #6372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e496b3f
5a8675d
afa58f3
45f74a8
80b2f2e
6ad6456
9425181
4edf480
73b3d8f
0eb2812
00f0d72
a74c99c
284ec79
836b7a2
89ba6d9
f63bdc1
b5de8d1
7ea16b7
f136bdd
f3dae30
d056b6a
c0d2813
400b88e
fb1eb32
a208961
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add this binary to the docs script?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't add it because it adds more noise than usefulness for users. What do you think?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No huge preference here, we can revisit once |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // Copyright 2019-2025 ChainSafe Systems | ||
| // SPDX-License-Identifier: Apache-2.0, MIT | ||
|
|
||
| #[tokio::main(flavor = "multi_thread")] | ||
| async fn main() -> anyhow::Result<()> { | ||
| forest::forest_dev_main(std::env::args_os()).await | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // Copyright 2019-2025 ChainSafe Systems | ||
| // SPDX-License-Identifier: Apache-2.0, MIT | ||
|
|
||
| use super::subcommands::Cli; | ||
| use crate::cli_shared::logger::setup_minimal_logger; | ||
| use clap::Parser as _; | ||
| use std::ffi::OsString; | ||
|
|
||
| pub async fn main<ArgT>(args: impl IntoIterator<Item = ArgT>) -> anyhow::Result<()> | ||
| where | ||
| ArgT: Into<OsString> + Clone, | ||
| { | ||
| // Capture Cli inputs | ||
| let Cli { cmd } = Cli::parse_from(args); | ||
| setup_minimal_logger(); | ||
| let client = crate::rpc::Client::default_or_from_env(None)?; | ||
| cmd.run(client).await | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| // Copyright 2019-2025 ChainSafe Systems | ||
| // SPDX-License-Identifier: Apache-2.0, MIT | ||
|
|
||
| pub mod main; | ||
| pub mod subcommands; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| // Copyright 2019-2025 ChainSafe Systems | ||
| // SPDX-License-Identifier: Apache-2.0, MIT | ||
|
|
||
| use crate::cli_shared::cli::HELP_MESSAGE; | ||
| use crate::rpc::Client; | ||
| use crate::utils::net::{DownloadFileOption, download_file_with_cache}; | ||
| use crate::utils::proofs_api::ensure_proof_params_downloaded; | ||
| use crate::utils::version::FOREST_VERSION_STRING; | ||
| use anyhow::Context as _; | ||
| use clap::Parser; | ||
| use directories::ProjectDirs; | ||
| use std::borrow::Cow; | ||
| use std::path::PathBuf; | ||
| use std::time::Duration; | ||
| use tokio::task::JoinSet; | ||
| use url::Url; | ||
|
|
||
| /// Command-line options for the `forest-dev` binary | ||
| #[derive(Parser)] | ||
| #[command(name = env!("CARGO_PKG_NAME"), bin_name = "forest-dev", author = env!("CARGO_PKG_AUTHORS"), version = FOREST_VERSION_STRING.as_str(), about = env!("CARGO_PKG_DESCRIPTION") | ||
| )] | ||
| #[command(help_template(HELP_MESSAGE))] | ||
| pub struct Cli { | ||
| #[command(subcommand)] | ||
| pub cmd: Subcommand, | ||
| } | ||
|
|
||
| /// forest-dev sub-commands | ||
| #[derive(clap::Subcommand)] | ||
| pub enum Subcommand { | ||
| /// Fetch RPC test snapshots to the local cache | ||
| FetchRpcTests, | ||
| } | ||
|
|
||
| impl Subcommand { | ||
| pub async fn run(self, _client: Client) -> anyhow::Result<()> { | ||
| match self { | ||
| Self::FetchRpcTests => fetch_rpc_tests().await, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| async fn fetch_rpc_tests() -> anyhow::Result<()> { | ||
| crate::utils::proofs_api::maybe_set_proofs_parameter_cache_dir_env( | ||
| &crate::Config::default().client.data_dir, | ||
| ); | ||
| ensure_proof_params_downloaded().await?; | ||
| let tests = include_str!("../../tool/subcommands/api_cmd/test_snapshots.txt") | ||
| .lines() | ||
| .map(|i| { | ||
| // Remove comment | ||
| i.split("#").next().unwrap().trim().to_string() | ||
| }) | ||
| .filter(|l| !l.is_empty() && !l.starts_with('#')); | ||
| let mut joinset = JoinSet::new(); | ||
| for test in tests { | ||
| joinset.spawn(fetch_rpc_test_snapshot(test.into())); | ||
| } | ||
| for result in joinset.join_all().await { | ||
| if let Err(e) = result { | ||
| tracing::warn!("{e}"); | ||
| } | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| pub async fn fetch_rpc_test_snapshot<'a>(name: Cow<'a, str>) -> anyhow::Result<PathBuf> { | ||
| let url: Url = | ||
| format!("https://forest-snapshots.fra1.cdn.digitaloceanspaces.com/rpc_test/{name}") | ||
| .parse() | ||
| .with_context(|| format!("Failed to parse URL for test: {name}"))?; | ||
| let project_dir = | ||
| ProjectDirs::from("com", "ChainSafe", "Forest").context("failed to get project dir")?; | ||
| let cache_dir = project_dir.cache_dir().join("test").join("rpc-snapshots"); | ||
| let path = crate::utils::retry( | ||
| crate::utils::RetryArgs { | ||
| timeout: Some(Duration::from_secs(30)), | ||
| max_retries: Some(5), | ||
| delay: Some(Duration::from_secs(1)), | ||
| }, | ||
| || download_file_with_cache(&url, &cache_dir, DownloadFileOption::NonResumable), | ||
| ) | ||
| .await | ||
| .map_err(|e| anyhow::anyhow!("failed to fetch rpc test snapshot {name} :{e}"))? | ||
| .path; | ||
| Ok(path) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
codecovruns on hosted runners now.