Sampler icon indicating copy to clipboard operation
Sampler copied to clipboard

Task `Set_PSModulePath`: Expanding `PSModulePath`

Open raandree opened this issue 5 months ago • 11 comments

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

  • Set_PSModulePath: The PSModulePath is now expanded and can therefore also contain variables.

Task list

  • [x] The PR represents a single logical change. i.e. Cosmetic updates should go in different PRs.
  • [x] Added an entry under the Unreleased section of in the CHANGELOG.md as per format.
  • [x] Local clean build passes without issue or fail tests (build.ps1 -ResolveDependency).
  • [ ] Documentation added/updated in README.md.
  • [ ] Comment-based help added/updated.
  • [ ] Localization strings added/updated in all localization files as appropriate.
  • [ ] Unit tests added/updated. See DSC Community Testing Guidelines.
  • [ ] Integration tests added/updated (where possible). See DSC Community Testing Guidelines.
  • [x] New/changed code adheres to DSC Community Style Guidelines.

This change is Reviewable

raandree avatar Feb 06 '24 12:02 raandree

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (5d47846) 81% compared to head (96b269e) 81%. Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@         Coverage Diff         @@
##           main   #463   +/-   ##
===================================
- Coverage    81%    81%   -1%     
===================================
  Files        44     44           
  Lines      2328   2330    +2     
===================================
+ Hits       1904   1905    +1     
- Misses      424    425    +1     
Files Coverage Δ
.build/tasks/release.module.build.ps1 82% <100%> (ø)
.build/tasks/SetPsModulePath.build.ps1 72% <50%> (-3%) :arrow_down:

codecov[bot] avatar Feb 06 '24 12:02 codecov[bot]

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

raandree avatar Feb 08 '24 15:02 raandree

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.

johlju avatar Feb 08 '24 20:02 johlju

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?

raandree avatar Feb 08 '24 21:02 raandree

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 avatar Feb 09 '24 06:02 johlju

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 avatar Feb 09 '24 06:02 johlju

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 avatar Feb 09 '24 21:02 johlju

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

johlju avatar Feb 09 '24 21:02 johlju