Skip to content

Commit 82f9c55

Browse files
committed
20221012A
1 parent 09e2714 commit 82f9c55

13 files changed

+191
-196
lines changed

hugoalh.GitHubActionsToolkit/module/cache.psm1

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ Restore cache that shared data from past job in the same workflow.
1515
.PARAMETER Key
1616
Key of the cache.
1717
.PARAMETER Path
18-
Path of the destination of the cache.
18+
Paths of the cache.
1919
.PARAMETER LiteralPath
20-
Absolute literal path of the destination of the cache.
20+
Literal paths of the cache.
2121
.PARAMETER NotUseAzureSdk
22-
Whether to not use Azure Blob SDK to download caches that are stored on the Azure Blob Storage, this maybe affect the reliability and performance.
22+
Whether to not use Azure Blob SDK to download the cache that stored on the Azure Blob Storage, this maybe affect the reliability and performance.
2323
.PARAMETER DownloadConcurrency
24-
Number of parallel downloads (only for Azure SDK).
24+
Number of parallel downloads of the cache (only for Azure SDK).
2525
.PARAMETER Timeout
26-
Maximum time for each download request, by seconds (only for Azure SDK).
26+
Maximum time for each download request of the cache, by seconds (only for Azure SDK).
2727
.OUTPUTS
2828
[String] The key of the cache hit.
2929
#>
3030
Function Restore-Cache {
3131
[CmdletBinding(DefaultParameterSetName = 'Path', HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_restore-githubactionscache#Restore-GitHubActionsCache')]
3232
[OutputType([String])]
3333
Param (
34-
[Parameter(Mandatory = $True, Position = 0, ValueFromPipelineByPropertyName = $True)][ValidateScript({ Test-CacheKey -InputObject $_ }, ErrorMessage = '`{0}` is not a valid GitHub Actions cache key, and/or more than 512 characters!')][Alias('Keys', 'Name', 'Names')][String[]]$Key,
34+
[Parameter(Mandatory = $True, Position = 0, ValueFromPipelineByPropertyName = $True)][Alias('Keys', 'Name', 'Names')][String[]]$Key,
3535
[Parameter(Mandatory = $True, ParameterSetName = 'Path', Position = 1, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][SupportsWildcards()][Alias('File', 'Files', 'Paths')][String[]]$Path,
3636
[Parameter(Mandatory = $True, ParameterSetName = 'LiteralPath', ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][Alias('LiteralFile', 'LiteralFiles', 'LiteralPaths', 'LP', 'PSPath', 'PSPaths')][String[]]$LiteralPath,
3737
[Parameter(ValueFromPipelineByPropertyName = $True)][Alias('NoAzureSdk')][Switch]$NotUseAzureSdk,
@@ -48,19 +48,12 @@ Function Restore-Cache {
4848
If ($NoOperation) {
4949
Return
5050
}
51-
[String[]]$KeysProceed = @()
52-
If ($Key.Count -igt 10) {
53-
Write-Warning -Message 'Keys are limit to maximum count of 10! Only first 10 keys will be use.'
54-
$KeysProceed += $Key |
55-
Select-Object -First 10
56-
}
57-
Else {
58-
$KeysProceed += $Key
59-
}
6051
[Hashtable]$InputObject = @{
61-
PrimaryKey = $KeysProceed[0]
62-
RestoreKey = $KeysProceed |
63-
Select-Object -SkipIndex 0
52+
PrimaryKey = $Key[0]
53+
RestoreKey = (
54+
$Key |
55+
Select-Object -SkipIndex 0
56+
) ?? @()
6457
Path = ($PSCmdlet.ParameterSetName -ieq 'LiteralPath') ? (
6558
$LiteralPath |
6659
ForEach-Object -Process { [WildcardPattern]::Escape($_) }
@@ -90,19 +83,19 @@ Key of the cache.
9083
.PARAMETER Path
9184
Paths of the cache.
9285
.PARAMETER LiteralPath
93-
Cache literal path.
86+
Literal paths of the cache.
9487
.PARAMETER UploadChunkSizes
95-
Maximum chunk size, by KB.
88+
Maximum chunk size of the cache, by KB.
9689
.PARAMETER UploadConcurrency
97-
Number of parallel uploads.
90+
Number of parallel uploads of the cache.
9891
.OUTPUTS
9992
[String] Cache ID.
10093
#>
10194
Function Save-Cache {
10295
[CmdletBinding(DefaultParameterSetName = 'Path', HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_save-githubactionscache#Save-GitHubActionsCache')]
10396
[OutputType([String])]
10497
Param (
105-
[Parameter(Mandatory = $True, Position = 0, ValueFromPipelineByPropertyName = $True)][ValidateScript({ Test-CacheKey -InputObject $_ }, ErrorMessage = '`{0}` is not a valid GitHub Actions cache key, and/or more than 512 characters!')][Alias('Name')][String]$Key,
98+
[Parameter(Mandatory = $True, Position = 0, ValueFromPipelineByPropertyName = $True)][Alias('Name')][String]$Key,
10699
[Parameter(Mandatory = $True, ParameterSetName = 'Path', Position = 1, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][SupportsWildcards()][Alias('File', 'Files', 'Paths')][String[]]$Path,
107100
[Parameter(Mandatory = $True, ParameterSetName = 'LiteralPath', ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][Alias('LiteralFile', 'LiteralFiles', 'LiteralPaths', 'LP', 'PSPath', 'PSPaths')][String[]]$LiteralPath,
108101
[Parameter(ValueFromPipelineByPropertyName = $True)][ValidateRange(1, 1MB)][Alias('ChunkSize', 'ChunkSizes', 'UploadChunkSize')][UInt32]$UploadChunkSizes,
@@ -140,9 +133,9 @@ Set-Alias -Name 'Export-Cache' -Value 'Save-Cache' -Option 'ReadOnly' -Scope 'Lo
140133
.SYNOPSIS
141134
GitHub Actions (Private) - Test Cache Key
142135
.DESCRIPTION
143-
Test GitHub Actions cache key whether is valid.
136+
Test the key of the GitHub Actions cache whether is valid.
144137
.PARAMETER InputObject
145-
GitHub Actions cache key that need to test.
138+
Key of the GitHub Actions cache that need to test.
146139
.OUTPUTS
147140
[Boolean] Test result.
148141
#>

hugoalh.GitHubActionsToolkit/module/command-base.psm1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ Write command to communicate with the runner machine.
6060
.PARAMETER Command
6161
Command.
6262
.PARAMETER Parameter
63-
Command parameter.
63+
Parameters of the command.
6464
.PARAMETER Value
65-
Command value.
65+
Value of the command.
6666
.OUTPUTS
6767
[Void]
6868
#>
@@ -89,7 +89,7 @@ GitHub Actions (Private) - Write File Command
8989
.DESCRIPTION
9090
Write file command to communicate with the runner machine.
9191
.PARAMETER LiteralPath
92-
Literal path of the file.
92+
Literal path of the file command.
9393
.PARAMETER Name
9494
Name.
9595
.PARAMETER Value

hugoalh.GitHubActionsToolkit/module/command-control.psm1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Import-Module -Name (
2929
.SYNOPSIS
3030
GitHub Actions - Disable Echoing Commands
3131
.DESCRIPTION
32-
Disable echoing most of the commands, the log will not show the command itself; Secret `ACTIONS_STEP_DEBUG` will ignore this setting; When processing a command, it will still echo if there has any issues.
32+
Disable echoing most of the commands, the log will not show the command itself; Environment variable `ACTIONS_STEP_DEBUG` will ignore this setting; When processing a command, it will still echo if there has any issues.
3333
.OUTPUTS
3434
[Void]
3535
#>
@@ -60,9 +60,9 @@ GitHub Actions - Disable Processing Commands
6060
.DESCRIPTION
6161
Disable processing any commands, to allow log anything without accidentally execute any commands.
6262
.PARAMETER EndToken
63-
An end token for function `Enable-GitHubActionsProcessingCommands`.
63+
An end token for the function `Enable-GitHubActionsProcessingCommands`.
6464
.OUTPUTS
65-
[String] An end token for function `Enable-GitHubActionsProcessingCommands`.
65+
[String] An end token for the function `Enable-GitHubActionsProcessingCommands`.
6666
#>
6767
Function Disable-ProcessingCommands {
6868
[CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_disable-githubactionsprocessingcommands#Disable-GitHubActionsProcessingCommands')]
@@ -92,7 +92,7 @@ Set-Alias -Name 'Stop-ProcessingCommands' -Value 'Disable-ProcessingCommands' -O
9292
.SYNOPSIS
9393
GitHub Actions - Enable Echoing Commands
9494
.DESCRIPTION
95-
Enable echoing most of the commands, the log will show the command itself; Secret `ACTIONS_STEP_DEBUG` will ignore this setting.
95+
Enable echoing most of the commands, the log will show the command itself; Environment variable `ACTIONS_STEP_DEBUG` will ignore this setting.
9696
.OUTPUTS
9797
[Void]
9898
#>
@@ -123,7 +123,7 @@ GitHub Actions - Enable Processing Commands
123123
.DESCRIPTION
124124
Enable processing any commands, to allow execute any commands.
125125
.PARAMETER EndToken
126-
An end token from function `Disable-GitHubActionsProcessingCommands`.
126+
An end token from the function `Disable-GitHubActionsProcessingCommands`.
127127
.OUTPUTS
128128
[Void]
129129
#>
@@ -173,7 +173,7 @@ Function New-CommandsEndToken {
173173
.SYNOPSIS
174174
GitHub Actions (Private) - Test Processing Commands End Token
175175
.DESCRIPTION
176-
Test GitHub Actions processing commands end token whether is valid.
176+
Test the GitHub Actions processing commands end token whether is valid.
177177
.PARAMETER InputObject
178178
GitHub Actions processing commands end token that need to test.
179179
.OUTPUTS

hugoalh.GitHubActionsToolkit/module/environment-variable.psm1

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ Import-Module -Name (
1414
.SYNOPSIS
1515
GitHub Actions - Add PATH
1616
.DESCRIPTION
17-
Add PATH to current step and all subsequent steps in the current job.
17+
Add PATH to the current step and/or all subsequent steps in the current job.
1818
.PARAMETER Path
19-
Path.
19+
Absolute paths.
2020
.PARAMETER NoValidator
21-
Do not check the PATH whether is valid.
21+
Whether to not check the paths are valid.
2222
.PARAMETER Scope
23-
Scope of PATH.
23+
Scope of the PATHs.
2424
.OUTPUTS
2525
[Void]
2626
#>
@@ -29,14 +29,14 @@ Function Add-PATH {
2929
[OutputType([Void])]
3030
Param (
3131
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][ValidatePattern('^.+$', ErrorMessage = 'Parameter `Path` must be in single line string!')][Alias('Paths')][String[]]$Path,
32-
[Alias('NoValidate', 'SkipValidate', 'SkipValidator')][Switch]$NoValidator,
33-
[Alias('Scopes')][GitHubActionsEnvironmentVariableScopes]$Scope = [GitHubActionsEnvironmentVariableScopes]3
32+
[Parameter(ValueFromPipelineByPropertyName = $True)][Alias('NoValidate', 'SkipValidate', 'SkipValidator')][Switch]$NoValidator,
33+
[Parameter(ValueFromPipelineByPropertyName = $True)][Alias('Scopes')][GitHubActionsEnvironmentVariableScopes]$Scope = [GitHubActionsEnvironmentVariableScopes]3
3434
)
3535
Begin {
3636
[Boolean]$Legacy = [String]::IsNullOrWhiteSpace($Env:GITHUB_PATH)
37-
[String[]]$ScopeArray = $Scope.ToString() -isplit ', '
3837
}
3938
Process {
39+
[String[]]$ScopeArray = $Scope.ToString() -isplit ', '
4040
ForEach ($Item In (
4141
$Path |
4242
Select-Object -Unique
@@ -65,17 +65,17 @@ Function Add-PATH {
6565
.SYNOPSIS
6666
GitHub Actions - Set Environment Variable
6767
.DESCRIPTION
68-
Set environment variable to current step and all subsequent steps in the current job.
68+
Set environment variable to the current step and/or all subsequent steps in the current job.
6969
.PARAMETER InputObject
7070
Environment variables.
7171
.PARAMETER Name
72-
Environment variable name.
72+
Name of the environment variable.
7373
.PARAMETER Value
74-
Environment variable value.
74+
Value of the environment variable.
7575
.PARAMETER NoToUpper
76-
Do not format environment variable name to uppercase.
76+
Whether to not format names of the environment variable to the uppercase.
7777
.PARAMETER Scope
78-
Scope of environment variable.
78+
Scope of the environment variables.
7979
.OUTPUTS
8080
[Void]
8181
#>
@@ -86,14 +86,14 @@ Function Set-EnvironmentVariable {
8686
[Parameter(Mandatory = $True, ParameterSetName = 'Multiple', Position = 0, ValueFromPipeline = $True)][Alias('Input', 'Object')][Hashtable]$InputObject,
8787
[Parameter(Mandatory = $True, ParameterSetName = 'Single', Position = 0, ValueFromPipelineByPropertyName = $True)][ValidateScript({ Test-EnvironmentVariableName -InputObject $_ }, ErrorMessage = '`{0}` is not a valid environment variable name!')][Alias('Key')][String]$Name,
8888
[Parameter(Mandatory = $True, ParameterSetName = 'Single', Position = 1, ValueFromPipelineByPropertyName = $True)][String]$Value,
89-
[Alias('NoToUppercase')][Switch]$NoToUpper,
90-
[Alias('Scopes')][GitHubActionsEnvironmentVariableScopes]$Scope = [GitHubActionsEnvironmentVariableScopes]3
89+
[Parameter(ValueFromPipelineByPropertyName = $True)][Alias('NoToUppercase')][Switch]$NoToUpper,
90+
[Parameter(ValueFromPipelineByPropertyName = $True)][Alias('Scopes')][GitHubActionsEnvironmentVariableScopes]$Scope = [GitHubActionsEnvironmentVariableScopes]3
9191
)
9292
Begin {
9393
[Boolean]$Legacy = [String]::IsNullOrWhiteSpace($Env:GITHUB_ENV)
94-
[String[]]$ScopeArray = $Scope.ToString() -isplit ', '
9594
}
9695
Process {
96+
[String[]]$ScopeArray = $Scope.ToString() -isplit ', '
9797
Switch ($PSCmdlet.ParameterSetName) {
9898
'Multiple' {
9999
ForEach ($Item In $InputObject.GetEnumerator()) {
@@ -140,9 +140,9 @@ Set-Alias -Name 'Set-Environment' -Value 'Set-EnvironmentVariable' -Option 'Read
140140
.SYNOPSIS
141141
GitHub Actions (Private) - Test Environment Variable Name
142142
.DESCRIPTION
143-
Test environment variable name whether is valid.
143+
Test the name of the environment variable whether is valid.
144144
.PARAMETER InputObject
145-
Environment variable name that need to test.
145+
Name of the environment variable that need to test.
146146
.OUTPUTS
147147
[Boolean] Test result.
148148
#>

0 commit comments

Comments
 (0)