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

Spin watch builds all components when a single component is changed #1417

Open
adamreese opened this issue Apr 21, 2023 · 7 comments · May be fixed by #2478
Open

Spin watch builds all components when a single component is changed #1417

adamreese opened this issue Apr 21, 2023 · 7 comments · May be fixed by #2478
Labels
enhancement New feature or request

Comments

@adamreese
Copy link
Member

if files in foo are changed foo and bar both get rebuilt.

[[component]]
id = "foo"
...
[component.build]
workdir = "foo"
command = "cargo build --target wasm32-wasi --release"
watch = ["src/**/*.rs", "Cargo.toml"]

[[component]]
id = "bar"
[component.build]
workdir = "bar"
command = "cargo build --target wasm32-wasi --release"
watch = ["src/**/*.rs", "Cargo.toml"]
@itowlson
Copy link
Contributor

@calebschoepp This feels like something that could slot nicely in if/when you are separating "artifact" paths from "source code" paths - you could split the source code watches down further to associate component name(s) with them. Though presumably it would also need an entry point into build to build only specific components - I am not sure how you are driving that at the moment.

@itowlson
Copy link
Contributor

reads 3 emails further on and discovers that @calebschoepp has already done that refactor

well maybe next time

@calebschoepp
Copy link
Collaborator

@itowlson this isn't handled in my current refactor (#1418) and is out of scope for it. Buuuuuut, my refactor has laid the foundation to do this much more easily. Something like:

pub enum Effect {
    /// Exit spin watch
    Exit,
    /// Either `spin build` or `spin up` failed to run
    ProcessFailed,
    /// `spin build` has completed running, `spin up` never completes
    ProcessCompleted,
    /// Changes have been made to the application manifest
    ManifestChange,
    /// Changes have been made to the application source code
    SourceChange(component String),
    /// Changes have been made to an application artifact
    ArtifactChange(component String),
    /// A default option that maps to doing nothing
    DoNothing,
}

@dicej dicej added the enhancement New feature or request label May 12, 2023
@itowlson
Copy link
Contributor

Just noting that the single-component entry point into build now exists courtesy of the Spin Doctor.

@itowlson itowlson added the good first issue Good for newcomers label Jul 20, 2023
@itowlson itowlson removed the good first issue Good for newcomers label Apr 29, 2024
@calebschoepp
Copy link
Collaborator

@itowlson is this kind of feature still achievable with your redesign of spin watch or do we just want to close this issue?

@itowlson
Copy link
Contributor

We still want to do it but my refactor definitely introduced exciting new challenges to doing so - see the discussion on #2478. I would leave it open because it is still a nice-to-have feature.

@dimitrilw
Copy link

Ok, so a silly and naive question:
Can't the underlying "compile my stuff to WASM binary" routine just do a quick sanity-check:

Have any files in the component been mod'd since last compilation?

There could be a flag in the config that is False by default, then opt-in via config.

[component name]
only_compile_if_modified = True

Then, the components that are slowest to compile could be toggled to only be recompiled when one of the component's files were mod'd.

[my tinygo component]
# since tinygo is very slow to compile, 
# only compile if a file inside the /my-tinygo-component dir was mod'd since last compile
only_compile_if_modified = True

To track, an artifact could be left in the .spin dir that lists last compile time for flagged components. Whenever the compile routine is called (via build or watch or whatever), then that routine would do a sanity-check for each component prior to rebuilding it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: TODO
Development

Successfully merging a pull request may close this issue.

5 participants