Skip to content

Commit

Permalink
Fix GitHub actions (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
johlju authored Feb 3, 2024
1 parent 9943005 commit 1239472
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 36 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,23 @@ 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

- Status badges updated.
- Update integration tests for the bootstrap script.
- Fix missing commands in bootstrap script.
- Fix bootstrap script parameter block.

### Changed

Expand Down
43 changes: 9 additions & 34 deletions Resolve-Dependency.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -141,10 +137,6 @@ param
[System.String]
$PSResourceGetVersion,

[Parameter()]
[System.UInt16]
$PSResourceGetThrottleLimit,

[Parameter()]
[System.Management.Automation.SwitchParameter]
$UsePowerShellGetCompatibilityModule,
Expand Down Expand Up @@ -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
}
Expand All @@ -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'
}
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion Resolve-Dependency.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

UsePSResourceGet = $true
#PSResourceGetVersion = '1.0.1'
PSResourceGetThrottleLimit = 2

UsePowerShellGetCompatibilityModule = $true
UsePowerShellGetCompatibilityModuleVersion = '3.0.23-beta23'
Expand Down

0 comments on commit 1239472

Please sign in to comment.