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

add a subcommand to clean all artifacts created by snfoundry #2723

Open
amanusk opened this issue Nov 27, 2024 · 11 comments · May be fixed by #2882
Open

add a subcommand to clean all artifacts created by snfoundry #2723

amanusk opened this issue Nov 27, 2024 · 11 comments · May be fixed by #2882
Assignees
Labels
feature New feature request/description good first issue Good for newcomers odboost: Hard ODBoost snforge

Comments

@amanusk
Copy link
Contributor

amanusk commented Nov 27, 2024

Which component is your feature related to?

Forge

Feature Request

The snforge tool can generate a significant number of files when utilized to its fullest potential, including:

  • snfoundry_trace
  • .snfoundry_cache
  • coverage
  • profile

To help manage these files, we propose a snforge clean command that facilitates their removal.


Command Design

snforge clean <CLEAN_COMPONENTS>... [possible values: coverage, profile, cache, trace, all]

To clean everything, you can use:

snforge clean all

To clean only the cache, run:

snforge clean cache

You can also specify multiple components at once:

snforge clean profile coverage

Note: The existing snforge clean-cache command should be deprecated in favor of the more flexible snforge clean cache.


Implementation Details

This is how you can implement the desired CLI using the clap crate:

#[derive(Parser, Debug)]
pub struct CleanArgs {
    #[arg(num_args = 1.., required = true)]
    pub clean_components: Vec<CleanComponent>,
}

#[derive(ValueEnum, Debug, Clone)]
pub enum CleanComponent {
    Coverage,
    Profile,
    Cache,
    Trace,
    All,
}

To comply with the current command conventions, you should add this branch to the match statement at this line:

ForgeSubcommand::Clean { args } => {
    clean::clean(args)?;
    Ok(ExitStatus::Success)
}

Next, create a clean.rs file in the forge/src directory to implement the cleaning logic. To handle directory traversal, you can use the WalkDir crate.

Definition of done:

  • clean command is added and working as in design
  • snforge clean-cache is deprecated
  • there are tests to make sure the changes are working
@github-actions github-actions bot added the new label Nov 27, 2024
@cptartur cptartur added snforge feature New feature request/description and removed new labels Jan 17, 2025
@cptartur cptartur moved this from New to Triage in Starknet foundry Jan 17, 2025
@cptartur
Copy link
Member

There's already snforge clean-cache and scarb has scarb clean so it's an issue of cleaning files from other tools like coverage.

@ksew1 ksew1 added the ODBoost label Jan 17, 2025
@cptartur cptartur moved this from Triage to Backlog in Starknet foundry Jan 17, 2025
@ksew1
Copy link
Collaborator

ksew1 commented Jan 20, 2025

You also have cairo-coverage clean.

@ksew1
Copy link
Collaborator

ksew1 commented Jan 20, 2025

We already have clean-cache, so instead of implementing clean-all, I would propose creating a command with the following interface:

snforge clean <CLEAN_COMPONENTS>... [possible values: coverage, profile, cache, all]

To clean everything, you would simply run:

snforge clean all

To clean only the cache:

snforge clean cache

You can also specify multiple components at once:

snforge clean profile coverage

This is also straightforward to implement using clap:

#[derive(Parser, Debug)]
pub struct CleanArgs {
    #[arg(num_args = 1.., required = true)]
    pub clean_components: Vec<CleanComponent>,
}

#[derive(ValueEnum, Debug, Clone)]
pub enum CleanComponent {
    Coverage,
    Profile,
    Cache,
    All,
}

@pheobeayo
Copy link

I'd love to work on this!
I am a Web3 front-end developer skilled in technical documentation and software development. I greatly understand technologies like JavaScript, Typescript, Cairo, Rust and Solidity. I have contributed successfully to open-source projects like Stark Quest, Bandada and Speedrun scaffold-stark
My Approach includes:

  • Implementation of the the clean command as required.
    -make sure the tests are working based on the design.
  • Create a Pull Request (PR).
  • Request for a Review.
  • Make changes based on the PR review.

@ksew1
Copy link
Collaborator

ksew1 commented Jan 21, 2025

Hey, this issue will be available for taking during the ODBoost https://app.onlydust.com/hackathons/odboost-1.
If you are still interested in tacking on this one, please apply after the ODBoost start tomorrow after 3 PM CET.

@olisaagbafor
Copy link

Is this issue still available?

1 similar comment
@hoangkianh
Copy link

Is this issue still available?

@Nemezjusz
Copy link
Contributor

Hi, I'd love to take this task!
I already work with starknet-foundry a few times during previous hackathons and i think this would great issue to dive deep into :)

@khayss
Copy link
Contributor

khayss commented Jan 22, 2025

May I take this issue on?

@cptartur
Copy link
Member

Hey @Nemezjusz what's the status of this? Do you have any kind of draft you can publish already?

@Nemezjusz
Copy link
Contributor

Hey, @cptartur, still working on tests and dir locations but i can make draft and see what you think

@Nemezjusz Nemezjusz linked a pull request Jan 27, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request/description good first issue Good for newcomers odboost: Hard ODBoost snforge
Projects
Status: Backlog
Development

Successfully merging a pull request may close this issue.

8 participants