gaelcolas / Sampler

Module template with build pipeline and examples, including DSC elements.
MIT License
167 stars 42 forks source link

Support ModuleFast #437

Closed johlju closed 11 months ago

johlju commented 1 year ago

Pull Request

Pull Request (PR) description

Added

Task list


This change is Reviewable

codecov[bot] commented 1 year ago

Codecov Report

Merging #437 (6044f34) into main (a14049c) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@         Coverage Diff         @@
##           main   #437   +/-   ##
===================================
  Coverage    81%    81%           
===================================
  Files        44     44           
  Lines      2326   2326           
===================================
  Hits       1906   1906           
  Misses      420    420           
gaelcolas commented 1 year ago

Great idea @johlju thanks! I thin I remember that part of Module fast solution is not using the gallery and instead Justin has some cloudfare shenanigans. It's great for us but maybe not so great for corps environment so we should check and make sure it's documented.

It's a long PR and don't have the time right now, but is it possible to use ResolveDependency.psd1 to set that -UseModuleFast parameter "by default" for the project?

johlju commented 1 year ago

Yes, modules are cached in Cloudflare.

I suggest that ModuleFast shouldn’t be made default in Sampler since there are bugs/restrictions on using ModuleFast. I cannot seem to save individual prerelease modules, and it doesn’t support module versions that are not using semantic versioning (e.g 2.1.0.0). Justin also mentioned it could be breaking changes so we shouldn’t have this as default for that reason too. Also, only works with PowerShell, not Windows PowerShell.

I’m not sure it is possible to use default parameters for scripts (never tried) It works, see next comment. But a user could also just change the pipelines to include UseModuleFast to pass to build.ps1, and pass the parameter in command line.

I had a thought it would be controlled by build.yaml but that is not read in until after dependency has been resolved. Thought it be to big of a change to implement that.

I mostly saw ModuleFast as a time saver during the development process and not that much of a time saver for the CI/CD pipeline.

I suggest we have it opt-in for now and when ModuleFast is more stable we can make it default.

johlju commented 1 year ago

It is possible to set the default value using the following - then it will be picked up by the script even if there are no advanced commands in the scripts.

$PSDefaultParameterValues = @{'*:UseModuleFast' = $true}
johlju commented 1 year ago

@gaelcolas when you review, remove whitespace changes and the PR won't be that big. A lot of code are not needed when using ModuleFast so they are wrapped in if-blocks so there are a lot of indentations.

johlju commented 1 year ago

I forgot that we can use Resolve-Dependency.psd1 to set config values! I will update this PR so that it is possible to toggle ModuleFast on or off by config (and be overridden by parameter).

gaelcolas commented 1 year ago

I've got some time lined up this (long) weekend to look at this.

johlju commented 1 year ago

Awesome! I will be ready to rebase (or make changes if that is required) 😃