From 3d271f6dfe263aa95801730ce77f2e3137816a7c Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Tue, 14 Apr 2020 09:24:14 +1200 Subject: [PATCH 1/2] Update CI files --- .gitattributes | 6 ++++++ .gitignore | 2 +- .vscode/analyzersettings.psd1 | 15 +++----------- .vscode/settings.json | 29 +++++++++++++++++++++++--- CHANGELOG.md | 17 ++++++++++++++++ CONTRIBUTING.md | 7 +++++++ RequiredModules.psd1 | 7 ++++--- azure-pipelines.yml | 9 ++++----- build.ps1 | 38 ++++++++++++++++++++++++++++++----- build.yaml | 8 +++++--- 10 files changed, 106 insertions(+), 32 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/.gitattributes b/.gitattributes index 37726ef..9dbbd55 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,3 +2,9 @@ # Set default behavior to automatically normalize line endings. ############################################################################### * text eol=crlf + +# Ensure any exe files are treated as binary +*.exe binary +*.jpg binary +*.xl* binary +*.pfx binary diff --git a/.gitignore b/.gitignore index ecfe6a7..44817b0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,8 @@ *.user *.coverage .vs +.vscode .psproj .sln markdownissues.txt -TestResults.xml output/ diff --git a/.vscode/analyzersettings.psd1 b/.vscode/analyzersettings.psd1 index be415e4..78312d2 100644 --- a/.vscode/analyzersettings.psd1 +++ b/.vscode/analyzersettings.psd1 @@ -1,11 +1,6 @@ @{ - <# - For the custom rules to work, the DscResource.Tests repo must be - cloned. It is automatically clone as soon as any unit or - integration tests are run. - #> - CustomRulePath = '.\DSCResource.Tests\DscResource.AnalyzerRules' - + CustomRulePath = '.\output\RequiredModules\DscResource.AnalyzerRules' + includeDefaultRules = $true IncludeRules = @( # DSC Resource Kit style guideline rules. 'PSAvoidDefaultValueForMandatoryParameter', @@ -43,11 +38,7 @@ 'PSUseDeclaredVarsMoreThanAssignments', 'PSUsePSCredentialType', - <# - This is to test all the DSC Resource Kit custom rules. - The name of the function-blocks of each custom rule start - with 'Measure*'. - #> 'Measure-*' ) + } diff --git a/.vscode/settings.json b/.vscode/settings.json index 43f01cf..a060627 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,15 +1,38 @@ -// Place your settings in this file to overwrite default and user settings. { "powershell.codeFormatting.openBraceOnSameLine": false, - "powershell.codeFormatting.newLineAfterOpenBrace": false, + "powershell.codeFormatting.newLineAfterOpenBrace": true, "powershell.codeFormatting.newLineAfterCloseBrace": true, "powershell.codeFormatting.whitespaceBeforeOpenBrace": true, "powershell.codeFormatting.whitespaceBeforeOpenParen": true, "powershell.codeFormatting.whitespaceAroundOperator": true, "powershell.codeFormatting.whitespaceAfterSeparator": true, "powershell.codeFormatting.ignoreOneLineBlock": false, + "powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationAfterEveryPipeline", "powershell.codeFormatting.preset": "Custom", + "powershell.codeFormatting.alignPropertyValuePairs": true, "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, - "powershell.scriptAnalysis.settingsPath": ".vscode\\analyzersettings.psd1" + "powershell.scriptAnalysis.settingsPath": ".vscode\\analyzersettings.psd1", + "powershell.scriptAnalysis.enable": true, + "files.associations": { + "*.ps1xml": "xml" + }, + "cSpell.words": [ + "COMPANYNAME", + "ICONURI", + "LICENSEURI", + "PROJECTURI", + "RELEASENOTES", + "buildhelpers", + "endregion", + "gitversion", + "icontains", + "keepachangelog", + "notin", + "pscmdlet", + "steppable" + ], + "[markdown]": { + "files.encoding": "utf8" + } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 43ed4e5..98b49f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Added build task `Generate_Conceptual_Help` to generate conceptual help + for the DSC resource. +- Added build task `Generate_Wiki_Content` to generate the wiki content + that can be used to update the GitHub Wiki. + +### Changed + +- Updated CI pipeline files. +- No longer run integration tests when running the build task `test`, e.g. + `.\build.ps1 -Task test`. To manually run integration tests, run the + following: + ```powershell + .\build.ps1 -Tasks test -PesterScript 'tests/Integration' -CodeCoverageThreshold 0 + ``` + ## [3.1.1] - 2020-01-31 ### Changed diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..3544bcc --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,7 @@ +# Contributing + +Please check out common DSC Community [contributing guidelines](https://dsccommunity.org/guidelines/contributing). + +## Running the Tests + +If want to know how to run this module's tests you can look at the [Testing Guidelines](https://dsccommunity.org/guidelines/testing-guidelines/#running-tests) diff --git a/RequiredModules.psd1 b/RequiredModules.psd1 index 17954c1..adb36d7 100644 --- a/RequiredModules.psd1 +++ b/RequiredModules.psd1 @@ -1,20 +1,21 @@ @{ - # Set up a mini virtual environment... PSDependOptions = @{ AddToPath = $True Target = 'output\RequiredModules' Parameters = @{ + Repository = '' } } - invokeBuild = 'latest' + InvokeBuild = 'latest' PSScriptAnalyzer = 'latest' - pester = 'latest' + Pester = 'latest' Plaster = 'latest' ModuleBuilder = '1.0.0' ChangelogManagement = 'latest' Sampler = 'latest' 'DscResource.Test' = 'latest' 'DscResource.AnalyzerRules' = 'latest' + 'DscResource.DocGenerator' = 'latest' xDscResourceDesigner = 'latest' } diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5711452..92e606b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,16 +1,15 @@ trigger: branches: include: - - '*' + - master + paths: + include: + - source/**/* tags: include: - "v*" exclude: - "*-*" -pr: - branches: - include: - - master stages: - stage: Build diff --git a/build.ps1 b/build.ps1 index a94f13b..4630cb8 100644 --- a/build.ps1 +++ b/build.ps1 @@ -18,7 +18,7 @@ param [validateScript( { Test-Path -Path $_ } )] - $BuildConfig = './build.yaml', + $BuildConfig, [Parameter()] # A Specific folder to build the artefact into. @@ -35,22 +35,34 @@ param [Parameter()] $RequiredModulesDirectory = $(Join-Path 'output' 'RequiredModules'), + [Parameter()] + [object[]] + $PesterScript, + # Filter which tags to run when invoking Pester tests # This is used in the Invoke-Pester.pester.build.ps1 tasks [Parameter()] [string[]] $PesterTag, - [Parameter()] - [string[]] - $PesterScript, - # Filter which tags to exclude when invoking Pester tests # This is used in the Invoke-Pester.pester.build.ps1 tasks [Parameter()] [string[]] $PesterExcludeTag, + # Filter which tags to run when invoking DSC Resource tests + # This is used in the DscResource.Test.build.ps1 tasks + [Parameter()] + [string[]] + $DscTestTag, + + # Filter which tags to exclude when invoking DSC Resource tests + # This is used in the DscResource.Test.build.ps1 tasks + [Parameter()] + [string[]] + $DscTestExcludeTag, + [Parameter()] [Alias('bootstrap')] [switch]$ResolveDependency, @@ -210,6 +222,22 @@ process Begin { + # Find build config if not specified + if (-not $BuildConfig) { + $config = Get-ChildItem -Path "$PSScriptRoot\*" -Include 'build.y*ml', 'build.psd1', 'build.json*' -ErrorAction:Ignore + if (-not $config -or ($config -is [array] -and $config.Length -le 0)) { + throw "No build configuration found. Specify path via -BuildConfig" + } + elseif ($config -is [array]) { + if ($config.Length -gt 1) { + throw "More than one build configuration found. Specify which one to use via -BuildConfig" + } + $BuildConfig = $config[0] + } + else { + $BuildConfig = $config + } + } # Bootstrapping the environment before using Invoke-Build as task runner if ($MyInvocation.ScriptName -notLike '*Invoke-Build.ps1') diff --git a/build.yaml b/build.yaml index 1dfc1ef..7974fea 100644 --- a/build.yaml +++ b/build.yaml @@ -22,6 +22,8 @@ BuildWorkflow: - Build_Module_ModuleBuilder - Build_NestedModules_ModuleBuilder - Create_changelog_release_output + - Generate_Conceptual_Help + - Generate_Wiki_Content pack: - build @@ -38,7 +40,6 @@ BuildWorkflow: - Publish_release_to_GitHub - publish_module_to_gallery - #################################################### # PESTER Configuration # #################################################### @@ -48,10 +49,9 @@ Pester: ExcludeFromCodeCoverage: Script: - tests/Unit - - tests/Integration ExcludeTag: Tag: - CodeCoverageThreshold: 85 + CodeCoverageThreshold: 70 DscTest: OutputFormat: NUnitXML @@ -68,6 +68,8 @@ Resolve-Dependency: ModuleBuildTasks: Sampler: - '*.build.Sampler.ib.tasks' + DscResource.DocGenerator: + - 'Task.*' TaskHeader: | param($Path) From 9a10295ceb37409cf56b97d5b252d9a96bda3835 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Tue, 14 Apr 2020 09:53:46 +1200 Subject: [PATCH 2/2] Correct code coverage threshold --- build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.yaml b/build.yaml index 7974fea..55c0941 100644 --- a/build.yaml +++ b/build.yaml @@ -51,7 +51,7 @@ Pester: - tests/Unit ExcludeTag: Tag: - CodeCoverageThreshold: 70 + CodeCoverageThreshold: 85 DscTest: OutputFormat: NUnitXML