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

Commit edc2402

Browse files
authored
Merge pull request #15 from bgelens/dev
!Deploy - Release v0.1.2
2 parents e9a62be + f6c8d62 commit edc2402

File tree

87 files changed

+7265
-270
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+7265
-270
lines changed

.build.ps1

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
[cmdletBinding()]
2-
Param (
1+
[CmdletBinding()]
2+
param (
33
[Parameter(Position=0)]
44
$Tasks,
55

6-
[switch]
7-
$ResolveDependency,
6+
[switch] $ResolveDependency,
87

9-
[String]
10-
$BuildOutput = "BuildOutput",
8+
[string] $BuildOutput = "BuildOutput",
119

12-
[String[]]
13-
$GalleryRepository,
10+
[string[]] $GalleryRepository,
1411

15-
[Uri]
16-
$GalleryProxy,
12+
[uri] $GalleryProxy,
1713

18-
[Switch]
19-
$ForceEnvironmentVariables = [switch]$true,
14+
[switch] $ForceEnvironmentVariables = [switch]$true,
2015

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

@@ -32,7 +27,7 @@ Param (
3227
''
3328
}
3429

35-
,$CodeCoverageThreshold = 0
30+
,$CodeCoverageThreshold = 70
3631
)
3732

3833
Process {
@@ -58,21 +53,31 @@ Process {
5853
# Defining the Default task 'workflow' when invoked without -tasks parameter
5954
task . Clean,
6055
Set_Build_Environment_Variables,
61-
#Pester_Quality_Tests_Stop_On_Fail,
56+
Pester_Quality_Tests_Stop_On_Fail,
6257
Copy_Source_To_Module_BuildOutput,
6358
Merge_Source_Files_To_PSM1,
64-
Clean_Empty_Folders_from_Build_Output,
59+
Clean_Folders_from_Build_Output,
6560
Update_Module_Manifest,
6661
Run_Unit_Tests,
67-
#Upload_Unit_Test_Results_To_AppVeyor,
62+
Upload_Unit_Test_Results_To_AppVeyor,
63+
Upload_Unit_Test_Results_To_CodeCov,
6864
Fail_Build_if_Unit_Test_Failed,
69-
Fail_if_Last_Code_Converage_is_Under_Threshold,
70-
IntegrationTests,
65+
Fail_if_Last_Code_Coverage_is_Under_Threshold,
66+
#IntegrationTests,
7167
Deploy_with_PSDeploy
7268

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

72+
# Just build so psm1 is availble to run unit tests
73+
task onlyBuild Clean,
74+
Set_Build_Environment_Variables,
75+
Copy_Source_To_Module_BuildOutput,
76+
Merge_Source_Files_To_PSM1,
77+
Clean_Folders_from_Build_Output,
78+
Update_Module_Manifest
79+
80+
7681
# Define a dummy task when you don't want any task executed (e.g. Only load PSModulePath)
7782
task Noop {}
7883

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
Param (
2-
[string]
3-
$BuildOutput = (property BuildOutput 'BuildOutput'),
1+
param (
2+
[string] $BuildOutput = (property BuildOutput 'BuildOutput'),
43

5-
[string]
6-
$ProjectName = (property ProjectName (Split-Path -Leaf $BuildRoot) ),
4+
[string] $ProjectName = (property ProjectName (Split-Path -Leaf $BuildRoot) ),
75

8-
[string]
9-
$PesterOutputFormat = (property PesterOutputFormat 'NUnitXml'),
6+
[string] $PesterOutputFormat = (property PesterOutputFormat 'NUnitXml'),
107

11-
[string]
12-
$APPVEYOR_JOB_ID = $(try {property APPVEYOR_JOB_ID} catch {})
8+
[string] $APPVEYOR_JOB_ID = $(try {property APPVEYOR_JOB_ID} catch {})
139
)
1410

1511
# Synopsis: Uploading Unit Test results to AppVeyor
@@ -24,4 +20,26 @@ task Upload_Unit_Test_Results_To_AppVeyor -If {(property BuildSystem 'unknown')
2420
Write-Build Green " Uploading test results [$($TestResultFiles.Name -join ', ')] to Appveyor"
2521
$TestResultFiles | Add-TestResultToAppveyor
2622
Write-Build Green " Upload Complete"
27-
}
23+
}
24+
25+
# Synopsis: Uploading Unit Test results to AppVeyor
26+
task Upload_Unit_Test_Results_To_CodeCov -If {(property BuildSystem 'unknown') -eq 'AppVeyor'} {
27+
if (![io.path]::IsPathRooted($BuildOutput)) {
28+
$BuildOutput = Join-Path -Path $BuildRoot -ChildPath $BuildOutput
29+
}
30+
31+
$TestOutputPath = [system.io.path]::Combine($BuildOutput,'testResults','unit', 'codecov')
32+
$TestResultFiles = Get-ChildItem -Path $TestOutputPath -Filter *.json
33+
34+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
35+
$ProgressPreference = 'SilentlyContinue'
36+
Invoke-WebRequest -UseBasicParsing -Uri 'https://github.com/codecov/codecov-exe/releases/download/1.0.4/Codecov.zip' -OutFile .\Codecov.zip
37+
$ProgressPreference = 'Continue'
38+
Unblock-File -Path .\Codecov.zip
39+
Expand-Archive -Path .\Codecov.zip -DestinationPath .\codecov
40+
41+
Write-Build Green " Uploading test results [$($TestResultFiles.Name -join ', ')] to CodeCov"
42+
43+
.\codecov\codecov.exe -f $TestResultFiles.FullName
44+
}
45+
Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
Param (
2-
[string]
3-
$BuildOutput = (property BuildOutput 'BuildOutput'),
1+
param (
2+
[string] $BuildOutput = (property BuildOutput 'BuildOutput'),
43

5-
[string]
6-
$ProjectName = (property ProjectName (Split-Path -Leaf $BuildRoot) ),
4+
[string] $ProjectName = (property ProjectName (Split-Path -Leaf $BuildRoot) ),
75

8-
[string]
9-
$PesterOutputFormat = (property PesterOutputFormat 'NUnitXml'),
6+
[string] $PesterOutputFormat = (property PesterOutputFormat 'NUnitXml'),
107

11-
[string]
12-
$APPVEYOR_JOB_ID = $(try {property APPVEYOR_JOB_ID} catch {}),
8+
[string] $APPVEYOR_JOB_ID = $(try {property APPVEYOR_JOB_ID} catch {}),
139

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

@@ -24,9 +20,9 @@ task Deploy_with_PSDeploy {
2420
}
2521

2622
$DeployFile = [io.path]::Combine($BuildRoot, $DeployConfig)
27-
23+
2824
"Deploying Module based on $DeployConfig config"
29-
25+
3026
$InvokePSDeployArgs = @{
3127
Path = $DeployFile
3228
Force = $true
@@ -35,7 +31,7 @@ task Deploy_with_PSDeploy {
3531
if($DeploymentTags) {
3632
$null = $InvokePSDeployArgs.Add('Tags',$DeploymentTags)
3733
}
38-
34+
3935
Import-Module PSDeploy
4036
Invoke-PSDeploy @InvokePSDeployArgs
41-
}
37+
}

.build/Pester/IntegrationTests.pester.build.ps1

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
Param (
2-
[string]
3-
$ProjectName = (property ProjectName (Split-Path -Leaf $BuildRoot) ),
1+
param (
2+
[string] $ProjectName = (property ProjectName (Split-Path -Leaf $BuildRoot) ),
43

5-
[string]
6-
$RelativePathToIntegrationTests = (property RelativePathToIntegrationTests 'tests/Integration')
4+
[string] $RelativePathToIntegrationTests = (property RelativePathToIntegrationTests 'tests\Integration')
75
)
86

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

3432
Pop-Location
3533
}
36-
37-
}
34+
}
Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,59 @@
1-
Param (
2-
[string]
3-
$BuildOutput = (property BuildOutput 'BuildOutput'),
1+
param (
2+
[string] $BuildOutput = (property BuildOutput 'BuildOutput'),
43

5-
[string]
6-
$ProjectName = (property ProjectName (Split-Path -Leaf $BuildRoot)),
4+
[string] $ProjectName = (property ProjectName (Split-Path -Leaf $BuildRoot)),
75

8-
[string]
9-
$PesterOutputFormat = (property PesterOutputFormat 'NUnitXml'),
6+
[string] $PesterOutputFormat = (property PesterOutputFormat 'NUnitXml'),
107

11-
[string]
12-
$RelativePathToQualityTests = (property RelativePathToQualityTests 'tests/QA'),
8+
[string] $RelativePathToQualityTests = (property RelativePathToQualityTests 'tests\QA'),
139

14-
[string]
15-
$PesterOutputSubFolder = (property PesterOutputSubFolder 'PesterOut')
10+
[string] $PesterOutputSubFolder = (property PesterOutputSubFolder 'PesterOut')
1611
)
1712

1813
# Synopsis: Making sure the Module meets some quality standard (help, tests)
1914
task Quality_Tests {
20-
"`tProject Path = $ProjectPath"
21-
"`tProject Name = $ProjectName"
22-
"`tQuality Tests = $RelativePathToQualityTests"
15+
"`tProject Path = $ProjectPath"
16+
"`tProject Name = $ProjectName"
17+
"`tQuality Tests = $RelativePathToQualityTests"
2318

24-
$QualityTestPath = [io.DirectoryInfo][system.io.path]::Combine($ProjectPath,$ProjectName,$RelativePathToQualityTests)
25-
26-
if (!$QualityTestPath.Exists -and
19+
$QualityTestPath = [io.DirectoryInfo][system.io.path]::Combine($ProjectPath, $ProjectName, $RelativePathToQualityTests)
20+
21+
if (-not $QualityTestPath.Exists -and
2722
( #Try a module structure where the
28-
($QualityTestPath = [io.DirectoryInfo][system.io.path]::Combine($ProjectPath,$RelativePathToQualityTests)) -and
29-
!$QualityTestPath.Exists
23+
($QualityTestPath = [io.DirectoryInfo][system.io.path]::Combine($ProjectPath, $RelativePathToQualityTests)) -and
24+
-not $QualityTestPath.Exists
3025
)
31-
)
32-
{
26+
) {
3327
Write-Warning ('Cannot Execute Quality tests, Path Not found {0}' -f $QualityTestPath)
3428
return
3529
}
3630

37-
"`tQualityTest Path: $QualityTestPath"
38-
if (![io.path]::IsPathRooted($BuildOutput)) {
31+
"`tQualityTest Path = $QualityTestPath"
32+
if (-not [io.path]::IsPathRooted($BuildOutput)) {
3933
$BuildOutput = Join-Path -Path $ProjectPath.FullName -ChildPath $BuildOutput
4034
}
41-
35+
4236
$PSVersion = 'PSv{0}.{1}' -f $PSVersionTable.PSVersion.Major, $PSVersionTable.PSVersion.Minor
4337
$Timestamp = Get-date -uformat "%Y%m%d-%H%M%S"
4438
$TestResultFileName = "QA_$PSVersion`_$TimeStamp.xml"
4539
$TestResultFile = [system.io.path]::Combine($BuildOutput,'testResults','QA',$PesterOutputFormat,$TestResultFileName)
4640
$TestResultFileParentFolder = Split-Path $TestResultFile -Parent
4741
$PesterOutFilePath = [system.io.path]::Combine($BuildOutput,'testResults','QA',$PesterOutputSubFolder,$TestResultFileName)
4842
$PesterOutParentFolder = Split-Path $PesterOutFilePath -Parent
49-
50-
if (!(Test-Path $PesterOutParentFolder)) {
43+
44+
if (-not (Test-Path $PesterOutParentFolder)) {
5145
Write-Verbose "CREATING Pester Results Output Folder $PesterOutParentFolder"
52-
$null = mkdir $PesterOutParentFolder -Force
46+
$null = New-Item -Path $PesterOutParentFolder -ItemType Directory -Force
5347
}
5448

55-
if (!(Test-Path $TestResultFileParentFolder)) {
49+
if (-not (Test-Path $TestResultFileParentFolder)) {
5650
Write-Verbose "CREATING Test Results Output Folder $TestResultFileParentFolder"
57-
$null = mkdir $TestResultFileParentFolder -Force
51+
$null = New-Item -Path $TestResultFileParentFolder -ItemType Directory -Force
5852
}
5953

60-
Push-Location $QualityTestPath
61-
62-
Import-module Pester -ErrorAction Stop
54+
Push-Location -Path $QualityTestPath
55+
56+
Import-module -Name Pester -ErrorAction Stop
6357
$script:QualityTestResults = Invoke-Pester -ErrorAction Stop -OutputFormat NUnitXml -OutputFile $TestResultFile -PassThru
6458
$null = $script:QualityTestResults | Export-Clixml -Path $PesterOutFilePath -Force
6559
Pop-Location
@@ -72,4 +66,4 @@ task Fail_Build_if_Quality_Tests_failed -If ($CodeCoverageThreshold -ne 0) {
7266
}
7367

7468
# Synopsis: Meta task that runs Quality Tests, and fails if they're not successful
75-
task Pester_Quality_Tests_Stop_On_Fail Quality_Tests,Fail_Build_if_Quality_Tests_failed
69+
task Pester_Quality_Tests_Stop_On_Fail Quality_Tests,Fail_Build_if_Quality_Tests_failed

0 commit comments

Comments
 (0)