Skip to content

Commit

Permalink
Add docgenerator and hqrmtests (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-hughes authored Oct 8, 2024
1 parent 825cc8a commit 890fa06
Show file tree
Hide file tree
Showing 12 changed files with 197 additions and 67 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Test-StatementOpeningParenthsesOnSameLine` helper method.
- Fixed type on `Test-StatementOpeningBrace*`.
- `Measure-ParameterBlock*` format test data.
- Enable generated docs with `DscResource.DocGenerator`
- Add HQRM checks

### Fixed

Expand Down
6 changes: 1 addition & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,11 @@ prefixed with just 'Sql'
Helper functions that are only used by one resource
so preferably be put in the same script file as the resource.
Helper function that can used by more than one resource can preferably
be placed in the resource module file [DscResource.Common](/Modules/DscResource.Common/DscResource.Common.psm1).
be placed in the resource module file [DscResource.Common](https://github.com/dsccommunity/DscResource.Common/).

### Localization

Please see the localization section in the [style guideline](https://dsccommunity.org/styleguidelines/localization/).
The helper functions is found in the module [DscResource.LocalizationHelper](/Modules/DscResource.LocalizationHelper/DscResource.LocalizationHelper.psm1).

### Unit tests

Expand Down Expand Up @@ -136,9 +135,6 @@ the automated test framework which is run in AppVeyor when commits are pushed
to a Pull Request (PR).
Please see the [Testing Guidelines](https://dsccommunity.org/guidelines/testing-guidelines/)
for common DSC Resource Kit testing guidelines.
There are also configurations made by existing integration tests that can be reused
to write integration tests for other resources. This is documented in the
[Integration tests README](/Tests/Integration/README.md).

#### AppVeyor

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ guidelines.
## Change log

A full list of changes in each version can be found in the [change log](CHANGELOG.md).

## Documentation

The documentation can be found in the [DscResource.AnalyzerRules Wiki](https://github.com/dsccommunity/DscResource.AnalyzerRules/wiki).
The documentation is automatically updated on each PR merge.
26 changes: 16 additions & 10 deletions RequiredModules.psd1
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
@{
PSDependOptions = @{
PSDependOptions = @{
AddToPath = $true
Target = 'output\RequiredModules'
Parameters = @{
Repository = 'PSGallery'
}
}

InvokeBuild = 'latest'
PSScriptAnalyzer = 'latest'
Pester = 'latest'
Plaster = 'latest'
ModuleBuilder = 'latest'
ChangelogManagement = 'latest'
Sampler = 'latest'
'Sampler.GitHubTasks' = 'latest'
'DscResource.Test' = 'latest'
InvokeBuild = 'latest'
PSScriptAnalyzer = 'latest'
Pester = 'latest'
Plaster = 'latest'
ModuleBuilder = 'latest'
ChangelogManagement = 'latest'
Sampler = 'latest'
'Sampler.GitHubTasks' = 'latest'
MarkdownLinkCheck = 'latest'
'DscResource.Test' = 'latest'
xDscResourceDesigner = 'latest'

# Prerequisite modules for documentation.
'DscResource.DocGenerator' = 'latest'
PlatyPS = 'latest'
}
17 changes: 17 additions & 0 deletions Source/WikiSource/Home.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Welcome to the DscResource.AnalyzerRules wiki

<sup>*DscResource.AnalyzerRules v#.#.#*</sup>

For the task documentation please see the [README.md](https://github.com/dsccommunity/DscResource.AnalyzerRules/blob/main/README.md)

Please leave comments, feature requests, and bug reports for this module in
the [issues section](https://github.com/dsccommunity/DscResource.AnalyzerRules/issues)
for this repository.

## Prerequisites

- [Sampler](https://github.com/gaelcolas/Sampler)

## Change log

A full list of changes in each version can be found in the [change log](https://github.com/dsccommunity/DscResource.AnalyzerRules/blob/main/CHANGELOG.md).
27 changes: 27 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,33 @@ stages:
- stage: Test
dependsOn: Build
jobs:
- job: Test_HQRM
displayName: 'HQRM'
pool:
vmImage: 'windows-latest'
timeoutInMinutes: 0
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download Build Artifact'
inputs:
buildType: 'current'
artifactName: $(buildArtifactName)
targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)'
- task: PowerShell@2
name: test
displayName: 'Run HQRM Test'
inputs:
filePath: './build.ps1'
arguments: '-Tasks hqrmtest'
pwsh: false
- task: PublishTestResults@2
displayName: 'Publish Test Results'
condition: succeededOrFailed()
inputs:
testResultsFormat: 'NUnit'
testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml'
testRunTitle: 'HQRM'

- job: test_linux
displayName: 'Linux'
timeoutInMinutes: 0
Expand Down
69 changes: 69 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,38 @@ Encoding: UTF8
VersionedOutputDirectory: true
BuiltModuleSubdirectory: builtModule

####################################################
# HQRM Test Configuration #
####################################################
DscTest:
Pester:
Configuration:
Filter:
Tag:
ExcludeTag:
- Common Tests - New Error-Level Script Analyzer Rules
Output:
Verbosity: Detailed
CIFormat: Auto
TestResult:
Enabled: true
OutputFormat: NUnitXML
OutputEncoding: ascii
OutputPath: ./output/testResults/NUnitXml_HQRM_Tests.xml
Script:
ExcludeSourceFile:
- output
- DscResource.AnalyzerRules
ExcludeModuleFile:
MainGitBranch: main

ModuleBuildTasks:
Sampler:
- '*.build.Sampler.ib.tasks'
Sampler.GitHubTasks:
- '*.ib.tasks'
DscResource.DocGenerator:
- 'Task.*'
DscResource.Test:
- 'Task.*'

Expand Down Expand Up @@ -43,10 +70,23 @@ BuildWorkflow:
- Build_NestedModules_ModuleBuilder
- Create_changelog_release_output

docs:
- Generate_Wiki_Content
- Generate_Conceptual_Help
- Generate_Markdown_For_Public_Commands
- Generate_External_Help_File_For_Public_Commands
- Clean_Markdown_Of_Public_Commands
- Generate_Wiki_Sidebar
- Clean_Markdown_Metadata

pack:
- build
- docs
- package_module_nupkg

hqrmtest:
- Invoke_HQRM_Tests_Stop_On_Fail

test:
- Pester_Tests_Stop_On_Fail
- Convert_Pester_Coverage
Expand All @@ -58,6 +98,7 @@ BuildWorkflow:
publish:
- Publish_Release_To_GitHub
- Publish_Module_To_gallery
- Publish_GitHub_Wiki_Content

####################################################
# Pester Configuration (Sampler) #
Expand Down Expand Up @@ -106,3 +147,31 @@ GitHubConfig:
GitHubConfigUserName: dscbot # cSpell: disable-line
GitHubConfigUserEmail: [email protected]
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)
Publish_GitHub_Wiki_Content:
Debug: true
Generate_Wiki_Content:
MofResourceMetadata:
Type: MofResource
Category: Resources
ClassResourceMetadata:
Type: ClassResource
Category: Resources
CompositeResourceMetadata:
Type: CompositeResource
Category: Resources
Generate_Wiki_Sidebar:
Debug: false
AlwaysOverwrite: true
3 changes: 2 additions & 1 deletion source/Private/Get-LocalizedData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@
function Get-LocalizedData
{
[CmdletBinding()]
param (
param
(
[Parameter(Position = 0)]
[Alias('Variable')]
[ValidateNotNullOrEmpty()]
Expand Down
3 changes: 2 additions & 1 deletion source/Private/New-SuggestedCorrection.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ function New-SuggestedCorrection
{
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'None')]
[OutputType([Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.CorrectionExtent])]
param (
param
(
[Parameter(Mandatory = $true)]
[System.Management.Automation.Language.IScriptExtent]
$Extent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ function Test-StatementOpeningParenthsesOnSameLine
[System.String[]] $statementBlockRows = Get-StatementBlockAsRow -StatementBlock $StatementBlock
if ($statementBlockRows.Count)
{

# Check so that an opening brace does not exist on the same line as the statement.
if ($statementBlockRows[0] -match '\(')
{
Expand Down
3 changes: 2 additions & 1 deletion source/Public/Measure-Hashtable.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ function Measure-Hashtable
{
[CmdletBinding()]
[OutputType([Microsoft.Windows.Powershell.ScriptAnalyzer.Generic.DiagnosticRecord[]])]
param (
param
(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.Management.Automation.Language.HashtableAst[]]
Expand Down
Loading

0 comments on commit 890fa06

Please sign in to comment.