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

Update getting-started.sh to install the specific rust version specified in .github/env file #5317

Open
wants to merge 44 commits into
base: master
Choose a base branch
from

Conversation

Wolfenheimm
Copy link

@Wolfenheimm Wolfenheimm commented Aug 12, 2024

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

  • Currently, there is no such 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.
  • This PR is intended to resolve #5263 and #5335

Checklist

  • My PR includes a detailed description as outlined in the "Description" and its two subsections above.
  • My PR follows the labeling requirements of this project (at minimum one label for T
    required)
    • External contributors: ask maintainers to put the right label on your PR.
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

@cla-bot-2021
Copy link

cla-bot-2021 bot commented Aug 12, 2024

User @Wolfenheimm, please sign the CLA here.

@bkchr bkchr requested a review from kianenigma August 12, 2024 18:35
@bkchr bkchr added the R0-silent Changes should not be mentioned in any release notes label Aug 12, 2024
@Wolfenheimm
Copy link
Author

Wolfenheimm commented Aug 12, 2024

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.

@@ -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`
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

yep, here: #5335

Copy link
Contributor

@kianenigma kianenigma left a 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.

@Wolfenheimm Wolfenheimm requested a review from alvicsam August 15, 2024 23:14
Copy link

Review required! Latest push from author must always be reviewed

@Wolfenheimm
Copy link
Author

@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.

@@ -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`
Copy link
Contributor

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?

Copy link
Author

@Wolfenheimm Wolfenheimm Aug 19, 2024

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.

Copy link
Contributor

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.

Copy link
Author

@Wolfenheimm Wolfenheimm Aug 20, 2024

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.

Copy link
Author

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.

@github-actions github-actions bot requested a review from kianenigma August 19, 2024 17:28
@Wolfenheimm
Copy link
Author

Wolfenheimm commented Oct 10, 2024

image
@alvicsam
Fail on job check-getting-started (arch, archlinux, solochain, sh) I'd like some advice (if possible) on this failure, I'm not certain why it's failing here as local tests using getting-started.sh prove functional, I haven't changed much of anything except that and adding a rust-toolchain.toml.

Digging deeper for the time being, but my initial thoughs are that I suspect it's not selecting an option here?
I'm also hoping that adding the toolchain didn't also cause extra errors.

@Wolfenheimm
Copy link
Author

Wolfenheimm commented Oct 10, 2024

@alvicsam
I'm noticing that the solochain template in the polkadot-sdk project already contains a rust-toolchain.toml inside an env-setup folder here perhaps I'm going about this in the wrong way.

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 setup

Special files for setting up an environment to work with the template:

  • rust-toolchain.toml when working with rustup.
  • flake.nix when working with nix.

These files will be copied by the installer script to the main directory. They are
put into this special directory to not interfere with the normal CI.

Will dig more, but this seems fruitful.

@kianenigma
Copy link
Contributor

@alvicsam I am increasingly thinking that having a rust-toolchain.toml is a great idea. At the moment, if I want to know what versions we use in our CI, and I should expect to work locally, I open a random job (e.g. build-subkey) and inspect a step in the CI process that prints the rust versions. We can do better in this regard :)

@alvicsam
Copy link
Contributor

Sure, I absolutely agree. Please fix the check-getting-started ci check and I'm happy to approve this PR.

@Wolfenheimm Wolfenheimm requested review from a team as code owners October 22, 2024 14:59
@Wolfenheimm
Copy link
Author

Wolfenheimm commented Oct 23, 2024

@alvicsam I need some input & advice on where it's currently failing, the check-getting-started ci checks pass now, but I'm unsure about the zombienet bridges or malus

@ggwpez
Copy link
Member

ggwpez commented Oct 23, 2024

I'm unsure about the zombienet bridges or malus

You can ignore those, they are known to cause issues currently 😄

@ggwpez
Copy link
Member

ggwpez commented Oct 23, 2024

/tip small

Copy link

@Wolfenheimm Contributor did not properly post their account address.

Make sure the pull request description (or user bio) has: "{network} address: {address}".

@Wolfenheimm
Copy link
Author

Wolfenheimm commented Oct 23, 2024

/tip small

@ggwpez I updated my account with my address, greatly appreciated :)

@ggwpez
Copy link
Member

ggwpez commented Oct 23, 2024

/tip small

Copy link

@ggwpez A referendum for a small (20 DOT) tip was successfully submitted for @Wolfenheimm (148p82cCkxEswcmLyQo4jV6kYP3kMRQusWC6B9wPknXMQEH8 on polkadot).

Referendum number: 1253.
tip

Copy link

The referendum has appeared on Polkassembly.

@kianenigma
Copy link
Contributor

Sure, I absolutely agree. Please fix the check-getting-started ci check and I'm happy to approve this PR.

Will our CI use the rust-toolchain.toml file too now?

Copy link
Contributor

@alvicsam alvicsam left a comment

Choose a reason for hiding this comment

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

@Wolfenheimm thanks!

@Wolfenheimm
Copy link
Author

Wolfenheimm commented Nov 2, 2024

@kianenigma @alvicsam

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'm throwing ideas, this is definitely for a later discussion.

I propose that if all goes well and engineering agrees with this PR's change, we open a new issue that touches this topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R0-silent Changes should not be mentioned in any release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Startup script: Use the CI rust version of polkadot-sdk
6 participants