Skip to content

Commit

Permalink
chore: remove testnet command
Browse files Browse the repository at this point in the history
We have removed support for the `testnet` binary, so it no longer applies and is hence being
removed.

Also upgrades `sn-releases` to the latest version, which uses the crates.io API to get the latest
version of a crate.

BREAKING CHANGE: properties have been removed from the `Settings` struct, meaning settings files
from previous versions will be incompatible with this new version.
  • Loading branch information
jacderida authored and joshuef committed Feb 6, 2024
1 parent 44e0456 commit 70a42d3
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 164 deletions.
42 changes: 0 additions & 42 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ env:
CLIENT_VERSION: 0.77.27
NODE_VERSION: 0.83.25
NODE_MANAGER_VERSION: 0.1.8
TESTNET_VERSION: 0.1.29

jobs:
# The code in this crate uses lots of conditional compilation for cross-platform capabilities.
Expand Down Expand Up @@ -142,7 +141,6 @@ jobs:
cargo run -- client --version $env:CLIENT_VERSION
cargo run -- node --version $env:NODE_VERSION
cargo run -- node-manager --version $env:NODE_MANAGER_VERSION
cargo run -- testnet --version $env:TESTNET_VERSION
- name: Check if binaries are available in new shell session
shell: pwsh
run: |
Expand All @@ -158,10 +156,6 @@ jobs:
Write-Host "safenode-manager.exe does not exist"
exit 1
}
if (!(Test-Path "$env:USERPROFILE\safe\testnet.exe")) {
Write-Host "testnet.exe does not exist"
exit 1
}
# For security reasons, the GHA infrastructure prevents environment variables
# being modified easily, so we need to refer to the binaries with their full paths.
Expand Down Expand Up @@ -203,18 +197,6 @@ jobs:
exit 1
}
$output = & "${env:USERPROFILE}\safe\testnet.exe" --version
$version = $output | Select-String -Pattern "testnet (\d+\.\d+\.\d+)"
$versionNumber = $version.Matches.Groups[1].Value
if ($versionNumber -eq "$env:TESTNET_VERSION") {
Write-Host "The correct version of testnet has been installed"
} else {
Write-Host "The correct version of testnet has not been installed"
Write-Host "We expected version $env:TESTNET_VERSION"
Write-Host "The downloaded binary has $versionNumber"
exit 1
}
test-install-linux:
if: "!startsWith(github.event.pull_request.title, 'Automated version bump')"
name: Install test (Linux)
Expand All @@ -232,7 +214,6 @@ jobs:
cargo run -- client --version $CLIENT_VERSION
cargo run -- node --version $NODE_VERSION
cargo run -- node-manager --version $NODE_MANAGER_VERSION
cargo run -- testnet --version $TESTNET_VERSION
- name: Check if binaries are available in new shell session
shell: bash
run: |
Expand All @@ -248,7 +229,6 @@ jobs:
[[ -f "$HOME/.local/bin/safe" ]] || { echo "safe not in expected location"; exit 1; }
[[ -f "$HOME/.local/bin/safenode" ]] || { echo "safenode not in expected location"; exit 1; }
[[ -f "$HOME/.local/bin/safenode-manager" ]] || { echo "safenode-manager not in expected location"; exit 1; }
[[ -f "$HOME/.local/bin/testnet" ]] || { echo "testnet not in expected location"; exit 1; }
version=$(safe --version | awk '{ print $2 }')
if [[ "$version" == "$CLIENT_VERSION" ]]; then
Expand Down Expand Up @@ -280,16 +260,6 @@ jobs:
exit 1
fi
version=$(testnet --version | awk '{ print $2 }')
if [[ "$version" == "$TESTNET_VERSION" ]]; then
echo "The correct version of testnet has been installed"
else
echo "The correct version of testnet has not been installed"
echo "We expected $TESTNET_VERSION"
echo "The downloaded binary has $version"
exit 1
fi
test-install-macos:
if: "!startsWith(github.event.pull_request.title, 'Automated version bump')"
name: Install test (macOS)
Expand All @@ -306,7 +276,6 @@ jobs:
cargo run -- client --version $CLIENT_VERSION
cargo run -- node --version $NODE_VERSION
cargo run -- node-manager --version $NODE_MANAGER_VERSION
cargo run -- testnet --version $TESTNET_VERSION
- name: Check if binaries are available in new shell session
run: |
# As with the Ubuntu test, we need to source the env file to get the binaries on PATH.
Expand All @@ -315,7 +284,6 @@ jobs:
[[ -f "$HOME/.local/bin/safe" ]] || { echo "safe not in expected location"; exit 1; }
[[ -f "$HOME/.local/bin/safenode" ]] || { echo "safenode not in expected location"; exit 1; }
[[ -f "$HOME/.local/bin/safenode-manager" ]] || { echo "safenode-manager not in expected location"; exit 1; }
[[ -f "$HOME/.local/bin/testnet" ]] || { echo "testnet not in expected location"; exit 1; }
version=$(safe --version | awk '{ print $2 }')
if [[ "$version" == "$CLIENT_VERSION" ]]; then
Expand Down Expand Up @@ -347,16 +315,6 @@ jobs:
exit 1
fi
version=$(testnet --version | awk '{ print $2 }')
if [[ "$version" == "$TESTNET_VERSION" ]]; then
echo "The correct version of testnet has been installed"
else
echo "The correct version of testnet has not been installed"
echo "We expected $TESTNET_VERSION"
echo "The downloaded binary has $version"
exit 1
fi
test-publish:
if: "!startsWith(github.event.pull_request.title, 'Automated version bump')"
name: Test Publish
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ semver = "1.0.4"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
sn-releases = "0.1.5"
sn-releases = "0.1.7"
tempfile = "3.8.1"
textwrap = "0.16.0"
tokio = { version = "1.26", features = ["full"] }
Expand Down
8 changes: 2 additions & 6 deletions src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ lazy_static! {
"https://sn-node.s3.eu-west-2.amazonaws.com",
);
m.insert(
AssetType::Testnet,
"https://sn-testnet.s3.eu-west-2.amazonaws.com",
AssetType::NodeManager,
"https://sn-node-manager.s3.eu-west-2.amazonaws.com",
);
m
};
Expand Down Expand Up @@ -176,10 +176,6 @@ async fn do_install_binary(
settings.safenode_manager_path = bin_path;
settings.safenode_manager_version = installed_version;
}
AssetType::Testnet => {
settings.testnet_path = bin_path;
settings.testnet_version = installed_version;
}
}
settings.save(&settings_file_path)?;

