Skip to content
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

Installation of Node and Testnet #2

Merged
merged 8 commits into from Mar 28, 2023
Merged

Conversation

jacderida
Copy link
Contributor

@jacderida jacderida commented Mar 24, 2023

  • 5ea39e2 chore: updates for dealing with new release format

    A new mock response file is provided that represents the new release format, which renames the
    assets and also provides the additional testnet assets.

    The tests were updated for new asset names and version numbers.

  • 361a490 feat: modify shell profile for safe on path

    If not running in elevated mode, the shell profile will be modified to add an extra statement to
    source an env file, in the same manner as rustup operates. Doing it this way makes it easier to
    modify the profile only once.

    Right now this only works for a Bash shell. Cross platform considerations will follow shortly.

  • c46b3b2 feat: support installing specific versions

    In the case where the user supplies a version, we don't need to use the Github API and instead just
    go straight to S3 to download the archive.

  • e56e889 feat: provide node command

    The only real modification required for this was to the env file to also put ~/.safe/node on the
    PATH. Otherwise it goes through identical code paths to the client installation, which has already
    been tested quite thoroughly.

    Strictly speaking, the install_bin function should have test coverage for the node, but as I
    already explained previously, the setup code for these tests is quite involved, so there would be a
    lot of duplication with minimal benefit.

  • 720d981 ci: run some integration tests

    A few integration tests were defined in CI. They were done here because it's just a bit easier to
    use new shell sessions than if they were defined as Rust tests. The tests install a specific version
    of the binaries, which will avoid rate limiting because it doesn't use the Github API. One of the
    tests runs non-elevated, which then uses a new shell session to make sure safe is available, i.e.,
    that the change to the environment variable has been applied. The other test runs in non-elevated
    mode and checks that the binaries are immediately available. On Github Actions, in macOS you can
    only run elevated, so there is no non-elevated test.

    The usage of reqwest was changed to switch off default features, which prevents the openssl
    crate being referenced in the dependency graph. We have this crate denied in our shared cargo deny
    configuration, although I don't know why. The rustls-tls feature then needs to be explicitly
    enabled for using HTTPS.

    Since this was the first time Clippy ran in CI, some flagged issues were fixed.

  • 5158a4c chore: add settings file to keep track of installs

    This will be used in the update command to apply the updates to the locations the binaries were
    installed. We keep track because the user can provide custom locations.

  • 83507c9 chore: vary location of shell profile

    For Linux, we are using ~/.bashrc as the default, whereas for macOS we will use ~/.zshrc, since
    ZSH is the default shell.

  • 1c709fb feat: provide testnet subcommand

    Since this goes through all the same code paths, not much was required other than adding a new entry
    to the AssetType enum.

A new mock response file is provided that represents the new release format, which renames the
assets and also provides the additional testnet assets.

The tests were updated for new asset names and version numbers.
If not running in elevated mode, the shell profile will be modified to add an extra statement to
source an `env` file, in the same manner as `rustup` operates. Doing it this way makes it easier to
modify the profile only once.

Right now this only works for a Bash shell. Cross platform considerations will follow shortly.
In the case where the user supplies a version, we don't need to use the Github API and instead just
go straight to S3 to download the archive.
The only real modification required for this was to the `env` file to also put `~/.safe/node` on the
PATH. Otherwise it goes through identical code paths to the client installation, which has already
been tested quite thoroughly.

Strictly speaking, the `install_bin` function should have test coverage for the node, but as I
already explained previously, the setup code for these tests is quite involved, so there would be a
lot of duplication with minimal benefit.
@jacderida jacderida force-pushed the install-node branch 16 times, most recently from c77dbdb to 5f3c384 Compare March 26, 2023 17:40
A few integration tests were defined in CI. They were done here because it's just a bit easier to
use new shell sessions than if they were defined as Rust tests. The tests install a specific version
of the binaries, which will avoid rate limiting because it doesn't use the Github API. One of the
tests runs non-elevated, which then uses a new shell session to make sure safe is available, i.e.,
that the change to the environment variable has been applied. The other test runs in non-elevated
mode and checks that the binaries are immediately available. On Github Actions, in macOS you can
only run elevated, so there is no non-elevated test.

The usage of `reqwest` was changed to switch off default features, which prevents the `openssl`
crate being referenced in the dependency graph. We have this crate denied in our shared `cargo deny`
configuration, although I don't know why. The `rustls-tls` feature then needs to be explicitly
enabled for using HTTPS.

Since this was the first time Clippy ran in CI, some flagged issues were fixed.
This will be used in the `update` command to apply the updates to the locations the binaries were
installed. We keep track because the user can provide custom locations.
For Linux, we are using ~/.bashrc as the default, whereas for macOS we will use ~/.zshrc, since
ZSH is the default shell.
@jacderida jacderida force-pushed the install-node branch 7 times, most recently from e3e4552 to e8a69ba Compare March 27, 2023 21:30
Since this goes through all the same code paths, not much was required other than adding a new entry
to the `AssetType` enum.
@jacderida jacderida changed the title WIP - Installation of Node Installation of Node and Testnet Mar 27, 2023
version,
no_modify_shell_profile,
)
.await
}
None => {
println!("interactive gui");
Ok(())
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small suggestion, but can we maybe print the help screen if no args were passed? https://docs.rs/clap/latest/clap/struct.Command.html#method.print_help

Copy link
Contributor Author

@jacderida jacderida Mar 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Roland, thanks for the feedback. My plan was that if no arguments were passed, we would run an interactive GUI, which is what rustup does too. Well, sorry, just to clarify, it's not a GUI, I guess, but a TUI.

Do you think that's not worth doing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see! That would be pretty useful to the non-tech people I assume. But I'm not so sure, they will again be exposed to the techy CLIs of safenode/safe/testnet after using this tool.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, to be honest, the value of it may be quite low. I might ask this question on the forum.

Copy link
Member

@RolandSherwin RolandSherwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Also tried out the commands both with privileged access and without it, and it seems to work as intended on Ubuntu!

@jacderida jacderida merged commit a814276 into maidsafe:main Mar 28, 2023
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants