Skip to content

Commit

Permalink
Updated pipeline with status from ConfluencePS
Browse files Browse the repository at this point in the history
  • Loading branch information
lipkau committed Dec 5, 2018
1 parent 6bf66fb commit 4e37930
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 314 deletions.
41 changes: 11 additions & 30 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,34 @@
{
"version": "0.2.0",
"configurations": [
{
"configurations": [{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch Current File",
"script": "${file}",
"name": "PowerShell Pester Tests",
"script": ".\\.env.ps1",
"script": "Invoke-Pester",
"args": [],
"cwd": "${file}"
"cwd": "${workspaceRoot}"
},
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch Current File in Temporary Console",
"name": "PowerShell Launch (current file)",
"script": "${file}",
"args": [],
"cwd": "${file}",
"createTemporaryIntegratedConsole": true
},
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch Current File w/Args Prompt",
"script": "${file}",
"args": [
"${command:SpecifyScriptArgs}"
],
"cwd": "${file}"
},
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Interactive Session",
"cwd": "${workspaceRoot}"
"request": "attach",
"name": "PowerShell Attach to Host Process",
"processId": "${command.PickPSHostProcess}",
"runspaceId": 1
},
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Pester Tests",
"script": "Invoke-Pester",
"args": [],
"name": "PowerShell Interactive Session",
"cwd": "${workspaceRoot}"
},
{
"type": "PowerShell",
"request": "attach",
"name": "PowerShell Attach to Host Process",
"processId": "${command:PickPSHostProcess}",
"runspaceId": 1
}
]
}
20 changes: 4 additions & 16 deletions JiraPS.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[System.Diagnostics.CodeAnalysis.SuppressMessage('PSAvoidUsingEmptyCatchBlock', '')]
param(
[String[]]$Tag,
[String[]]$ExcludeTag = @("Integration", "Documentation"),
[String[]]$ExcludeTag = @("Integration"),
[String]$PSGalleryAPIKey,
[String]$GithubAccessToken
)
Expand Down Expand Up @@ -35,17 +35,6 @@ if ($BuildTask -notin @("SetUp", "InstallDependencies")) {
Invoke-Init
}

$shouldDeploy = (
# only deploy master branch
('master' -eq $env:BHBranchName) -and
# it cannot be a PR
( -not $env:SYSTEM_PULLREQUEST_PULLREQUESTID) -and
# only deploy from VSTS
('VSTS' -eq $env:BHBuildSystem) -and
# it cannot have a commit message that contains "skip-deploy"
($env:BHCommitMessage -notlike '*skip-deploy*')
)

