setup-msys2 icon indicating copy to clipboard operation
setup-msys2 copied to clipboard

Save package cache as a post build step

Open jtanx opened this issue 4 years ago • 8 comments

This action is pretty neat, but one thing that would be nice is if saving the package cache could be deferred until after the build is done.

This would be ideal because I have a build script that installs many dependencies (and where it's not really practical to list them out directly in the workflows yml), so it would be nice if it cached those packages too. Not entirely sure if this is possible, although I see actions/cache does it as a post build step.

jtanx avatar Nov 22 '20 09:11 jtanx

Sounds good. https://github.com/actions/cache/blob/0781355a23dac32fd3bac414512f4b903437991a/action.yml#L20

I wonder why it's not practical to list them for you?

lazka avatar Nov 22 '20 09:11 lazka

There's a lot of packages to install, plus I also use the same build script outside of CI for manual invocations, so it would be nice to not have to list out the packages twice but have it work in both cases

jtanx avatar Nov 22 '20 09:11 jtanx

My concern with this request is that I use the resulting MSYS2 environment both for building and for testing a package. Hence, the package is installed before running the tests, but I don't want that to remain in the cache. Also, I don't think it's reasonable to keep uninstalling undesired packages. Therefore, I would propose users defining when to do the caching through an specific step. From a technical point of view, we can distribute two Actions or entrypoints:

  steps:

  - uses: msys2/setup-msys2@v2

  - run: install your deps here

  - run: do something else

  - uses: msys2/setup-msys2/cache@v2

  - run: install things which are not to be kept

  - run: test whatever

eine avatar Nov 22 '20 09:11 eine

There's a lot of packages to install, plus I also use the same build script outside of CI for manual invocations, so it would be nice to not have to list out the packages twice but have it work in both cases

Note that you can define the list of packages in a file and have that file loaded and passed to setup-msys2.

eine avatar Nov 22 '20 09:11 eine

My concern with this request is that I use the resulting MSYS2 environment both for building and for testing a package. Hence, the package is installed before running the tests, but I don't want that to remain in the cache.

Note that only downloads end up in the cache, not things you install. So this is still an issue for our MSYS2 CI where we download random makedepends which we don't want to cache for the next run, but not for a somewhat static sets of tasks.

We could also add an option to tell the action when to save the cache (in the default case the post-action would then just do nothing)

lazka avatar Nov 22 '20 10:11 lazka

Note that you can define the list of packages in a file and have that file loaded and passed to setup-msys2.

That's good to know, I do multiarch builds though (both 32/64 bit), so having the post-build cache is definitely easier.

jtanx avatar Nov 22 '20 12:11 jtanx

This would be very helpful!

txtsd avatar Apr 29 '22 14:04 txtsd

@MehdiChinoune What shell are you running Install prerequisites in? Because it doesn't work for me. Neither like this, nor with shell: msys2 {0}.

txtsd avatar Jun 01 '22 11:06 txtsd