Skip to content

Commit

Permalink
adding changelog checks (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelcolas authored and johlju committed Dec 28, 2019
1 parent c62ce6d commit f822cd3
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 72 deletions.
15 changes: 0 additions & 15 deletions .MetaTestOptIn.json

This file was deleted.

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Added a new test type, `All`, to the `Initialize-TestEnvironment` function
that initializes the DSC LCM and imports the module for testing ([issue #48](https://github.com/dsccommunity/DscResource.Test/issues/48)).
- Added check on changelog when invoking by project path.

## [0.9.0] - 2019-12-27

Expand Down
2 changes: 1 addition & 1 deletion build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ BuildWorkflow:
DscTest: |
{
Import-Module -force DscResource.Test
Invoke-DscResourceTest
Invoke-DscResourceTest -ExcludeTag 'Common Tests - Validate Localization'
}
t:
- build
Expand Down
61 changes: 61 additions & 0 deletions source/Tests/QA/Changelog.common.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('DscResource.AnalyzerRules\Measure-ParameterBlockParameterAttribute', '', Scope='Function', Target='*')]
param (
$ModuleName,
$ModuleBase,
$ModuleManifest,
$ProjectPath,
$SourcePath,
$SourceManifest,
$Tag,
$ExcludeTag,
$ExcludeModuleFile,
$ExcludeSourceFile
)

if (!$ProjectPath)
{
# Invoke-DscResourceTest is only looking at a built module, skipping this test file.
Write-Verbose "No Project path set: $ProjectPath. Skipping changelog checks."
return
}
else
{
Write-Verbose "Pushing location $ProjectPath on Stack ProjectTest"
Push-Location -StackName ProjectTest -Path $ProjectPath
}

try
{
Describe 'Changelog Management' -Tag 'Changelog' {

It 'Changelog has been updated' -skip:(
!([bool](Get-Command git -EA SilentlyContinue) -and
[bool](&(Get-Process -id $PID).Path -NoProfile -Command 'git rev-parse --is-inside-work-tree 2>$null'))
) {
# Get the list of changed files compared with master
$HeadCommit = &git rev-parse HEAD
$MasterCommit = &git rev-parse origin/master
$filesChanged = &git diff $MasterCommit...$HeadCommit --name-only

if ($HeadCommit -ne $MasterCommit)
{
# if we're not testing same commit (i.e. master..master)
$filesChanged.Where{
(Split-Path $_ -Leaf) -match '^changelog.md'
} | Should -Not -BeNullOrEmpty
}
}

It 'Changelog format compliant with keepachangelog format' -skip:(
![bool](Get-Command git -EA SilentlyContinue) -or
!(Import-Module -Name ChangelogManagement -ErrorAction SilentlyContinue -PassThru)
) {
{ Get-ChangelogData (Join-Path $ProjectPath 'CHANGELOG.md') -ErrorAction Stop } | Should -Not -Throw
}
}
}
finally
{
Write-Debug "Poping location on Stack ProjectTest"
Pop-Location -StackName ProjectTest
}
4 changes: 2 additions & 2 deletions source/Tests/QA/PSSAResource.common.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ $DscResourceAnalyzerRulesModule = Import-Module DscResource.AnalyzerRules -PassT

Describe 'Common Tests - PS Script Analyzer on Resource Files' -Tag DscPSSA,'Common Tests - PS Script Analyzer on Resource Files' {

$dscResourcesPsm1Files = Get-ChildItem -Path $ModuleBase -Include *.psm1 -Recurse | WhereModuleFileNotExcluded
$dscResourcesPsm1Files = @(Get-ChildItem -Path $ModuleBase -Include *.psm1 -Recurse | WhereModuleFileNotExcluded)

if ($SourcePath)
{
$dscResourcesPsm1Files += Get-ChildItem -Path $SourcePath -Include *.psm1 -Recurse | WhereSourceFileNotExcluded
$dscResourcesPsm1Files += @(Get-ChildItem -Path $SourcePath -Include *.psm1 -Recurse | WhereSourceFileNotExcluded)
}

foreach ($dscResourcesPsm1File in $dscResourcesPsm1Files)
Expand Down
54 changes: 0 additions & 54 deletions source/Tests/QA/Restore-TestEnvironment.ps1

This file was deleted.

0 comments on commit f822cd3

Please sign in to comment.