Expand Down
37 changes: 2 additions & 35 deletions src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,18 @@ pub enum AssetType {
Client,
Node,
NodeManager,
Testnet,
}

impl AssetType {
pub fn variants() -> Vec<AssetType> {
vec![
AssetType::Client,
AssetType::Node,
AssetType::NodeManager,
AssetType::Testnet,
]
vec![AssetType::Client, AssetType::Node, AssetType::NodeManager]
}

pub fn get_release_type(&self) -> ReleaseType {
match self {
AssetType::Client => ReleaseType::Safe,
AssetType::Node => ReleaseType::Safenode,
AssetType::NodeManager => ReleaseType::SafenodeManager,
AssetType::Testnet => ReleaseType::Testnet,
}
}
}
Expand All @@ -79,7 +72,6 @@ impl std::fmt::Display for AssetType {
AssetType::Client => write!(f, "safe"),
AssetType::Node => write!(f, "safenode"),
AssetType::NodeManager => write!(f, "safenode-manager"),
AssetType::Testnet => write!(f, "testnet"),
}
}
}
Expand All @@ -92,8 +84,6 @@ pub struct Settings {
pub safenode_version: String,
pub safenode_manager_path: PathBuf,
pub safenode_manager_version: String,
pub testnet_path: PathBuf,
pub testnet_version: String,
}

impl Settings {
Expand All @@ -108,8 +98,6 @@ impl Settings {
safenode_version: String::new(),
safenode_manager_path: PathBuf::new(),
safenode_manager_version: String::new(),
testnet_path: PathBuf::new(),
testnet_version: String::new(),
})
} else {
Settings {
Expand All @@ -119,8 +107,6 @@ impl Settings {
safenode_version: String::new(),
safenode_manager_path: PathBuf::new(),
safenode_manager_version: String::new(),
testnet_path: PathBuf::new(),
testnet_version: String::new(),
}
};
Ok(settings)
Expand All @@ -131,7 +117,6 @@ impl Settings {
AssetType::Client => self.safe_version.clone(),
AssetType::Node => self.safenode_version.clone(),
AssetType::NodeManager => self.safenode_manager_version.clone(),
AssetType::Testnet => self.testnet_version.clone(),
}
}

Expand All @@ -140,7 +125,6 @@ impl Settings {
AssetType::Client => !self.safe_version.is_empty(),
AssetType::Node => !self.safenode_version.is_empty(),
AssetType::NodeManager => !self.safenode_manager_version.is_empty(),
AssetType::Testnet => !self.testnet_version.is_empty(),
}
}

