Keep plugin artifacts / environments across cleanups for faster iteration?

Question

Is it possible to re-use plugin artifacts across build runs of a given snap part, but re-pull the latest version of my part’s source? For example, keep the ruby/node runtime built during the part’s pull step by the corresponding plugin, but re-build the ruby/JS app from the latest codebase using the existing runtime. I could of course add said runtime as a part of its own and specify before/after chains, but that way I loose all the bells and whistles of plugins :slight_smile: A second, related question: Two parts of my snap use the same nodejs version, so each part downloads & builds its own Node version (which then gets thrown away because I just need the resulting JS bundle). Is it possible to re-use the plugin runtime across parts?

Problem description / use case

My snap bundles several script language applications, each defined as a part with a plugin (two JavaScript singlepage applications and a Ruby-on-Rails backend). While iterating over the codebase of each part, I have to test certain functionality from within the snap. To get the latest app code in a new snap revision, I have to clean the part from the pull step onward and rebuild it (snapcraft clean my-part -s pull but pull is the first step anyway … so snapcraft clean my-part :slight_smile: ). Cleaning a part’s pull step also removes the runtime built by the plugin, so each rebuild also downloads and builds the required ruby/nodejs version from scratch. This is especially time-consuming on the ARM devices for which the snap is intended (and the ruby plugin does not support cross-compilation atm).

1 Like

Is the source a remote source, e.g. a git repo or tarball online? Or is it local (e.g. source: src/)?

The source for all three parts is a publicly available git repo.

Is there a way to keep build parts that didn’t change and build just updated part?

I have snap that keeps forcing me to clean parts until I give up and clean whole project.

The source for all three parts is a publicly available git repo.

Then sadly, no, at least not at this time. The pull step is when plugins both fetch whatever they require (e.g. ruby or node) as well as the source code specified in source. As a result, the only way to get snapcraft to pull again (to get updates in a remote source) is to clean the pull step and run it again. Snapcraft does not currently have a way to say “clean this part except for the stuff that the plugin fetched on its own”.

A second, related question: Two parts of my snap use the same nodejs version, so each part downloads & builds its own Node version (which then gets thrown away because I just need the resulting JS bundle). Is it possible to re-use the plugin runtime across parts?

I realized I missed this question initially: no, parts are meant to be independent/isolated. They could be using completely different versions of node, for example.

Is there a way to keep build parts that didn’t change and build just updated part?

@pekof this blog post might help.