Skip to content

Commit 9886c74

Browse files
committed
Updated Tests
1 parent 9951519 commit 9886c74

16 files changed

+761
-424
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ If you like drinking from the firehose, here's [everything we closed for 2.0], b
158158

159159
No changelog available for version `1.0` of ConfluencePS. `1.0` was created in late 2015. Version `.69` was published to the PowerShell Gallery in Nov 2016, and it remained unchanged until `2.0`. If you're looking for things that changed prior to `2.0`...sorry, but these probably aren't the droids you're looking for. :)
160160

161-
162161
[everything we closed for 2.0]: https://github.com/AtlassianPS/ConfluencePS/issues?utf8=%E2%9C%93&q=closed%3A2017-04-01..2017-08-17
163162
[@alexsuslin]: https://github.com/alexsuslin
164163
[@axxelG]: https://github.com/axxelG

ConfluencePS.build.ps1

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ param(
77
[String[]]$Tag,
88
[String[]]$ExcludeTag,
99
[String]$PSGalleryAPIKey,
10-
[String]$GithubAccessToken,
11-
[String]$WikiUri = $env:WikiURI,
12-
[String]$WikiUser = $env:WikiUser,
13-
[String]$WikiPassword = $env:WikiPass
10+
[String]$GithubAccessToken
1411
)
1512

1613
$WarningPreference = "Continue"
@@ -37,25 +34,14 @@ if ($BuildTask -notin @("SetUp", "InstallDependencies")) {
3734
Import-Module BuildHelpers -Force -ErrorAction Stop
3835
Invoke-Init
3936
}
40-
if ('AppVeyor' -eq $env:BHBuildSystem) {
41-
$project = Get-AppVeyorProject
42-
}
43-
44-
$env:WikiURI = $WikiUri
45-
$env:WikiUser = $WikiUser
46-
$env:WikiPass = $WikiPassword
4737

