gaelcolas / Sampler

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

Task `Set_PSModulePath`: Expanding `PSModulePath` #463

Closed raandree closed 2 months ago

raandree commented 9 months ago

Pull Request

Pull Request (PR) description

So far the PSModulePath configured in the build.yml was a static value. Do make it more flexible, the PSModulePath is not expanded.

SetPSModulePath:
  PSModulePath: $([System.Environment]::GetFolderPath('MyDocuments'))\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;c:\Users\Install\.vscode\extensions\ms-vscode.powershell-2022.5.1\modules;
  #RemovePersonal: false
  #RemoveProgramFiles: false
  #RemoveWindows: false

Changed

Task list


This change is Reviewable

codecov[bot] commented 9 months ago

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 81%. Comparing base (e669ffa) to head (32c31f7). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.build/tasks/SetPsModulePath.build.ps1 50% 1 Missing :warning:
Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/gaelcolas/Sampler/pull/463/graphs/tree.svg?width=650&height=150&src=pr&token=xHbQB1FHYN&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Gael)](https://app.codecov.io/gh/gaelcolas/Sampler/pull/463?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Gael) ```diff @@ Coverage Diff @@ ## main #463 +/- ## =================================== - Coverage 81% 81% -1% =================================== Files 44 44 Lines 2328 2330 +2 =================================== + Hits 1904 1905 +1 - Misses 424 425 +1 ``` | [Files with missing lines](https://app.codecov.io/gh/gaelcolas/Sampler/pull/463?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Gael) | Coverage Δ | | |---|---|---| | [.build/tasks/SetPsModulePath.build.ps1](https://app.codecov.io/gh/gaelcolas/Sampler/pull/463?src=pr&el=tree&filepath=.build%2Ftasks%2FSetPsModulePath.build.ps1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Gael#diff-LmJ1aWxkL3Rhc2tzL1NldFBzTW9kdWxlUGF0aC5idWlsZC5wczE=) | `72% <50%> (-3%)` | :arrow_down: |
raandree commented 9 months ago

@johlju, @gaelcolas, do you have any idea why this isn't working. When building on a Windows Server 2022 build agent, it runs fine.

johlju commented 9 months ago

It uses PSResurceGet now in the pipeline. Maybe something changed on the build workers so it started to fail now. I will dig into it this weekend. For now you can switch off PSResurceGet by setting it to false in Resolve-Dependecies.psd1. Hopefully the build passes then.

raandree commented 9 months ago

Thanks, @johlju. But, when following your advice and disabling PSResourceGet in a PR, we would disable it for the main branch as well. I guess this is not what you want, right?

johlju commented 9 months ago

If this is a problem with PSResourceGet then I think we need to turn it off temporarily until I can investigate why it's happening. But please first try to enable the use of the compatibility module in the Resolve-Dependency.psd1 if it is not already enabled.

I think build workers was updated to PS 7.4.1 recently. PSResourceGet was included in that apparently. So maybe there is an issue with the PowerShellGet compatibility module not being included in PS 7.4.1 or download as part of the pipeline (there is a setting for that too), or a bug in the PowerShellGet compatibility module. We might need to refactor all tasks that use PowerShellGet commands to instead use PSResourceGet commands when available. Then we don't rely on the compatibility module.

johlju commented 9 months ago

But please first try to enable the use of the compatibility module in the Resolve-Dependency.psd1 if it is not already enabled.

It was already enabled, so there is an issue sonewhere. So suggest temporarily turning off PSResourceGet until we can investigate. So we get this PR through. 😊

johlju commented 9 months ago

It seems to be an issue with the image ubuntu-latest. Not sure what, switching to windows-latest made it start working. Will switch to windows-latest to fix the issue for now.

johlju commented 9 months ago

@raandree build works now, but integration tests are failing due to this change

raandree commented 4 months ago

I have merged the latest changed but the build is failing again with errors that are not related to my change. Is the build working at all at the moment?

johlju commented 4 months ago

I have fixed the test pipeline. It seems there were changes on the build worker that affected the tests. If you rebase again that error should not happen now.

johlju commented 4 months ago

@raandree I resolved the conflicts so it would pull in latest changes. Now the build fails due to the suggested changes. Looks like Plaster does not like the variable in the template. 🤔

raandree commented 3 months ago

@johlju, I have tried to get it working but Plaster cannot handle subexpressions. I have removed them and added a comment. Does that work?

johlju commented 3 months ago

It works if we document how to use it here: https://github.com/gaelcolas/Sampler/blob/main/README.md#set_psmodulepath

raandree commented 2 months ago

Sure @johlju, the documentation has been updated.