From 12394722cce94f90d661d562b244696be617b56c Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sat, 3 Feb 2024 13:54:52 +0100 Subject: [PATCH] Fix GitHub actions (#12) --- CHANGELOG.md | 11 ++++++++++- Resolve-Dependency.ps1 | 43 +++++++++-------------------------------- Resolve-Dependency.psd1 | 1 - 3 files changed, 19 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ed6e4a..e5576af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Reverted resolve dependency logic so that GitHub actions works. + +## [0.1.2] - 2024-02-03 + +### Fixed + +- Fix bootstrap script parameter block. + ## [0.1.1] - 2024-02-02 ### Fixed @@ -12,7 +22,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Status badges updated. - Update integration tests for the bootstrap script. - Fix missing commands in bootstrap script. -- Fix bootstrap script parameter block. ### Changed diff --git a/Resolve-Dependency.ps1 b/Resolve-Dependency.ps1 index d5ab35f..17cc98e 100644 --- a/Resolve-Dependency.ps1 +++ b/Resolve-Dependency.ps1 @@ -61,10 +61,6 @@ .PARAMETER PSResourceGetVersion String specifying the module version for PSResourceGet if the `UsePSResourceGet` switch is utilized. - .PARAMETER PSResourceGetThrottleLimit - Specifies the maximum number of concurrent requests to the PowerShell Gallery - when using PSResourceGet. - .NOTES Load defaults for parameters values from Resolve-Dependency.psd1 if not provided as parameter. @@ -141,10 +137,6 @@ param [System.String] $PSResourceGetVersion, - [Parameter()] - [System.UInt16] - $PSResourceGetThrottleLimit, - [Parameter()] [System.Management.Automation.SwitchParameter] $UsePowerShellGetCompatibilityModule, @@ -945,19 +937,16 @@ try $percentagePerModule = [System.Math]::Floor(100 / $modulesToSave.Length) - # Inspired from https://stackoverflow.com/questions/67114770/are-non-concurrent-collections-safe-inside-concurrent-collections - $syncProgress = [System.Collections.Concurrent.ConcurrentDictionary[string, int]]::new() - - # The variable $progressPercent will not be the same one as inside the parallell foreach loop. - $progressPercent = $syncProgress.GetOrAdd('ProgressPercentage', { param($key) return 0 }) + $progressPercentage = 0 - Write-Progress -Activity 'PSResourceGet:' -PercentComplete $progressPercent -CurrentOperation 'Restoring Build Dependencies' + Write-Progress -Activity 'PSResourceGet:' -PercentComplete $progressPercentage -CurrentOperation 'Restoring Build Dependencies' - $modulesToSave | ForEach-Object -ThrottleLimit $PSResourceGetThrottleLimit -Parallel { - $currentModule = $_ + foreach ($currentModule in $modulesToSave) + { + Write-Progress -Activity 'PSResourceGet:' -PercentComplete $progressPercentage -CurrentOperation 'Restoring Build Dependencies' -Status ('Saving module {0}' -f $savePSResourceParameters.Name) $savePSResourceParameters = @{ - Path = $using:PSDependTarget + Path = $PSDependTarget TrustRepository = $true Confirm = $false } @@ -968,11 +957,9 @@ try # Modules that Sampler depend on that cannot be refreshed without a new session. $skipModule = @('PowerShell-Yaml') - $savedModule = $false - if ($savePSResourceParameters.Name -in $skipModule -and (Get-Module -Name $savePSResourceParameters.Name)) { - Write-Progress -Activity 'PSResourceGet:' -PercentComplete $progressPercent -CurrentOperation 'Restoring Build Dependencies' -Status ('Skipping module {0}' -f $savePSResourceParameters.Name) + Write-Progress -Activity 'PSResourceGet:' -PercentComplete $progressPercentage -CurrentOperation 'Restoring Build Dependencies' -Status ('Skipping module {0}' -f $savePSResourceParameters.Name) Write-Information -MessageData ('Skipping the module {0} since it cannot be refresh while loaded into the session. To refresh the module open a new session and resolve dependencies again.' -f $savePSResourceParameters.Name) -InformationAction 'Continue' } @@ -987,24 +974,12 @@ try { Write-Warning -Message 'Save-PSResource could not save (replace) one or more dependencies. This can be due to the module is loaded into the session (and referencing assemblies). Close the current session and open a new session and try again.' } - else - { - $savedModule = $true - } } - $syncProgressCopy = $using:syncProgress - - #$syncProgressCopy.progressPercentage += $using:percentagePerModule - $progressPercent = $syncProgressCopy.AddOrUpdate('ProgressPercentage', { param($key) return 0 }, { param($key, $value) return $value + $using:percentagePerModule }) - - if ($savedModule) - { - Write-Progress -Activity 'PSResourceGet:' -PercentComplete $progressPercent -CurrentOperation 'Restoring Build Dependencies' -Status ('Saved module {0}' -f $savePSResourceParameters.Name) - } + $progressPercentage += $percentagePerModule } - Write-Progress -Activity 'PSResourceGet:' -PercentComplete 100 -CurrentOperation 'Restoring Build Dependencies' -Completed + Write-Progress -Activity 'PSResourceGet:' -PercentComplete 100 -CurrentOperation 'Dependencies restored' -Completed } } else diff --git a/Resolve-Dependency.psd1 b/Resolve-Dependency.psd1 index 4fbf7de..07945f8 100644 --- a/Resolve-Dependency.psd1 +++ b/Resolve-Dependency.psd1 @@ -9,7 +9,6 @@ UsePSResourceGet = $true #PSResourceGetVersion = '1.0.1' - PSResourceGetThrottleLimit = 2 UsePowerShellGetCompatibilityModule = $true UsePowerShellGetCompatibilityModuleVersion = '3.0.23-beta23'