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

feat: support toolchain export #526

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

Conversation

Halimao
Copy link
Contributor

@Halimao Halimao commented Nov 23, 2023

close #322

Support fuelup toolchain export

image

image

image

image

@Halimao
Copy link
Contributor Author

Halimao commented Dec 1, 2023

@sdankel GM sir, looking for your review again😀

Copy link
Member

@sdankel sdankel left a comment

Choose a reason for hiding this comment

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

Thanks for your PR! 🚀

src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
Copy link
Member

@sdankel sdankel left a comment

Choose a reason for hiding this comment

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

Thanks for adding the tests! I left a few more comments, and will test this out next week.

src/commands/toolchain.rs Outdated Show resolved Hide resolved
src/commands/toolchain.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
Copy link
Member

@sdankel sdankel left a comment

Choose a reason for hiding this comment

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

Looking good, left some nits.

src/toolchain_override.rs Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/commands/toolchain.rs Show resolved Hide resolved
src/commands/toolchain.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
@Halimao Halimao requested a review from sdankel January 10, 2024 03:30
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/commands/toolchain.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@Braqzen Braqzen left a comment

Choose a reason for hiding this comment

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

Running toolchain export without any args / options I see the following

1

I would move the message asking for input onto a new line instead of having a single long line.
The default is not automatically exported, it prompts for input.

The invalid channel message comes from a break in backwards compatibility. I haven't followed the changes to know how we manage new toolchains etc. so I'm unsure if this x86 channel is valid but I have updated fuelup and installed beta-4 so I assume that it's still valid.
All that to say, we are forcing a new format, have we considered the current / old format and whether we ought to support that?

Running toolchain export with beta-4 I get a file containing the toolchain and components however when I run latest-YYYY-MM-DD I get the following error

1

We ought to handle the difference between a valid channel that the user can type in ex. the beta-X vs the example formats which include a date (as seen above).

According to the possible argument values I should be able to use latest however when I do that it tells me that it's an invalid channel.

1

Overriding an existing toolchain uses the incorrect toolchain. It ignores my input and uses the default now? When I check the content of the file it has beta-4 so it only prints the incorrect toolchain.

1

@Halimao
Copy link
Contributor Author

Halimao commented Jan 11, 2024

Running toolchain export without any args / options I see the following

1

I would move the message asking for input onto a new line instead of having a single long line. The default is not automatically exported, it prompts for input.

The invalid channel message comes from a break in backwards compatibility. I haven't followed the changes to know how we manage new toolchains etc. so I'm unsure if this x86 channel is valid but I have updated fuelup and installed beta-4 so I assume that it's still valid. All that to say, we are forcing a new format, have we considered the current / old format and whether we ought to support that?

Running toolchain export with beta-4 I get a file containing the toolchain and components however when I run latest-YYYY-MM-DD I get the following error

1

We ought to handle the difference between a valid channel that the user can type in ex. the beta-X vs the example formats which include a date (as seen above).

According to the possible argument values I should be able to use latest however when I do that it tells me that it's an invalid channel.

1

Overriding an existing toolchain uses the incorrect toolchain. It ignores my input and uses the default now? When I check the content of the file it has beta-4 so it only prints the incorrect toolchain.

1

I think this should be discussed with @sdankel first. According to the confusion listed above, it seems that you have mixed up the toolchain name and toolchain channel.


Such as

Running toolchain export without any args / options shows the promotions that ask for a valid channel.

Reference to the comments by @sdankel
This is caused by the default toolchain name you have(latest-x86_64_unknown...) is not a valid channel but a valid toolchain name. When there is no --channel provided, we will use the default toolchain name as the channel, and then check the validation of channel


According to the possible argument values I should be able to use latest however when I do that it tells me that it's an invalid channel.

Just as the help message described, latest is a possible argument value for toolchain name, not the toolchain channel. But for the beta-4, it's not only a valid toolchain name, but also a valid toolchain channel

@Halimao Halimao requested a review from Braqzen January 18, 2024 16:25
Copy link
Contributor

@Braqzen Braqzen left a comment

Choose a reason for hiding this comment

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

I would also split the tests a bit further to group them in order to reduce the cognitive load and make it easier to read.

I would opt for either putting all the success cases at the top and panics at the bottom or consider putting the success cases in a mod success and the panics in a mod panic.

After the tests are split I'll look over test coverage because I haven't exactly checked if all cases are covered

src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
src/ops/fuelup_toolchain/export.rs Outdated Show resolved Hide resolved
@Halimao
Copy link
Contributor Author