Expand All @@ -149,7 +133,6 @@ impl Settings {
AssetType::Client => self.safe_path.clone(),
AssetType::Node => self.safenode_path.clone(),
AssetType::NodeManager => self.safenode_manager_path.clone(),
AssetType::Testnet => self.testnet_path.clone(),
}
}

Expand Down Expand Up @@ -359,7 +342,6 @@ fn get_bin_name(asset_type: &AssetType) -> String {
AssetType::Client => "safe".to_string(),
AssetType::Node => "safenode".to_string(),
AssetType::NodeManager => "safenode-manager".to_string(),
AssetType::Testnet => "testnet".to_string(),
};
if OS == "windows" {
bin_name.push_str(".exe");
Expand Down Expand Up @@ -733,8 +715,6 @@ mod test {
safenode_version: "v0.75.2".to_string(),
safenode_manager_path: safenode_manager_bin_file.to_path_buf(),
safenode_manager_version: "v0.1.8".to_string(),
testnet_path: testnet_bin_file.to_path_buf(),
testnet_version: "v0.75.3".to_string(),
};

settings.save(&settings_file.to_path_buf())?;
Expand All @@ -750,8 +730,6 @@ mod test {
safenode_manager_bin_file.to_path_buf()
);
assert_eq!(settings.safenode_manager_version, "v0.1.8");
assert_eq!(settings.testnet_path, testnet_bin_file.to_path_buf());
assert_eq!(settings.testnet_version, "v0.75.3");
Ok(())
}

Expand Down Expand Up @@ -780,8 +758,6 @@ mod test {
safenode_version: "v0.75.2".to_string(),
safenode_manager_path: safenode_manager_bin_file.to_path_buf(),
safenode_manager_version: "v0.1.8".to_string(),
testnet_path: testnet_bin_file.to_path_buf(),
testnet_version: "v0.75.3".to_string(),
};

settings.save(&settings_file.to_path_buf())?;
Expand All @@ -797,8 +773,6 @@ mod test {
safenode_manager_bin_file.to_path_buf()
);
assert_eq!(settings.safenode_manager_version, "v0.1.8");
assert_eq!(settings.testnet_path, testnet_bin_file.to_path_buf());
assert_eq!(settings.testnet_version, "v0.75.3");
Ok(())
}

Expand All @@ -814,9 +788,7 @@ mod test {
"safenode_path": "/home/chris/.local/bin/safenode",
"safenode_version": "v0.75.2",
"safenode_manager_path": "/home/chris/.local/bin/safenode-manager",
"safenode_manager_version": "v0.1.8",
"testnet_path": "/home/chris/.local/bin/testnet",
"testnet_version": "v0.75.3"
"safenode_manager_version": "v0.1.8"
}
"#,
)?;
Expand All @@ -840,11 +812,6 @@ mod test {
PathBuf::from("/home/chris/.local/bin/safenode-manager")
);
assert_eq!(settings.safenode_manager_version, "v0.1.8");
assert_eq!(
settings.testnet_path,
PathBuf::from("/home/chris/.local/bin/testnet")
);
assert_eq!(settings.testnet_version, "v0.75.3");
Ok(())
}
}
37 changes: 0 additions & 37 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,30 +101,6 @@ enum Commands {
#[arg(short = 'v', long)]
version: Option<String>,
},
/// Install the testnet binary.
///
/// The location is platform specific:
/// - Linux/macOS: $HOME/.local/bin
/// - Windows: C:\Users\<username>\safe
///
/// On Linux/macOS, the Bash shell profile will be modified to add $HOME/.local/bin to the PATH
/// variable. On Windows, the user Path variable will be modified to add C:\Users\<username>\safe.
#[clap(verbatim_doc_comment)]
Testnet {
/// Override the default installation path.
///
/// Any directories that don't exist will be created.
#[arg(short = 'p', long, value_name = "DIRECTORY")]
path: Option<PathBuf>,

/// Disable modification of the shell profile.
#[arg(short = 'n', long)]
no_modify_shell_profile: bool,

/// Install a specific version rather than the latest.
#[arg(short = 'v', long)]
version: Option<String>,
},
/// Update installed components.
#[clap(verbatim_doc_comment)]
Update {},
Expand Down Expand Up @@ -182,19 +158,6 @@ async fn main() -> Result<()> {
)
.await
}
Some(Commands::Testnet {
path,
no_modify_shell_profile,
version,
}) => {
println!("**************************************");
println!("* *");
println!("* Installing testnet *");
println!("* *");
println!("**************************************");
install::check_prerequisites()?;
process_install_cmd(AssetType::Testnet, path, version, no_modify_shell_profile).await
}
Some(Commands::Update {}) => {
println!("**************************************");
println!("* *");
Expand Down

0 comments on commit 70a42d3

Please sign in to comment.