Catesta icon indicating copy to clipboard operation
Catesta copied to clipboard

Add module dependency support

Open TsekNet opened this issue 3 years ago • 4 comments

Description

As part of getting started with Catesta, I had to dig through the code base to find where to import the module dependencies for my PowerShell module. I found the actions_bootstrap.ps1 file, and determined that I needed to add my module imports there.

For additional context, I was not able to initially start using Catesta until I added my module imports to the actions_bootstrap.ps1 script, as my tests were failing due to missing module dependencies.

I noticed a note in the build.ps1 script about dependency installation not being included, but was not able to find further documentation on that comment.

See this failed action for an example of the error I ran into, and this commit for how I resolved this issue.

Describe the solution you'd like

Ideally, during setup, Catesta would have an additional prompt that asks you which modules you would like to install as dependencies. This should add the required modules to the module manifest and the appropriate workflow script.

Describe any alternatives you've considered

Alternatively, update/add documentation on how to avoid this issue for users getting started with Catesta.

Additional context

Example broken action run: https://github.com/TsekNet/TsekProfile/runs/1078982174?check_suite_focus=true Fixed issue in my repo: https://github.com/TsekNet/TsekProfile/commit/2257337bdff4434967fc9646a729cda717b196e0

TsekNet avatar Sep 07 '20 17:09 TsekNet

For now, I've elected to address this via additional documentation.

I recognize that overall, module dependency is something that could stand to be improved.

I have not settled on something beyond ensuring that required modules are added to the bootstrap file. Solutions like PSDepend or PSRequire seem overly clunky for solving this which is what other module generator solutions tend to lean on.

I am open to discussion on ideas for longer term improvements.

techthoughts2 avatar Sep 08 '20 15:09 techthoughts2

Did a quick PoC of using PSDepend with Catesta this morning. I haven't used PSDepend before, but I don't see it being a clunky solution. I found PSDepend to be extensible and simple. Open to discussing why/if there's any hesitance to use PSDepend.

Artifacts:

TsekNet avatar Sep 09 '20 14:09 TsekNet

Adding that what was missing from the solution above was local dependency support. I've added this in my latest commit, linked below:

https://github.com/TsekNet/TsekProfile/commit/d3762dcdf70d7bef80fffe257de768e5981832fd#diff-e7215d569c39029991758de0706d2dcc (starting on like 269)

TsekNet avatar Sep 10 '20 14:09 TsekNet

For GitHub actions specifically, seeing this an option: https://github.com/marketplace/actions/powershell-module-cache

TsekNet avatar Oct 07 '20 19:10 TsekNet