massa
massa copied to clipboard
Define a standard for our scripts
Following a discussion with @sydhds on https://github.com/massalabs/massa/pull/3367 . We thought that we should unify and setup a policy to write our scripts.
I checked how other repositories managed it :
- Rust use shell scripts : https://github.com/rust-lang/rust/blob/master/.github/workflows/ci.yml
- Solana use shell scripts : https://github.com/solana-labs/solana/tree/master/ci
- Near use mainly python scripts : https://github.com/near/nearcore/tree/master/scripts
We used cargo-script one time but they are not used by anyone else because the package isn't maintained since 2017.
@sydhds thinks that Python is a good way to go to keep our scripts cross platform. What do you think @massalabs/core-team ?
I never used it but i think we can replace cargo-script by rust-script (https://crates.io/crates/rust-script). Python is a good way too
If you wanna rustify the scripts, we have rhai.
I never used it but i think we can replace cargo-script by rust-script (https://crates.io/crates/rust-script). Python is a good way too
I don't find any article that make a comparison with pros and cons about rust scripting and usage in CI. Hard to make a choice
If you wanna rustify the scripts, we have rhai.
It's a new scripting language that can be integrated with Rust ? But does it support cloning git repository launching dockers etc ? And why it's better then Rust/Python ?
Problem with rust script is that you need to import some dependencies in order to perform simple task.
As an example in https://github.com/massalabs/massa/blob/main/tools/setup_test.rs, we need:
- clap (argument parsing)
- glob crate (for directory parsing)
- http crate (to download file)
This script could be rewritten in python using only the std lib so I'm in favor of python script here :)
Problem with rust script is that you need to import some dependencies in order to perform simple task.
As an example in https://github.com/massalabs/massa/blob/main/tools/setup_test.rs, we need:
- clap (argument parsing)
- glob crate (for directory parsing)
- http crate (to download file)
This script could be rewritten in python using only the std lib so I'm in favor of python script here :)
@sydhds You can parse arg in rust with standard lib too std::env::args() clap is more friendly user.
For glob and http on the other hand i don’t know a solution with the std library.
Python would be more appropriate for scripting where performance is not needed
@massalabs/core-team last week to share your thoughts before deciding.
In general, I'm leaning towards python scripting if it is suitable for most of our scripts (regarding e.g. performance).
With the caveat that I don't have much history with scripting, here are my two cents :
Whichever way we go, I advocate for having some sort of strongly enforced typing. E.g. what the mypy library promises.
If we go with python, but not with mypy I would at least like to see usage of type-hints enforced by CI.
With that said, a rust-oriented solution would get my vote, if that's on the table.
I hate to say this but I also believe Python scripts are probably our best option, writing them in Rust is way more fun but only brings inconveniences imo.
That said, there will still be a minority of cases where we have no choice but to write them in Rust, for a DB dump script for example, or really anything that would require an object or a behaviour from the node that is too complex or impossible to reproduce in a Python script.
The decision is to write our scripts in Python except for the ones that need to interact with direct modules of our codes and don't have bindings that need to be wrote in Rust.
I let this issue open to remember to change our current script in Rust (unit test) and bash (gas-calibration check) to python.
Discussion is over. Closing.