[DOCS] Add an example for an expansion convention for changed files
Open
Nobody has claimed this yet.
documentation
- Dominant language
- C#
- Stars
- 474
- Forks
- 65
- Avg merge
- 22h 25m
- Merged PRs (30d)
- 26
Description
URL
https://microsoft.github.io/PSRule/v3/creating-your-pipeline
How could the documentation be improved?
Add an example showing how to expand/ explode the change set when the file types are complex like ARM and Bicep.
Example 1:
Export-PSRuleConvention 'AddModuleFiles' -Initialize {
Write-Host "Initializing AddModuleFiles convention"
# Get the change file set for any bicep files.
foreach ($inputFile in $PSRule.Repository.GetChangedFiles().WithExtension('.bicep')) {
# Calculate the module path, modules are expected to be under modules/<moduleName>/v<version>
# Tests are under modules/<moduleName>/v<version>/.tests/main.tests.bicep
$modulePath = $inputFile.AsFileInfo().Directory;
while (!$modulePath.Name.StartsWith('v')) {
$modulePath = $modulePath.Parent;
}
$moduleVersion = $modulePath.Name;
$moduleName = $modulePath.Parent.Name;
# Add tests
Write-Host "Adding module tests for $moduleName/$moduleVersion";
if (!(Test-Path "$($modulePath.FullName)/.tests/main.tests.bicep")) {
Write-Warning "No tests found for $moduleName/$moduleVersion";
}
else {
$PSRule.Input.Add($modulePath.FullName + "/.tests/main.tests.bicep");
}
# Add matching docs
$PSRule.Input.Add("docs/modules/$moduleName-$moduleVersion/**");
}
}
Example 2:
Export-PSRuleConvention 'AddParams' -Initialize {
Write-Verbose "Initializing Params convention"
# If a deployment, test through parameter files.
foreach ($inputFile in $PSRule.Repository.GetChangedFiles().WithinPath("deployments/").WithExtension('.bicep')) {
$paramFiles = $inputFile.DirectoryName + "/*.bicepparam"
Write-Verbose "Adding input file: $paramFiles"
$PSRule.Input.Add($paramFiles);
}
}
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the creating-your-pipeline documentation page named in the issue and review its existing change-set convention examples. Add examples covering expansion for changed Bicep files, including module tests and matching documentation, plus deployment parameter files; the page is done when both requested scenarios are clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100