potatoqualitee / psmodulecache

This action makes caching PowerShell modules from the PowerShell Gallery easy for Linux, Windows and macOS runners.
MIT License
31 stars 12 forks source link

Dependent modules no longer cached (v5.1 onwards) #50

Closed christianacca closed 1 year ago

christianacca commented 1 year ago

As of version 5.1, it appears only those modules directly referenced in the modules-to-cache list are cached, the module dependencies are no longer cached.

This was not the case with v4.5 which cached not only the modules listed in modules-to-cache, but also the dependencies of those modules.

Take the following usage of v4.5:

      - name: 'Install dependent powershell modules'
        uses: potatoqualitee/psmodulecache@v4.5
        with:
          modules-to-cache: Az:9.3.0,SqlServer:22.0.59

The above produces a cache that I believe includes the dependencies of the Az module (eg Az.Accounts). Note the size of the cache:

image

On a subsequent execution of the workflow that includes the caching step, the cache is resolved and the workflow is able to import the powershell modules that it needs.

Take the following usage of v5.3:

      - name: 'Install dependent powershell modules'
        uses: potatoqualitee/psmodulecache@03c44cade706c982e0632f52a2712668b03c8f24 # <- 5.3
        with:
          modules-to-cache: Az:9.3.0,SqlServer:22.0.59

The above produces a cache that I believe does NOT include the dependencies of the Az module (eg Az.Accounts). Note the size of the cache which is much smaller than the same cache when using v4.5:

image

On a subsequent execution of the workflow that includes the caching step, the cache is resolved but the workflow fails to import one of the dependent powershell modules that it needs (see below screenshot). The ONLY difference between the example above and this example, is the version of potatoqualitee/psmodulecache

image
LaurentDardenne commented 1 year ago

Hello, indeed the original version implicitly saved dependencies and fetched modules from a single repository. Version 5.0 tests did not cover this scenario and this version now allows searching in multiple repositories which causes some issues in some scenarios. I plan to correct this defect this month.

LaurentDardenne commented 1 year ago

Hi, as I took the time to study the different cases, I think fixing the management of dependencies this month. Sorry for the delay.

christianacca commented 1 year ago

Awesome thanks 😊

On Fri, 2 Jun 2023, 14:13 Laurent Dardenne, @.***> wrote:

Hi, as I took the time to study the different cases, I think fixing the management of dependencies this month. Sorry for the delay.

— Reply to this email directly, view it on GitHub https://github.com/potatoqualitee/psmodulecache/issues/50#issuecomment-1573715926, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGYOPXD5FZP75QQEPTLKZ3XJHRIHANCNFSM6AAAAAAXR5R2Y4 . You are receiving this because you authored the thread.Message ID: @.***>

LaurentDardenne commented 1 year ago

I didn't forget, sorry for the wait.

I think fixing the management of dependencies this mont

Happy day scenario ;-)

LaurentDardenne commented 1 year ago

The result with the next version (macOS) :

image

image

If a module and its requested version is already installed in the runner, we save it on disk and in the cache. Restoring the cache may therefore have generated warnings in the logs.

A module can be delivered in each runner but its version can be different. Each new version of a runner can upgrade the 'Az' module. An object cache is used by n runners of different OS. The 'standard GitHub-hosted runner' only contains stable versions of a module.

So if your code uses a specific version of the AZ module this involves using -Requiredversion when calling Import-Module.

Finally, the Module 'AZ' has dependencies using the same module (Az.Accounts) but with different versions. In this case Find-module -IncludeDependencies returns this module several times.

christianacca commented 11 months ago

Works like a charm. Thank you very much

On Mon, 6 Nov 2023, 10:39 Laurent Dardenne, @.***> wrote:

Closed #50 https://github.com/potatoqualitee/psmodulecache/issues/50 as completed via d307360 https://github.com/potatoqualitee/psmodulecache/commit/d307360c9ba807f31c8315e35f14efe79fddd8a2 .

— Reply to this email directly, view it on GitHub https://github.com/potatoqualitee/psmodulecache/issues/50#event-10870902777, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGYOPWPUQWZQZHLXUQJE4LYDC44VAVCNFSM6AAAAAAXR5R2Y6VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJQHA3TAOJQGI3TONY . You are receiving this because you authored the thread.Message ID: @.***>