Skip to content

Commit

Permalink
Publish_GitHub_Wiki_Content: Add debug configuration option (#92)
Browse files Browse the repository at this point in the history
- `Publish_GitHub_Wiki_Content`
  - Added optional debug configuration option in `build.yml`.
- `Invoke-Git`
  - Output properties in return value if called with the `Debug` optional
    common parameter.
  • Loading branch information
johlju authored Jul 8, 2021
1 parent ae1350e commit d23d17d
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Output message if `$GitHubToken` not specified which skips this task.
Fixes [Issue 75](https://github.com/dsccommunity/DscResource.DocGenerator/issues/75)
- Change working folder for the call to `git` with the argument `remote`.
- Added optional debug configuration option in `build.yml`.
- `Invoke-Git`
- Set `$TimeOut` to Milliseconds
Fixes [Issue 84](https://github.com/dsccommunity/DscResource.DocGenerator/issues/84)
- Calls `git` so it works on both Windows and Linux.
- Output properties in return value if called with the `Debug` optional
common parameter.
- `Publish-WikiContent`
- Remove a unnecessary `Set-Location` so it is possible to remove the
temporary folder.
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,12 @@ BuildWorkflow:
- publish_module_to_gallery
- Publish_GitHub_Wiki_Content
```

It is also possible to enable debug output information for the task when
it is run by adding this to the build configuration:

```yaml
DscResource.DocGenerator:
Publish_GitHub_Wiki_Content:
Debug: true
```
4 changes: 4 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,7 @@ GitHubConfig:
GitHubConfigUserName: dscbot
GitHubConfigUserEmail: [email protected]
UpdateChangelogOnPrerelease: false

DscResource.DocGenerator:
Publish_GitHub_Wiki_Content:
Debug: true
4 changes: 4 additions & 0 deletions source/Public/Invoke-Git.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,9 @@ function Invoke-Git
}
}

Write-Debug -Message ('{0}: {1}' -f $MyInvocation.MyCommand.Name, ($localizedData.InvokeGitExitCodeMessage -f $returnValue.ExitCode))
Write-Debug -Message ('{0}: {1}' -f $MyInvocation.MyCommand.Name, ($localizedData.InvokeGitStandardOutputMessage -f $returnValue.StandardOutput))
Write-Debug -Message ('{0}: {1}' -f $MyInvocation.MyCommand.Name, ($localizedData.InvokeGitStandardErrorMessage -f $returnValue.StandardError))

return $returnValue
}
36 changes: 34 additions & 2 deletions source/tasks/Publish_GitHub_Wiki_Content.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,21 @@ task Publish_GitHub_Wiki_Content {
}
else
{
$debugTask = $BuildInfo.'DscResource.DocGenerator'.Publish_GitHub_Wiki_Content.Debug

# Only show debug information if Debug was set to 'true' in build configuration.
if ($debugTask)
{
"Running task with debug information."

$local:VerbosePreference = 'Continue'
$local:DebugPreference = 'Continue'
}

$OutputDirectory = Get-SamplerAbsolutePath -Path $OutputDirectory -RelativeTo $BuildRoot

"`tOutputDirectory = '$OutputDirectory'"

$BuiltModuleSubdirectory = Get-SamplerAbsolutePath -Path $BuiltModuleSubdirectory -RelativeTo $OutputDirectory

if ($VersionedOutputDirectory)
Expand Down Expand Up @@ -137,10 +150,12 @@ task Publish_GitHub_Wiki_Content {

$builtModuleManifest = Get-SamplerBuiltModuleManifest @GetBuiltModuleManifestParams
$builtModuleManifest = [string](Get-Item -Path $builtModuleManifest).FullName

"`tBuilt Module Manifest = '$builtModuleManifest'"

$builtModuleBase = Get-SamplerBuiltModuleBase @GetBuiltModuleManifestParams
$builtModuleBase = [string](Get-Item -Path $builtModuleBase).FullName

"`tBuilt Module Base = '$builtModuleBase'"

$moduleVersion = Get-BuiltModuleVersion @GetBuiltModuleManifestParams
Expand Down Expand Up @@ -170,8 +185,18 @@ task Publish_GitHub_Wiki_Content {
}
}

$gitRemoteResult = Invoke-Git -WorkingDirectory $ProjectPath `
-Arguments @( 'remote', 'get-url', 'origin' )
$invokeGitParameters = @{
WorkingDirectory = $ProjectPath
Arguments = @('remote', 'get-url', 'origin')
}

if ($debugTask)
{
$invokeGitParameters.Verbose = $true
$invokeGitParameters.Debug = $true
}

$gitRemoteResult = Invoke-Git @invokeGitParameters

if ($gitRemoteResult.ExitCode -eq 0)
{
Expand All @@ -189,6 +214,7 @@ task Publish_GitHub_Wiki_Content {
}

$wikiOutputPath = Join-Path -Path $OutputDirectory -ChildPath $WikiContentFolderName

"`tWiki Output Path = $wikiOutputPath"

$publishWikiContentParameters = @{
Expand All @@ -202,6 +228,12 @@ task Publish_GitHub_Wiki_Content {
GitUserName = $GitHubConfigUserName
}

if ($debugTask)
{
$publishWikiContentParameters.Verbose = $true
$publishWikiContentParameters.Debug = $true
}

Write-Build Magenta "Publishing Wiki content."

Publish-WikiContent @publishWikiContentParameters
Expand Down

0 comments on commit d23d17d

Please sign in to comment.