4838
$shouldDeploy = (
4939
# only deploy master branch
5040
('master' -eq $env:BHBranchName) -and
5141
# it cannot be a PR
52-
# ( -not $env:APPVEYOR_PULL_REQUEST_NUMBER) -and
53-
# only deploy from AppVeyor
42+
( -not $env:SYSTEM_PULLREQUEST_PULLREQUESTID) -and
43+
# only deploy from VSTS
5444
('VSTS' -eq $env:BHBuildSystem) -and
55-
# must be last job of AppVeyor
56-
# (Test-IsLastJob) -and
57-
# Travis-CI must be finished (if used)
58-
# TODO: ( -not Test-TravisProgress) -and
5945
# it cannot have a commit message that contains "skip-deploy"
6046
($env:BHCommitMessage -notlike '*skip-deploy*')
6147
)
@@ -148,10 +134,10 @@ task ShowInfo Init, GetNextVersion, {
148134

149135
#region BuildRelease
150136
# Synopsis: Build a shippable release
151-
task Build Init, GenerateRelease, UpdateManifest, CompileModule
137+
task Build Init, GenerateExternalHelp, CopyModuleFiles, UpdateManifest, CompileModule, PrepareTests
152138

153139
# Synopsis: Generate ./Release structure
154-
task GenerateRelease GenerateExternalHelp, {
140+
task CopyModuleFiles {
155141
# Setup
156142
if (-not (Test-Path "$env:BHBuildOutput/$env:BHProjectName")) {
157143
$null = New-Item -Path "$env:BHBuildOutput/$env:BHProjectName" -ItemType Directory
@@ -165,16 +151,17 @@ task GenerateRelease GenerateExternalHelp, {
165151
"$env:BHProjectPath/LICENSE"
166152
"$env:BHProjectPath/README.md"
167153
) -Destination "$env:BHBuildOutput/$env:BHProjectName" -Force
168-
# Copy Tests
169-
Copy-Item -Path "$env:BHProjectPath/PSScriptAnalyzerSettings.psd1" -Destination $env:BHBuildOutput -Force
154+
}
155+
156+
# Synopsis: Prepare tests for ./Release
157+
task PrepareTests Init, {
170158
$null = New-Item -Path "$env:BHBuildOutput/Tests" -ItemType Directory -ErrorAction SilentlyContinue
171159
Copy-Item -Path "$env:BHProjectPath/Tests" -Destination $env:BHBuildOutput -Recurse -Force
172-
# Remove all execptions from PSScriptAnalyzer
173-
BuildHelpers\Update-Metadata -Path "$env:BHBuildOutput/PSScriptAnalyzerSettings.psd1" -PropertyName ExcludeRules -Value ''
160+
Copy-Item -Path "$env:BHProjectPath/PSScriptAnalyzerSettings.psd1" -Destination $env:BHBuildOutput -Force
174161
}
175162

176163
# Synopsis: Compile all functions into the .psm1 file
177-
task CompileModule {
164+
task CompileModule Init, {
178165
$regionsToKeep = @('Dependencies', 'ModuleConfig')
179166

180167
$targetFile = "$env:BHBuildOutput/$env:BHProjectName/$env:BHProjectName.psm1"
@@ -210,7 +197,7 @@ task CompileModule {
210197
}
211198

212199
# Synopsis: Use PlatyPS to generate External-Help
213-
task GenerateExternalHelp {
200+
task GenerateExternalHelp Init, {
214201
Import-Module platyPS -Force
215202
foreach ($locale in (Get-ChildItem "$env:BHProjectPath/docs" -Attribute Directory)) {
216203
New-ExternalHelp -Path "$($locale.FullName)" -OutputPath "$env:BHModulePath/$($locale.Basename)" -Force
@@ -250,13 +237,13 @@ task Test Init, {
250237

251238
Remove-Module $env:BHProjectName -ErrorAction SilentlyContinue
252239

253-
$params = @{
240+
<# $params = @{
254241
Path = "$env:BHBuildOutput/$env:BHProjectName"
255242
Include = '*.ps1', '*.psm1'
256243
Recurse = $True
257-
# Exclude = $CodeCoverageExclude
244+
Exclude = $CodeCoverageExclude
258245
}
259-
$codeCoverageFiles = Get-ChildItem @params
246+
$codeCoverageFiles = Get-ChildItem @params #>
260247

261248
try {
262249
$parameter = @{
@@ -271,10 +258,6 @@ task Test Init, {
271258
}
272259
$testResults = Invoke-Pester @parameter
273260

274-
if ('AppVeyor' -eq $env:BHBuildSystem) {
275-
BuildHelpers\Add-TestResultToAppveyor -TestFile $parameter["OutputFile"]
276-
}
277-
278261
Assert-True ($testResults.FailedCount -eq 0) "$($testResults.FailedCount) Pester test(s) failed."
279262
}
280263
catch {

PSScriptAnalyzerSettings.psd1

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
@{
22
Severity=@('Error','Warning')
33
# IncludeRules = @()
4-
ExcludeRules = @(
5-
'PSAvoidAlias'
6-
)
4+
# ExcludeRules = @()
75
}

Tests/Build.Tests.ps1

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#requires -modules BuildHelpers
2+
#requires -modules Configuration
3+
#requires -modules Pester
4+
5+
Describe "Validation of build environment" {
6+
7+
BeforeAll {
8+
Remove-Item -Path Env:\BH*
9+
$projectRoot = (Resolve-Path "$PSScriptRoot/..").Path
10+
if ($projectRoot -like "*Release") {
11+
$projectRoot = (Resolve-Path "$projectRoot/..").Path
12+
}
13+
14+
Import-Module BuildHelpers
15+
Set-BuildEnvironment -BuildOutput '$ProjectPath/Release' -Path $projectRoot -ErrorAction SilentlyContinue
16+
17+
$env:BHManifestToTest = $env:BHPSModuleManifest
18+
$script:isBuild = $PSScriptRoot -like "$env:BHBuildOutput*"
19+
if ($script:isBuild) {
20+
$Pattern = [regex]::Escape($env:BHProjectPath)
21+
22+
$env:BHBuildModuleManifest = $env:BHPSModuleManifest -replace $Pattern, $env:BHBuildOutput
23+
$env:BHManifestToTest = $env:BHBuildModuleManifest
24+
}
25+
26+
Import-Module "$env:BHProjectPath/Tools/BuildTools.psm1"
27+
28+
Remove-Module $env:BHProjectName -ErrorAction SilentlyContinue
29+
# Import-Module $env:BHManifestToTest
30+
}
31+
AfterAll {
32+
Remove-Module $env:BHProjectName -ErrorAction SilentlyContinue
33+
Remove-Module BuildHelpers -ErrorAction SilentlyContinue
34+
Remove-Item -Path Env:\BH*
35+
}
36+
37+
$changelogFile = if ($script:isBuild) {
38+
"$env:BHBuildOutput/$env:BHProjectName/CHANGELOG.md"
39+
}
40+
else {
41+
"$env:BHProjectPath/CHANGELOG.md"
42+
}
43+
44+
Context "CHANGELOG" {
45+
46+
foreach ($line in (Get-Content $changelogFile)) {
47+
if ($line -match "(?:##|\<h2.*?\>)\s*\[(?<Version>(\d+\.?){1,2})\]") {
48+
$changelogVersion = $matches.Version
49+
break
50+
}
51+
}
52+
53+
It "has a changelog file" {
54+
$changelogFile | Should -Exist
55+
}
56+
57+
It "has a valid version in the changelog" {
58+
$changelogVersion | Should -Not -BeNullOrEmpty
59+
[Version]($changelogVersion) | Should -BeOfType [Version]
60+
}
61+
62+
It "has a version changelog that matches the manifest version" {
63+
Configuration\Get-Metadata -Path $env:BHManifestToTest -PropertyName ModuleVersion | Should -BeLike "$changelogVersion*"
64+
}
65+
}
66+
}

0 commit comments

Comments
 (0)