build.yaml (142 lines of code) (raw):
---
####################################################
# ModuleBuilder Configuration #
####################################################
CopyPaths:
- en-US
- DscResources
- templates
prefix: prefix.ps1
Encoding: UTF8
VersionedOutputDirectory: true
####################################################
# Sampler Pipeline Configuration #
####################################################
BuildWorkflow:
'.':
- build
- test
download_gc_agents: |
{
$binPath = Join-Path -Path (Get-Item ./output/GuestConfiguration/*) -ChildPath 'bin'
New-Item -ItemType Directory -Force -Path $binPath
New-Item -ItemType Directory -Force -Path './source/gc_agents'
$localLinuxAgent = './source/gc_agents/DSC_Linux.zip'
$localWindowsAgent = './source/gc_agents/DSC_Windows.zip'
$GitHubPATPath = 'GHPAT.local.txt'
if ($env:GitHubToken)
{
Write-Verbose -Message "Using environment GitHub token" -Verbose
$GHPAT = $env:GitHubToken
}
elseif (Test-Path -Path $GitHubPATPath)
{
Write-Verbose -Message "Using file GitHub token" -Verbose
$GHPAT = (gc -raw $GitHubPATPath).Trim()
}
elseif ((Test-Path $localLinuxAgent) -and (Test-Path $localWindowsAgent))
{
Write-Warning "Using local versions of the agent available in './source/gc_agents'"
}
else
{
Write-Warning -Message "Unable to download GC Agents."
return
}
if (-not (Test-Path $localWindowsAgent))
{
Write-Verbose -Message "Attempting to retrieve Windows agent release from GitHub" -Verbose
$windowsReleaseTag = 'Windows-1.29.36.0'
$windowsRelease = Get-GitHubRelease -OwnerName PowerShell -RepositoryName DesiredStateConfiguration -AccessToken $GHPAT -Tag $windowsReleaseTag
$windowsReleaseAssetId = $windowsRelease.assets.Where{ $_.Name.Contains('GCService') }.id
Write-Verbose -Message "Attempting to retrieve Windows agent release asset from GitHub" -Verbose
$null = Get-GitHubReleaseAsset -OwnerName PowerShell -RepositoryName DesiredStateConfiguration -AccessToken $GHPAT -Asset $windowsReleaseAssetId -Path $localWindowsAgent -Force
}
if ( -not (Test-Path $localLinuxAgent))
{
Write-Verbose -Message "Attempting to retrieve Linux agent release from GitHub" -Verbose
$linuxReleaseTag = 'Linux-1.26.28'
$linuxRelease = Get-GitHubRelease -OwnerName PowerShell -RepositoryName DesiredStateConfiguration -AccessToken $GHPAT -Tag $linuxReleaseTag
$linuxReleaseAssetId = $linuxRelease.assets.Where{$_.Name.Contains('GC.zip')}.id
Write-Verbose -Message "Attempting to retrieve Linux agent release asset from GitHub" -Verbose
$null = Get-GitHubReleaseAsset -OwnerName PowerShell -RepositoryName DesiredStateConfiguration -AccessToken $GHPAT -Asset $linuxReleaseAssetId -Path $localLinuxAgent
}
Write-Verbose -Message "Copying agents to destination folder" -Verbose
$null = Copy-Item -Path $localLinuxAgent -Destination $binPath
$null = Copy-Item -Path $localWindowsAgent -Destination $binPath
Write-Verbose -Message "Finished retrieving GC agents" -Verbose
}
build:
- Clean
- Build_Module_ModuleBuilder
- Build_NestedModules_ModuleBuilder
- download_gc_agents
- Create_changelog_release_output
# - Generate_Conceptual_Help
# - Generate_Wiki_Content
pack:
- build
- package_module_nupkg
hqrmtest:
- DscResource_Tests_Stop_On_Fail
# Defining test task to be run when invoking `./build.ps1 -Tasks test`
test:
- Pester_Tests_Stop_On_Fail
- Pester_if_Code_Coverage_Under_Threshold
# Use this task when you have multiple parallel tests, which produce multiple
# code coverage files and needs to get merged into one file.
#- Merge_CodeCoverage_Files
publish:
- publish_module_to_gallery
- Publish_Release_To_GitHub
- Create_ChangeLog_GitHub_PR
####################################################
# PESTER Configuration #
####################################################
Pester:
# Pester Advanced configuration.
# If a key is not set it will be using Sampler pipeline default value.
Configuration:
Run:
Path:
- tests
ExcludePath:
Filter:
Tag:
ExcludeTag:
- PesterLanguage
- bugLinuxGCAgent
Output:
Verbosity:
CodeCoverage:
Path:
OutputFormat: JaCoCo
CoveragePercentTarget: 45
OutputPath:
CodeCoverage:
# Filename of the file that will be outputted by the task Merge_CodeCoverage_Files.
CodeCoverageMergedOutputFile: JaCoCo_coverage.xml
# File pattern used to search for files under the ./output/testResults folder
# by task Merge_CodeCoverage_Files.
CodeCoverageFilePattern: Codecov*.xml
DscTest:
ExcludeTagFilter:
- "Common Tests - New Error-Level Script Analyzer Rules"
- "Common Tests - Validate Localization"
Tag:
ExcludeSourceFile:
- output
ExcludeModuleFile:
- Modules/
# Import ModuleBuilder tasks from a specific PowerShell module using the build
# task's alias. Wildcard * can be used to specify all tasks that has a similar
# prefix and or suffix. The module contain the task must be added as a required
# module in the file RequiredModules.psd1.
ModuleBuildTasks:
Sampler:
- '*.build.Sampler.ib.tasks'
Sampler.GitHubTasks:
- '*.ib.tasks'
DscResource.DocGenerator:
- 'Task.*'
# Invoke-Build Header to be used to 'decorate' the terminal output of the tasks.
TaskHeader: |
param($Path)
""
"=" * 79
Write-Build Cyan "`t`t`t$($Task.Name.replace("_"," ").ToUpper())"
Write-Build DarkGray "$(Get-BuildSynopsis $Task)"
"-" * 79
Write-Build DarkGray " $Path"
Write-Build DarkGray " $($Task.InvocationInfo.ScriptName):$($Task.InvocationInfo.ScriptLineNumber)"
""
GitHubConfig:
GitHubFilesToAdd:
- 'CHANGELOG.md'
GitHubConfigUserName: dscbot
GitHubConfigUserEmail: dsccommunity@outlook.com
UpdateChangelogOnPrerelease: false
####################################################
# DscResource.DocGenerator Configuration #
####################################################
DscResource.DocGenerator:
Generate_Conceptual_Help:
MarkdownCodeRegularExpression:
- '\`(.+?)\`' # Match inline code-block
- '\\(\\)' # Match escaped backslash
- '\[[^\[]+\]\((.+?)\)' # Match markdown URL
- '_(.+?)_' # Match Italic (underscore)
- '\*\*(.+?)\*\*' # Match bold
- '\*(.+?)\*' # Match Italic (asterisk)