Halimao commented Jan 19, 2024

I would also split the tests a bit further to group them in order to reduce the cognitive load and make it easier to read.

I would opt for either putting all the success cases at the top and panics at the bottom or consider putting the success cases in a mod success and the panics in a mod panic.

After the tests are split I'll look over test coverage because I haven't exactly checked if all cases are covered

Addressed!

@sdankel
Copy link
Member

sdankel commented Jan 29, 2024

This produces a file that looks like this:

toolchain = { channel = "beta-3" }
components = { forc = "0.46.1", forc-explore = "0.28.1", forc-tx = "0.46.1", forc-deploy = "0.46.1", forc-wallet = "0.3.0", fuel-core = "0.20.5", forc-run = "0.46.1" }

But we want it formatted like this:

[toolchain]
channel = "beta-3"
    
[components]
forc-wallet = "0.3.0",
forc-deploy = "0.46.1",
forc-run = "0.46.1",
forc-explore = "0.28.1",
forc-tx = "0.46.1",
forc = "0.46.1",
fuel-core = "0.20.5"

@sdankel
Copy link
Member

sdankel commented Jan 30, 2024

I fixed the formatting issue and added tests for it. However I noticed it still pulls the wrong name for the channel by default. When I'm on beta-3, it pulls the full toolchain name rather than the shortened dist name for the channel.

This test should pass:

    #[test]
    #[serial]
    fn test_export_beta3_full() {
        create_settings_file();
        create_toolchain_info();

        export(
            ExportCommand {
                name: None,
                channel: Some("beta-3-x86_64-apple-darwin".to_string()),
                force: true,
            },
            &INPUT_NO[..],
        )
        .expect("should succeed");
        assert_toolchain_info(BETA_3_FILE_CONTENTS);
    }

@Halimao
Copy link
Contributor Author

Halimao commented Jan 30, 2024

This test should pass:

            ExportCommand {
                name: None,
                channel: Some("beta-3-x86_64-apple-darwin".to_string()),
                force: true,
            },
            &INPUT_NO[..],
        )

One of the valid channel should be <latest-YYYY-MM-DD|nightly-YYYY-MM-DD|beta-1|beta-2|beta-3|beta-4>, not sure if this("beta-3-x86_64-apple-darwin" is not a valid channel) is the reason why this test didn't pass?

@sdankel
Copy link
Member

sdankel commented Jan 31, 2024

This test should pass:

            ExportCommand {
                name: None,
                channel: Some("beta-3-x86_64-apple-darwin".to_string()),
                force: true,
            },
            &INPUT_NO[..],
        )

One of the valid channel should be <latest-YYYY-MM-DD|nightly-YYYY-MM-DD|beta-1|beta-2|beta-3|beta-4>, not sure if this("beta-3-x86_64-apple-darwin" is not a valid channel) is the reason why this test didn't pass?

What I'm saying is if I'm on beta-3, the toolchain name is beta-3-x86_64-apple-darwin. If I just run fuelup toolchain export, I expect it to work. Currently it gives me the error that beta-3-x86_64-apple-darwin is not a valid channel. I think this is because of #545

@Halimao
Copy link
Contributor Author

Halimao commented Jan 31, 2024

What I'm saying is if I'm on beta-3, the toolchain name is beta-3-x86_64-apple-darwin. If I just run fuelup toolchain export, I expect it to work. Currently it gives me the error that beta-3-x86_64-apple-darwin is not a valid channel. I think this is because of #545

I'm sorry, but this is expected IMO. As we discussed before, reference to this thread

  1. if no toolchain name is provided(run only fuelup toolchain export), we will use the default toolchain name, in your local env, that's beta-3-x86_64-apple-darwin.
  2. Also, as there is no --channel provided, we will try to use the toolchain name as channel first.
  3. Then check the channel name, it will prompt user "beta-3-x86_64-apple-darwin is not a valid channel, please input a valid one"
  4. If user input beta-3, then this will success as beta-3 is a valid channel, otherwise, abort the process as input channel is invalid
image

@sdankel
Copy link
Member

sdankel commented Feb 2, 2024

if no toolchain name is provided(run only fuelup toolchain export), we will use the default toolchain name, in your local env, that's beta-3-x86_64-apple-darwin.

Yes, and we should parse out beta-3 from the toolchain name using DistToolchainDescription::from_str once #566 lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement enhancement to a current feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: export a toolchain into fuel-toolchain.toml
4 participants