#region SetUp
# Synopsis: Proxy task
task Init { Invoke-Init }
Expand All @@ -70,9 +59,9 @@ task InstallDependencies {

# Synopsis: Get the next version for the build
task GetNextVersion {
$manifestVersion = [Version](Get-Metadata -Path $env:BHPSModuleManifest)
try {
$env:CurrentOnlineVersion = [Version](Find-Module -Name $env:BHProjectName).Version
$manifestVersion = [Version](Get-Metadata -Path $env:BHPSModuleManifest)
$nextOnlineVersion = Get-NextNugetPackageVersion -Name $env:BHProjectName

if ( ($manifestVersion.Major -gt $nextOnlineVersion.Major) -or
Expand Down Expand Up @@ -127,7 +116,6 @@ task ShowInfo Init, GetNextVersion, {
Write-Build Gray ('Commit: {0}' -f $env:BHCommitMessage)
Write-Build Gray ('Build #: {0}' -f $env:BHBuildNumber)
Write-Build Gray ('Next Version: {0}' -f $env:NextBuildVersion)
Write-Build Gray ('Will deploy new version? {0}' -f $shouldDeploy)
Write-Build Gray '-------------------------------------------------------'
Write-Build Gray
Write-Build Gray ('PowerShell version: {0}' -f $PSVersionTable.PSVersion.ToString())
Expand Down Expand Up @@ -267,12 +255,12 @@ task Test Init, {
catch {
throw $_
}
}, RemoveTestResults, { Init }
}, { Init }
#endregion

#region Publish
# Synopsis: Publish a new release on github and the PSGallery
task Deploy -If ($shouldDeploy) Init, PublishToGallery, TagReplository, UpdateHomepage
task Deploy Init, PublishToGallery, TagReplository, UpdateHomepage

# Synpsis: Publish the $release to the PSGallery
task PublishToGallery {
Expand Down
67 changes: 8 additions & 59 deletions Tests/Build.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#requires -modules Configuration
#requires -modules Pester

Describe "Validation of build environment" {
Describe "Validation of build environment" -Tag Unit {

BeforeAll {
Remove-Item -Path Env:\BH*
Expand Down Expand Up @@ -34,13 +34,14 @@ Describe "Validation of build environment" {
Remove-Item -Path Env:\BH*
}

$changelogFile = if ($script:isBuild) {
"$env:BHBuildOutput/$env:BHProjectName/CHANGELOG.md"
}
else {
"$env:BHProjectPath/CHANGELOG.md"
}

Context "CHANGELOG" {
$changelogFile = if ($script:isBuild) {
"$env:BHBuildOutput/$env:BHProjectName/CHANGELOG.md"
}
else {
"$env:BHProjectPath/CHANGELOG.md"
}

foreach ($line in (Get-Content $changelogFile)) {
if ($line -match "(?:##|\<h2.*?\>)\s*\[(?<Version>(\d+\.?){1,2})\]") {
Expand All @@ -62,56 +63,4 @@ Describe "Validation of build environment" {
Configuration\Get-Metadata -Path $env:BHManifestToTest -PropertyName ModuleVersion | Should -BeLike "$changelogVersion*"
}
}

<# Context "AppVeyor" {
$appveyorFile = "$env:BHProjectPath/appveyor.yml"
$appveyorDevFile = "$env:BHProjectPath/Tools/dev-appveyor.yml"
foreach ($line in (Get-Content $appveyorFile)) {
# (?<Version>()) - non-capturing group, but named Version. This makes it
# easy to reference the inside group later.
if ($line -match '^\D*(?<Version>(\d+\.){1,3}\d+).\{build\}') {
$appveyorVersion = $matches.Version
break
}
}
It "has an AppVeyor config file for master branch" {
$appveyorFile | Should -Exist
$appveyorFile | Should -FileContentMatchMultiline "branches:\r?\n\s+only:\r?\n\s+- master"
}
It "has an AppVeyor config file for development" {
$appveyorDevFile | Should -Exist
$appveyorDevFile | Should -FileContentMatchMultiline "branches:\r?\n\s+except:\r?\n\s+- master"
}
It "contains an authentication token (secure) for the PS Gallery" {
$appveyorFile | Should -FileContentMatchMultiline "PSGalleryAPIKey:\r?\n\s+secure:"
}
foreach ($version in @("4.0", "5.1", "6.0")) {
It "tests the project on Powersell version $version" {
$appveyorFile | Should -FileContentMatch "PowershellVersion: `"$version"
}
}
It "tests the project on Windows" {
$appveyorFile | Should -FileContentMatch "APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio"
}
It "tests the project on Ubuntu" {
$appveyorFile | Should -FileContentMatch "APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu"
}
It "has a valid version in the appveyor config" {
$appveyorVersion | Should -Not -BeNullOrEmpty
[Version]($appveyorVersion) | Should -BeOfType [Version]
}
It "has a version for appveyor that matches the manifest version" {
Configuration\Get-Metadata -Path $env:BHManifestToTest -PropertyName ModuleVersion | Should -BeLike "$appveyorVersion*"
}
} #>
}
43 changes: 4 additions & 39 deletions Tests/Examples.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#requires -modules BuildHelpers
#requires -modules Pester

Describe "Validation of example codes in the documentation" -Tag Documentation {
Describe "Validation of example codes in the documentation" -Tag Documentation, NotImplemented {

BeforeAll {
Remove-Item -Path Env:\BH*
Expand All @@ -25,56 +25,21 @@ Describe "Validation of example codes in the documentation" -Tag Documentation {
Import-Module "$env:BHProjectPath/Tools/BuildTools.psm1"

Remove-Module $env:BHProjectName -ErrorAction SilentlyContinue
Import-Module $env:BHManifestToTest

# backup current configuration
& (Get-Module $env:BHProjectName) {
$script:previousConfig = $script:Configuration
$script:Configuration = @{}
$script:Configuration.Add("ServerList", [System.Collections.Generic.List[AtlassianPS.ServerData]]::new())
}
# Import-Module $env:BHManifestToTest
}
AfterAll {
#restore previous configuration
& (Get-Module $env:BHProjectName) {
$script:Configuration = $script:previousConfig
Save-Configuration
}

Remove-Module $env:BHProjectName -ErrorAction SilentlyContinue
Remove-Module BuildHelpers -ErrorAction SilentlyContinue
Remove-Item -Path Env:\BH*
}

Assert-True $script:isBuild "Examples can only be tested in the build environment. Please run `Invoke-Build -Task Build`."

#region Mocks
Mock Invoke-WebRequest { }
Mock Invoke-RestMethod { }
Mock Write-DebugMessage { } -ModuleName $env:BHProjectName
Mock Write-Verbose { } -ModuleName $env:BHProjectName
#endregion Mocks

foreach ($function in (Get-Command -Module $env:BHProjectName)) {
$functions = Get-Command -Module $env:BHProjectName | Get-Help
foreach ($function in $functions) {
Context "Examples of $($function.Name)" {
$originalErrorActionPreference = $ErrorActionPreference
$ErrorActionPreference = "Stop"

$help = Get-Help $function.Name

foreach ($example in $help.examples.example) {
$exampleName = ($example.title -replace "-").trim()

It "has a working example: $exampleName" {
{
$scriptBlock = [Scriptblock]::Create($example.code)

& $scriptBlock
} | Should -Not -Throw
}
}

$ErrorActionPreference = $originalErrorActionPreference
}
}
}
56 changes: 10 additions & 46 deletions Tests/Help.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,45 +50,9 @@ Describe "Help tests" -Tag Documentation {
)

$module = Get-Module $env:BHProjectName
$abouts = Get-ChildItem "$env:BHProjectPath/docs/en-US/about*.md"
$commands = Get-Command -Module $module -CommandType Cmdlet, Function, Workflow # Not alias
$classes = Get-ChildItem "$env:BHProjectPath/docs/en-US/classes/*"
$enums = Get-ChildItem "$env:BHProjectPath/docs/en-US/enumerations/*"
$loadedNamespace = [AtlassianPS.ServerData].Assembly.GetTypes() |
Where-Object IsPublic

#region About Help
It "has an About Help for the module" {
$abouts | Where-Object {$_.Name -eq "about_$env:BHProjectName.md"} | Should -Not -BeNullOrEmpty

if ($script:isBuild) {
Test-Path "$env:BHBuildOutput/$env:BHProjectName/en-US/about_$env:BHProjectName.help.txt" | Should -Be $true
}
}

foreach ($about in $abouts) {
$markdownFile = $about.FullName

Context "About $($about.BaseName)'s Help" {
It "has no platyPS template artifacts" {
$markdownFile | Should -Not -BeNullOrEmpty
$markdownFile | Should -Not -FileContentMatch '{{.*}}'
}

It "defines the frontmatter for the homepage" {
$markdownFile | Should -Not -BeNullOrEmpty
$markdownFile | Should -FileContentMatch "Module Name: $env:BHProjectName"
$markdownFile | Should -FileContentMatchExactly "layout: documentation"
$markdownFile | Should -FileContentMatch "permalink: /docs/$env:BHProjectName*"
$markdownFile | Should -FileContentMatch "online version: https://atlassianps.org/docs/$env:BHProjectName*"
}

if ($script:isBuild) {
@(Get-Help $about.BaseName).Count | Should -BeGreaterOrEqual 1
}
}
}
#endregion About Help
# $classes = Get-ChildItem "$env:BHProjectPath/docs/en-US/classes/*"
# $enums = Get-ChildItem "$env:BHProjectPath/docs/en-US/enumerations/*"

#region Public Functions
foreach ($command in $commands) {
Expand Down Expand Up @@ -222,7 +186,7 @@ Describe "Help tests" -Tag Documentation {
#endregion Public Functions

#region Classes
foreach ($class in $classes) {
<# foreach ($class in $classes) {
Context "Classes $($class.BaseName) Help" {
It "is described in a markdown file" {
Expand All @@ -247,15 +211,15 @@ Describe "Help tests" -Tag Documentation {
Context "Missing classes" {
It "has a documentation file for every class" {
foreach ($class in ($loadedNamespace | Where-Object IsClass)) {
foreach ($class in ([AtlassianPS.ServerData].Assembly.GetTypes() | Where-Object IsClass)) {
$classes.BaseName | Should -Contain $class.FullName
}
}
}
} #>
#endregion Classes

#region Enumerations
foreach ($enum in $enums) {
<# foreach ($enum in $enums) {
Context "Enumeration $($enum.BaseName) Help" {
It "is described in a markdown file" {
Expand All @@ -277,12 +241,12 @@ Describe "Help tests" -Tag Documentation {
}
}
Context "Missing classes" {
It "has a documentation file for every class" {
foreach ($enum in ($loadedNamespace | Where-Object IsEnum)) {
Context "Missing enumerations" {
It "has a documentation file for every enumeration" {
foreach ($enum in ([AtlassianPS.ServerData].Assembly.GetTypes() | Where-Object IsEnum)) {
$enums.BaseName | Should -Contain $enum.FullName
}
}
}
} #>
#endregion Enumerations
}
Loading

0 comments on commit 4e37930

Please sign in to comment.