JustinGrote / ModuleFast

A "fast and loose" way to install modules from Powershell Gallery quickly. Meant for CICD, not production
Other
74 stars 5 forks source link

Az install fails in GitHub Actions #73

Closed ThomasNieto closed 6 months ago

ThomasNieto commented 6 months ago
Error: [-] should install 179ms (111ms|68ms)
Message
  Expected no exception to be thrown, but an exception "Object reference not set to an instance of an object." was thrown from D:\a\modulefast\modulefast\test\Install-Package.Tests.ps1:11 char:15
  +             { Install-ModuleFast Az -Verbose -Debug } |
  +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
  at Should -Not -Throw, D:\a\modulefast\modulefast\test\Install-Package.Tests.ps1:12
  at <ScriptBlock>, D:\a\modulefast\modulefast\test\Install-Package.Tests.ps1:11
JustinGrote commented 6 months ago

Install-Package.Tests.ps1

This isn't my code but I'm working on a dedicated github action here that is working fine in the alpha if you want to try it: https://github.com/justingrote/modulefast-action

ThomasNieto commented 6 months ago

I ran into this issue testing the AnyPackage provider in Pester. It doesn't error on my machine just seems to be the runner. Originally had Install-Package Az there and had the same issue when changing it directly to Install-ModuleFast Az for testing to rule out the provider. It could be an issue between ModuleFast, Pester, and GH Actions image.

JustinGrote commented 6 months ago

The problem with should not throw is that it swallows the stack trace, better to just set install-modulefast to erroraction stop

JustinGrote commented 6 months ago

Looks to be windows runner specific, the linux one worked just fine https://github.com/JustinGrote/ModuleFast-action/actions/runs/7764313988/job/21177566222

JustinGrote commented 6 months ago

Appears to not be detecting noninteractive mode in some circumstances

❌❯ pwsh -noni { & ([scriptblock]::Create((iwr 'bit.ly/modulefastmain'))) -UseMain; imf importexcel -destination TEMP: -destinationonly -verbose -debug }
WARNING: Parameter -Destination is set to a custom path not in your current PSModulePath. We will add it to your PSModulePath for this session. You can suppress this behavior with the -NoPSModulePathUpdate switch.
VERBOSE: Updating PSModulePath to include Temp:\
DEBUG: Skipping updating the profile because -NoProfileUpdate was specified
DEBUG: Creating new ModuleFast HTTP Client. This should only happen once!
VERBOSE: importexcel: Evaluating Module Specification
DEBUG: importexcel: Skipping PSModulePath Temp:\ - Configured but does not exist.
DEBUG: importexcel: 🔍 No installed versions matched the spec. Will check remotely.
DEBUG: importexcel: fetch registration index from https://preview.pwsh.gallery/index.json
DEBUG: importexcel: fetch info from https://preview.pwsh.gallery/importexcel/index.json
DEBUG: importexcel: Processing Response
DEBUG: importexcel: Received Response with 3 pages
DEBUG: importexcel: Found satisfying version 7.8.6 in the inlined index.
VERBOSE: ImportExcel(7.8.6): Added to install plan
Install-ModuleFast: PowerShell is in NonInteractive mode. Read and Prompt functionality is not available.
JustinGrote commented 6 months ago

Something weird is happening here, in the meantime you can specify -confirm:$false to install-modulefast as a workaround.

JustinGrote commented 6 months ago

Should be fixed: https://github.com/JustinGrote/ModuleFast-action/actions/runs/7764683017

I'll be releasing 0.2.0 soon which will include this fix once I make sure the corresponding GitHub action doesn't have any further weirdness.