Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Line property instead of Matches and re-throw errors in GitHub actions #25

Merged
merged 2 commits into from
Sep 7, 2020

Conversation

TsekNet
Copy link
Contributor

@TsekNet TsekNet commented Sep 6, 2020

Pull Request

Issue

When Catesta detects missing comment-based help, it outputs the Matches property, shown below:

Filename            Matches
--------            -------
Copy-LastCommand.md {0}
Copy-LastCommand.md {0}    
Copy-LastCommand.md {0}
Copy-LastCommand.md {0}
Edit-Profile.md     {0}
Edit-Profile.md     {0}
Edit-Profile.md     {0}
Edit-Profile.md     {0}
Get-Elevation.md    {0}    
Get-Elevation.md    {0}
Get-Elevation.md    {0}
Get-Elevation.md    {0}    

There's also a small issue I found when troubleshooting GitHub actions. The Import-Module error is not re-thrown, making it difficult to troubleshoot. Example:

Installing PowerShell Modules
  - Successfully installed Pester
  - Successfully installed InvokeBuild
  - Successfully installed PSScriptAnalyzer
  - Successfully installed platyPS
  - Successfully installed posh-git
  - Successfully installed oh-my-posh
  - Failed to install Get-ChildItemColor
Failed to install Get-ChildItemColor
At D:\a\TsekProfile\TsekProfile\actions_bootstrap.ps1:70 char:5
+     throw $message
+     ~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Failed to install Get-ChildItemColor:String) [], RuntimeException
    + FullyQualifiedErrorId : Failed to install Get-ChildItemColor

Description

It would be more useful to output the line that's missing documentation, as shown below:

Filename            Line
--------            ----
Copy-LastCommand.md {{Fill in the Synopsis}}
Copy-LastCommand.md {{Fill in the Description}}
Copy-LastCommand.md PS C:\> {{ Add example code here }}
Copy-LastCommand.md {{ Add example description here }}
Edit-Profile.md     {{Fill in the Synopsis}}
Edit-Profile.md     {{Fill in the Description}}
Edit-Profile.md     PS C:\> {{ Add example code here }}
Edit-Profile.md     {{ Add example description here }} 
Get-Elevation.md    {{Fill in the Synopsis}}
Get-Elevation.md    {{Fill in the Description}}
Get-Elevation.md    PS C:\> {{ Add example code here }}
Get-Elevation.md    {{ Add example description here }}

Outputting the line property instead enables the user to quickly identify which documentation is missing.

With errors from Import-Module re-thrown, you'll see the following, as an example:

Installing PowerShell Modules
  - Successfully installed Pester
  - Successfully installed InvokeBuild
  - Successfully installed PSScriptAnalyzer
  - Successfully installed platyPS
  - Successfully installed posh-git
  - Successfully installed oh-my-posh
  - Failed to install Get-ChildItemColor
PackageManagement\Install-Package : The following commands are already available on this system:'Out-Default'. This 
module 'Get-ChildItemColor' may override the existing commands. If you still want to install this module 
'Get-ChildItemColor', use -AllowClobber parameter.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.4.1\PSModule.psm1:9709 char:34
+ ... talledPackages = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package],  
   Exception
    + FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.PowerShell.Pack 
   ageManagement.Cmdlets.InstallPackage

License

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@TsekNet TsekNet changed the title Use Line Property instead of Matches Use Line property instead of Matches and re-throw errors in GitHub actions Sep 7, 2020
@techthoughts2 techthoughts2 self-assigned this Sep 7, 2020
@techthoughts2 techthoughts2 added the enhancement New feature or request label Sep 7, 2020
@techthoughts2 techthoughts2 merged commit cd0cb4b into techthoughts2:Enhancements Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants