-
Notifications
You must be signed in to change notification settings - Fork 780
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
Update getting-started.sh to install the specific rust version specified in .github/env file #5317
base: master
Are you sure you want to change the base?
Update getting-started.sh to install the specific rust version specified in .github/env file #5317
Conversation
… specified in .github/env file
User @Wolfenheimm, please sign the CLA here. |
…sion wasn't found.
…thub.com/Wolfenheimm/polkadot-sdk into wolfenheimm/getting-started-rust-version
Updated the code to include installing the latest version of rust if the required version wasn't found.I've chosen to do a check on the version that is retrieved for an empty string or if the string doesn't contain dots - if the variable passes those constraints, it just defaults to the latest version of rust. My original fix didn't take into account for a bad version fetch. |
scripts/getting-started.sh
Outdated
@@ -114,8 +114,16 @@ if command -v rustc >/dev/null 2>&1; then | |||
echo "\n✅︎🦀 Rust already installed." | |||
else | |||
if prompt_default_yes "\n🦀 Rust is not installed. Install it?"; then | |||
echo "🦀 Installing via rustup." | |||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh | |||
version=`cat ../.github/env | grep IMAGE | cut -d'-' -f3` |
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.
This seems flaky to me, any change to the other file will break this.
I think the nicer thing to do is to store this in a nicely discover-able variable, and have it be used in both places.
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.
I would expect @alvicsam to know if my worry here is real or not, perhaps it is fine.
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.
It's fine as a temporary solution for now, in the future it should be switched to using rust-toolchain.toml
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.
in the future it should be switched to using rust-toolchain.toml
is this tracked in an issue?
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.
yep, here: #5335
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.
LGTM!
Thanks for @alvicsam for chiming in.
Review required! Latest push from author must always be reviewed |
@alvicsam & @kianenigma, sorry for the inconvenience here, I just wanted to keep the branch updated and clear some fails - will refrain from touching it from now on. |
scripts/getting-started.sh
Outdated
@@ -114,8 +114,16 @@ if command -v rustc >/dev/null 2>&1; then | |||
echo "\n✅︎🦀 Rust already installed." | |||
else | |||
if prompt_default_yes "\n🦀 Rust is not installed. Install it?"; then | |||
echo "🦀 Installing via rustup." | |||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh | |||
version=`cat ../.github/env | grep IMAGE | cut -d'-' -f3` |
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.
But also, this won't if you are not in the polkadot sdk repo right? this .github/env
is not available otherwise.
In other words, have you tried the outcome, and does it actually works?
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.
I'm just now noticing that the curl, even if the version is defined, will always grab latest.
It requires something like:
rustup default 1.77.0
I pushed some changes.
Also you are right in that if you run this script from outside the repo, you will not get the required version, and it will default to using latest, tested.
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.
I would argue that 99% of the users running this script are outside of the repo (recall the script is meant to onboard a new user), so I think the solution presented here is really marginally better than not having it.
I think that having a rust-toolchain file is probably the better approach. In that case all devs can inspect this file and adjust their rust versions accordingly. Hopefully IDEs can even automatically warn you about it.
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.
True, and it could create complications if my proposed script (God forbid) finds "1.2.0" and installs + uses that version.
It might then be useful to add the following line to fetch the toml file directly from polkadot-sdk, once it's added in:
curl -s -H "Accept:application/vnd.github.v3.raw" https://api.github.com/repos/paritytech/polkadot-sdk/contents/rust-toolchain.toml | grep 'channel =' | awk -F'"' '{print $2}'
I pushed an example of this.
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.
@kianenigma - After some guidance from Nazar, a decision was made to pull the rust-toolchain.toml
from polkadot-sdk straight into the minimal-template fetched at the end of the script, which should satisfy the requirement. This PR now contains a base toml file with the required version to support this.
Digging deeper for the time being, but my initial thoughs are that I suspect it's not selecting an option here? |
@alvicsam It might be a better idea to have toolchains already set up inside the other templates like solochain does, like that we wouldn't need to add a redundant toolchain file in the root directory of this project. The readme states:Env setupSpecial files for setting up an environment to work with the template:
These files will be copied by the installer script to the main directory. They are
|
@alvicsam I am increasingly thinking that having a |
Sure, I absolutely agree. Please fix the |
@alvicsam I need some input & advice on where it's currently failing, the |
You can ignore those, they are known to cause issues currently 😄 |
/tip small |
@Wolfenheimm Contributor did not properly post their account address. Make sure the pull request description (or user bio) has: "{network} address: {address}". |
@ggwpez I updated my account with my address, greatly appreciated :) |
/tip small |
@ggwpez A referendum for a small (20 DOT) tip was successfully submitted for @Wolfenheimm (148p82cCkxEswcmLyQo4jV6kYP3kMRQusWC6B9wPknXMQEH8 on polkadot). |
The referendum has appeared on Polkassembly. |
Will our CI use the |
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.
@Wolfenheimm thanks!
Additional note after some digging: At a later time, we'll have to think deeper about how this toolchain can be applied to the global scale of the project. This PR mainly affects the template starter projects via the getting-started script. We could have a folder in the root containing a nightly + stable toolchain and use those as the one source of truth, allowing devs/checks/deployments to use them interchangibly according to their need. It would standardize requirements across the board and there would no longer be a need to maintain these settings in the pipelines/project. See: 1, 2, 3, 4. I propose that if all goes well and engineering agrees with this PR's change, we open a new issue that touches this topic. |
Description
Add a means to fetch and install the expected rust version defined in .github/env for the getting-started script, as requested in Issue #5263. Discussions were made and the use of a
rust-toolchain.toml
file was decided.Integration
The implementation relies on fetching the rust-toolchain.toml found within the polkadot-sdk repo.
Review Notes
rust-toolchain.toml
file - but an issue has been made to create one #5335. The file has been added to this PR with basic requirements.Checklist
T
required)