Skip to content
This repository was archived by the owner on Jul 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #15 from bgelens/dev
Browse files Browse the repository at this point in the history
!Deploy - Release v0.1.2
  • Loading branch information
bgelens authored Jul 6, 2018
2 parents e9a62be + f6c8d62 commit edc2402
Show file tree
Hide file tree
Showing 87 changed files with 7,265 additions and 270 deletions.
41 changes: 23 additions & 18 deletions .build.ps1
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
[cmdletBinding()]
Param (
[CmdletBinding()]
param (
[Parameter(Position=0)]
$Tasks,

[switch]
$ResolveDependency,
[switch] $ResolveDependency,

[String]
$BuildOutput = "BuildOutput",
[string] $BuildOutput = "BuildOutput",

[String[]]
$GalleryRepository,
[string[]] $GalleryRepository,

[Uri]
$GalleryProxy,
[uri] $GalleryProxy,

[Switch]
$ForceEnvironmentVariables = [switch]$true,
[switch] $ForceEnvironmentVariables = [switch]$true,

$MergeList = @('enum*',[PSCustomObject]@{Name='class*';order={(Import-PowerShellDataFile -EA 0 .\*\Classes\classes.psd1).order.indexOf($_.BaseName)}},'priv*','pub*')

Expand All @@ -32,7 +27,7 @@ Param (
''
}

,$CodeCoverageThreshold = 0
,$CodeCoverageThreshold = 70
)

Process {
Expand All @@ -58,21 +53,31 @@ Process {
# Defining the Default task 'workflow' when invoked without -tasks parameter
task . Clean,
Set_Build_Environment_Variables,
#Pester_Quality_Tests_Stop_On_Fail,
Pester_Quality_Tests_Stop_On_Fail,
Copy_Source_To_Module_BuildOutput,
Merge_Source_Files_To_PSM1,
Clean_Empty_Folders_from_Build_Output,
Clean_Folders_from_Build_Output,
Update_Module_Manifest,
Run_Unit_Tests,
#Upload_Unit_Test_Results_To_AppVeyor,
Upload_Unit_Test_Results_To_AppVeyor,
Upload_Unit_Test_Results_To_CodeCov,
Fail_Build_if_Unit_Test_Failed,
Fail_if_Last_Code_Converage_is_Under_Threshold,
IntegrationTests,
Fail_if_Last_Code_Coverage_is_Under_Threshold,
#IntegrationTests,
Deploy_with_PSDeploy

# Define a testAll tasks for interactive testing
task testAll UnitTests, IntegrationTests, QualityTestsStopOnFail

# Just build so psm1 is availble to run unit tests
task onlyBuild Clean,
Set_Build_Environment_Variables,
Copy_Source_To_Module_BuildOutput,
Merge_Source_Files_To_PSM1,
Clean_Folders_from_Build_Output,
Update_Module_Manifest


# Define a dummy task when you don't want any task executed (e.g. Only load PSModulePath)
task Noop {}

Expand Down
38 changes: 28 additions & 10 deletions .build/Appveyor/TestResultUpload.Appveyor.build.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
Param (
[string]
$BuildOutput = (property BuildOutput 'BuildOutput'),
param (
[string] $BuildOutput = (property BuildOutput 'BuildOutput'),

[string]
$ProjectName = (property ProjectName (Split-Path -Leaf $BuildRoot) ),
[string] $ProjectName = (property ProjectName (Split-Path -Leaf $BuildRoot) ),

[string]
$PesterOutputFormat = (property PesterOutputFormat 'NUnitXml'),
[string] $PesterOutputFormat = (property PesterOutputFormat 'NUnitXml'),

[string]
$APPVEYOR_JOB_ID = $(try {property APPVEYOR_JOB_ID} catch {})
[string] $APPVEYOR_JOB_ID = $(try {property APPVEYOR_JOB_ID} catch {})
)

# Synopsis: Uploading Unit Test results to AppVeyor
Expand All @@ -24,4 +20,26 @@ task Upload_Unit_Test_Results_To_AppVeyor -If {(property BuildSystem 'unknown')
Write-Build Green " Uploading test results [$($TestResultFiles.Name -join ', ')] to Appveyor"
$TestResultFiles | Add-TestResultToAppveyor
Write-Build Green " Upload Complete"
}
}

# Synopsis: Uploading Unit Test results to AppVeyor
task Upload_Unit_Test_Results_To_CodeCov -If {(property BuildSystem 'unknown') -eq 'AppVeyor'} {
if (![io.path]::IsPathRooted($BuildOutput)) {
$BuildOutput = Join-Path -Path $BuildRoot -ChildPath $BuildOutput
}

$TestOutputPath = [system.io.path]::Combine($BuildOutput,'testResults','unit', 'codecov')
$TestResultFiles = Get-ChildItem -Path $TestOutputPath -Filter *.json

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -UseBasicParsing -Uri 'https://github.com/codecov/codecov-exe/releases/download/1.0.4/Codecov.zip' -OutFile .\Codecov.zip
$ProgressPreference = 'Continue'
Unblock-File -Path .\Codecov.zip
Expand-Archive -Path .\Codecov.zip -DestinationPath .\codecov

Write-Build Green " Uploading test results [$($TestResultFiles.Name -join ', ')] to CodeCov"

.\codecov\codecov.exe -f $TestResultFiles.FullName
}

22 changes: 9 additions & 13 deletions .build/PSDeploy/DeployAll.PSDeploy.build.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
Param (
[string]
$BuildOutput = (property BuildOutput 'BuildOutput'),
param (
[string] $BuildOutput = (property BuildOutput 'BuildOutput'),

[string]
$ProjectName = (property ProjectName (Split-Path -Leaf $BuildRoot) ),
[string] $ProjectName = (property ProjectName (Split-Path -Leaf $BuildRoot) ),

[string]
$PesterOutputFormat = (property PesterOutputFormat 'NUnitXml'),
[string] $PesterOutputFormat = (property PesterOutputFormat 'NUnitXml'),

[string]
$APPVEYOR_JOB_ID = $(try {property APPVEYOR_JOB_ID} catch {}),
[string] $APPVEYOR_JOB_ID = $(try {property APPVEYOR_JOB_ID} catch {}),

$DeploymentTags = $(try {property DeploymentTags} catch {}),

Expand All @@ -24,9 +20,9 @@ task Deploy_with_PSDeploy {
}

$DeployFile = [io.path]::Combine($BuildRoot, $DeployConfig)

"Deploying Module based on $DeployConfig config"

$InvokePSDeployArgs = @{
Path = $DeployFile
Force = $true
Expand All @@ -35,7 +31,7 @@ task Deploy_with_PSDeploy {
if($DeploymentTags) {
$null = $InvokePSDeployArgs.Add('Tags',$DeploymentTags)
}

Import-Module PSDeploy
Invoke-PSDeploy @InvokePSDeployArgs
}
}
11 changes: 4 additions & 7 deletions .build/Pester/IntegrationTests.pester.build.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
Param (
[string]
$ProjectName = (property ProjectName (Split-Path -Leaf $BuildRoot) ),
param (
[string] $ProjectName = (property ProjectName (Split-Path -Leaf $BuildRoot) ),

[string]
$RelativePathToIntegrationTests = (property RelativePathToIntegrationTests 'tests/Integration')
[string] $RelativePathToIntegrationTests = (property RelativePathToIntegrationTests 'tests\Integration')
)

# Synopsis: Running the Integration tests if present
Expand Down Expand Up @@ -33,5 +31,4 @@ task IntegrationTests {

Pop-Location
}

}
}
60 changes: 27 additions & 33 deletions .build/Pester/QualityTests.pester.build.ps1
Original file line number Diff line number Diff line change
@@ -1,65 +1,59 @@
Param (
[string]
$BuildOutput = (property BuildOutput 'BuildOutput'),
param (
[string] $BuildOutput = (property BuildOutput 'BuildOutput'),

[string]
$ProjectName = (property ProjectName (Split-Path -Leaf $BuildRoot)),
[string] $ProjectName = (property ProjectName (Split-Path -Leaf $BuildRoot)),

[string]
$PesterOutputFormat = (property PesterOutputFormat 'NUnitXml'),
[string] $PesterOutputFormat = (property PesterOutputFormat 'NUnitXml'),

[string]
$RelativePathToQualityTests = (property RelativePathToQualityTests 'tests/QA'),
[string] $RelativePathToQualityTests = (property RelativePathToQualityTests 'tests\QA'),

[string]
$PesterOutputSubFolder = (property PesterOutputSubFolder 'PesterOut')
[string] $PesterOutputSubFolder = (property PesterOutputSubFolder 'PesterOut')
)

# Synopsis: Making sure the Module meets some quality standard (help, tests)
task Quality_Tests {
"`tProject Path = $ProjectPath"
"`tProject Name = $ProjectName"
"`tQuality Tests = $RelativePathToQualityTests"
"`tProject Path = $ProjectPath"
"`tProject Name = $ProjectName"
"`tQuality Tests = $RelativePathToQualityTests"

$QualityTestPath = [io.DirectoryInfo][system.io.path]::Combine($ProjectPath,$ProjectName,$RelativePathToQualityTests)
if (!$QualityTestPath.Exists -and
$QualityTestPath = [io.DirectoryInfo][system.io.path]::Combine($ProjectPath, $ProjectName, $RelativePathToQualityTests)

if (-not $QualityTestPath.Exists -and
( #Try a module structure where the
($QualityTestPath = [io.DirectoryInfo][system.io.path]::Combine($ProjectPath,$RelativePathToQualityTests)) -and
!$QualityTestPath.Exists
($QualityTestPath = [io.DirectoryInfo][system.io.path]::Combine($ProjectPath, $RelativePathToQualityTests)) -and
-not $QualityTestPath.Exists
)
)
{
) {
Write-Warning ('Cannot Execute Quality tests, Path Not found {0}' -f $QualityTestPath)
return
}

"`tQualityTest Path: $QualityTestPath"
if (![io.path]::IsPathRooted($BuildOutput)) {
"`tQualityTest Path = $QualityTestPath"
if (-not [io.path]::IsPathRooted($BuildOutput)) {
$BuildOutput = Join-Path -Path $ProjectPath.FullName -ChildPath $BuildOutput
}

$PSVersion = 'PSv{0}.{1}' -f $PSVersionTable.PSVersion.Major, $PSVersionTable.PSVersion.Minor
$Timestamp = Get-date -uformat "%Y%m%d-%H%M%S"
$TestResultFileName = "QA_$PSVersion`_$TimeStamp.xml"
$TestResultFile = [system.io.path]::Combine($BuildOutput,'testResults','QA',$PesterOutputFormat,$TestResultFileName)
$TestResultFileParentFolder = Split-Path $TestResultFile -Parent
$PesterOutFilePath = [system.io.path]::Combine($BuildOutput,'testResults','QA',$PesterOutputSubFolder,$TestResultFileName)
$PesterOutParentFolder = Split-Path $PesterOutFilePath -Parent
if (!(Test-Path $PesterOutParentFolder)) {

if (-not (Test-Path $PesterOutParentFolder)) {
Write-Verbose "CREATING Pester Results Output Folder $PesterOutParentFolder"
$null = mkdir $PesterOutParentFolder -Force
$null = New-Item -Path $PesterOutParentFolder -ItemType Directory -Force
}

if (!(Test-Path $TestResultFileParentFolder)) {
if (-not (Test-Path $TestResultFileParentFolder)) {
Write-Verbose "CREATING Test Results Output Folder $TestResultFileParentFolder"
$null = mkdir $TestResultFileParentFolder -Force
$null = New-Item -Path $TestResultFileParentFolder -ItemType Directory -Force
}

Push-Location $QualityTestPath
Import-module Pester -ErrorAction Stop
Push-Location -Path $QualityTestPath

Import-module -Name Pester -ErrorAction Stop
$script:QualityTestResults = Invoke-Pester -ErrorAction Stop -OutputFormat NUnitXml -OutputFile $TestResultFile -PassThru
$null = $script:QualityTestResults | Export-Clixml -Path $PesterOutFilePath -Force
Pop-Location
Expand All @@ -72,4 +66,4 @@ task Fail_Build_if_Quality_Tests_failed -If ($CodeCoverageThreshold -ne 0) {
}

# Synopsis: Meta task that runs Quality Tests, and fails if they're not successful
task Pester_Quality_Tests_Stop_On_Fail Quality_Tests,Fail_Build_if_Quality_Tests_failed
task Pester_Quality_Tests_Stop_On_Fail Quality_Tests,Fail_Build_if_Quality_Tests_failed
Loading

0 comments on commit edc2402

Please sign in to comment.