Skip to content

Updated the soldeer version to 0.2.18 and added extra CLI tests #8441

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

Merged
merged 5 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,6 @@ reqwest = { version = "0.12", default-features = false }
tower = "0.4"
tower-http = "0.5"
# soldeer
soldeer = "0.2.17"
soldeer = "0.2.19"

proptest = "1"
4 changes: 4 additions & 0 deletions crates/config/src/soldeer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ pub struct MapDependency {
/// The url from where the dependency was retrieved
#[serde(default, skip_serializing_if = "Option::is_none")]
pub url: Option<String>,

/// The commit in case git is used as dependency retrieval
#[serde(default, skip_serializing_if = "Option::is_none")]
pub rev: Option<String>,
}

/// Type for Soldeer configs, under dependencies tag in the foundry.toml
Expand Down
3 changes: 3 additions & 0 deletions crates/forge/bin/cmd/soldeer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use soldeer::commands::Subcommands;
// CLI arguments for `forge soldeer`.
#[derive(Clone, Debug, Parser)]
#[clap(override_usage = "forge soldeer install [DEPENDENCY]~[VERSION] <REMOTE_URL>
forge soldeer install [DEPENDENCY]~[VERSION] <GIT_URL>
forge soldeer install [DEPENDENCY]~[VERSION] <GIT_URL> --rev <REVISION>
forge soldeer install [DEPENDENCY]~[VERSION] <GIT_URL> --rev <TAG>
forge soldeer push [DEPENDENCY]~[VERSION] <CUSTOM_PATH_OF_FILES>
forge soldeer login
forge soldeer update
Expand Down
98 changes: 92 additions & 6 deletions crates/forge/tests/cli/soldeer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,96 @@ libs = ["lib"]
forge-std = "1.8.1"
"#;

let actual_foundry_contents = read_file_to_string(&foundry_file);
assert_eq!(foundry_contents, actual_foundry_contents);
assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents);
});

forgesoldeer!(install_dependency_git, |prj, cmd| {
let command = "install";
let dependency = "forge-std~1.8.1";
let git = "[email protected]:mario4582928/Mario.git";

let foundry_file = prj.root().join("foundry.toml");

cmd.arg("soldeer").args([command, dependency, git]);
cmd.execute();

// Making sure the path was created to the dependency and that README.md exists
// meaning that the dependencies were installed correctly
let path_dep_forge = prj.root().join("dependencies").join("forge-std-1.8.1").join("README.md");
assert!(path_dep_forge.exists());

// Making sure the lock contents are the right ones
let path_lock_file = prj.root().join("soldeer.lock");
let lock_contents = r#"
[[dependencies]]
name = "forge-std"
version = "1.8.1"
source = "[email protected]:mario4582928/Mario.git"
checksum = "22868f426bd4dd0e682b5ec5f9bd55507664240c"
"#;

let actual_lock_contents = read_file_to_string(&path_lock_file);
assert_eq!(lock_contents, actual_lock_contents);

// Making sure the foundry contents are the right ones
let foundry_contents = r#"[profile.default]
src = "src"
out = "out"
libs = ["lib"]

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

[dependencies]
forge-std = { version = "1.8.1", git = "[email protected]:mario4582928/Mario.git", rev = "22868f426bd4dd0e682b5ec5f9bd55507664240c" }
"#;

assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents);
});

forgesoldeer!(install_dependency_git_commit, |prj, cmd| {
let command = "install";
let dependency = "forge-std~1.8.1";
let git = "[email protected]:mario4582928/Mario.git";
let rev_flag = "--rev";
let commit = "7a0663eaf7488732f39550be655bad6694974cb3";

let foundry_file = prj.root().join("foundry.toml");

cmd.arg("soldeer").args([command, dependency, git, rev_flag, commit]);
cmd.execute();

// Making sure the path was created to the dependency and that README.md exists
// meaning that the dependencies were installed correctly
let path_dep_forge =
prj.root().join("dependencies").join("forge-std-1.8.1").join("JustATest2.md");
assert!(path_dep_forge.exists());

// Making sure the lock contents are the right ones
let path_lock_file = prj.root().join("soldeer.lock");
let lock_contents = r#"
[[dependencies]]
name = "forge-std"
version = "1.8.1"
source = "[email protected]:mario4582928/Mario.git"
checksum = "7a0663eaf7488732f39550be655bad6694974cb3"
"#;

let actual_lock_contents = read_file_to_string(&path_lock_file);
assert_eq!(lock_contents, actual_lock_contents);

// Making sure the foundry contents are the right ones
let foundry_contents = r#"[profile.default]
src = "src"
out = "out"
libs = ["lib"]

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

[dependencies]
forge-std = { version = "1.8.1", git = "[email protected]:mario4582928/Mario.git", rev = "7a0663eaf7488732f39550be655bad6694974cb3" }
"#;

assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents);
});

forgesoldeer!(update_dependencies, |prj, cmd| {
Expand Down Expand Up @@ -101,8 +189,7 @@ libs = ["lib"]
forge-std = { version = "1.8.1" }
"#;

let actual_foundry_contents = read_file_to_string(&foundry_file);
assert_eq!(foundry_contents, actual_foundry_contents);
assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents);
});

forgesoldeer!(update_dependencies_simple_version, |prj, cmd| {
Expand Down Expand Up @@ -156,8 +243,7 @@ libs = ["lib"]
forge-std = "1.8.1"
"#;

let actual_foundry_contents = read_file_to_string(&foundry_file);
assert_eq!(foundry_contents, actual_foundry_contents);
assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents);
});

forgesoldeer!(login, |prj, cmd| {
Expand Down
Loading