Skip to content

Commit 0767a58

Browse files
committed
updated build scripts
1 parent e766a15 commit 0767a58

File tree

6 files changed

+123
-95
lines changed

6 files changed

+123
-95
lines changed

.vscode/tasks.json

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,37 +54,16 @@
5454
}
5555
},
5656
{
57-
"label": "Build, Install, and Load Module",
57+
"label": "Test, Build, Install, and Load Module",
5858
"type": "shell",
5959
"windows": {
60-
"command": "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File ${workspaceRoot}\\Build.ps1 -BuildModule -InstallAndTestModule"
60+
"command": "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File ${workspaceRoot}\\Build.ps1 -TestBuildAndInstallModule"
6161
},
6262
"linux": {
63-
"command": "/usr/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -BuildModule -InstallAndTestModule"
63+
"command": "/usr/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -TestBuildAndInstallModule"
6464
},
6565
"osx": {
66-
"command": "/usr/local/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -BuildModule -InstallAndTestModule"
67-
},
68-
"group": {
69-
"kind": "build",
70-
"isDefault": true
71-
},
72-
"presentation": {
73-
"reveal": "always",
74-
"panel": "new"
75-
}
76-
},
77-
{
78-
"label": "Build, Install, Load, and Publish Module",
79-
"type": "shell",
80-
"windows": {
81-
"command": "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File ${workspaceRoot}\\Build.ps1 -BuildModule -InstallAndTestModule -UploadPSGallery"
82-
},
83-
"linux": {
84-
"command": "/usr/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -BuildModule -InstallAndTestModule -UploadPSGallery"
85-
},
86-
"osx": {
87-
"command": "/usr/local/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -BuildModule -InstallAndTestModule -UploadPSGallery"
66+
"command": "/usr/local/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -TestBuildAndInstallModule"
8867
},
8968
"group": {
9069
"kind": "build",

Build.ps1

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,26 @@
33
param (
44
[parameter(Position = 0, ParameterSetName = 'Build')]
55
[switch]$BuildModule,
6-
[parameter(Position = 1, ParameterSetName = 'Build')]
7-
[switch]$UploadPSGallery,
6+
[parameter(Position = 1,ParameterSetName = 'Build')]
7+
[switch]$TestBuildAndInstallModule,
88
[parameter(Position = 2, ParameterSetName = 'Build')]
9-
[switch]$InstallAndTestModule,
9+
[switch]$UploadPSGallery,
1010
[parameter(Position = 3, ParameterSetName = 'Build')]
11-
[version]$NewVersion,
11+
[switch]$InstallAndTestModule,
1212
[parameter(Position = 4, ParameterSetName = 'Build')]
13+
[version]$NewVersion,
14+
[parameter(Position = 5, ParameterSetName = 'Build')]
1315
[string]$ReleaseNotes,
14-
[parameter(Position = 5, ParameterSetName = 'CBH')]
16+
[parameter(Position = 6, ParameterSetName = 'CBH')]
1517
[switch]$AddMissingCBH,
16-
[parameter(Position = 6, ParameterSetName = 'Tests')]
17-
[switch]$Test
18+
[parameter(Position = 7, ParameterSetName = 'Tests')]
19+
[switch]$Test,
20+
[parameter(Position = 8,ParameterSetName = 'Tests')]
21+
[switch]$TestMetaOnly,
22+
[parameter(Position = 9,ParameterSetName = 'Tests')]
23+
[switch]$TestUnitOnly,
24+
[parameter(Position = 10,ParameterSetName = 'Tests')]
25+
[switch]$TestIntergrationOnly
1826
)
1927

2028
function PrerequisitesLoaded {
@@ -80,16 +88,32 @@ switch ($psCmdlet.ParameterSetName) {
8088
throw
8189
}
8290
}
83-
}
84-
'Build' {
85-
if ($NewVersion -ne $null) {
91+
if ($TestMetaOnly) {
8692
try {
87-
Invoke-Build -Task UpdateVersion -NewVersion $NewVersion -ReleaseNotes $ReleaseNotes
93+
Invoke-Build -Task RunMetaTests
8894
}
8995
catch {
90-
throw $_
96+
throw
97+
}
98+
}
99+
if ($TestUnitOnly) {
100+
try {
101+
Invoke-Build -Task RunUnitTests
102+
}
103+
catch {
104+
throw
91105
}
92106
}
107+
if ($TestIntergrationOnly) {
108+
try {
109+
Invoke-Build -Task RunIntergrationTests
110+
}
111+
catch {
112+
throw
113+
}
114+
}
115+
}
116+
'Build' {
93117
# If no parameters were specified or the build action was manually specified then kick off a standard build
94118
if (($psboundparameters.count -eq 0) -or ($BuildModule)) {
95119
try {
@@ -101,13 +125,22 @@ switch ($psCmdlet.ParameterSetName) {
101125
}
102126
}
103127

104-
# Install and test the module?
105-
if ($InstallAndTestModule) {
128+
# Test, Build Installd and test load the module
129+
if ($TestBuildAndInstallModule) {
106130
try {
107-
Invoke-Build -Task InstallAndTestModule
131+
Invoke-Build -Task TestBuildAndInstallModule
132+
}
133+
catch {
134+
Write-Host 'Test, Build Installd and test load the module of the module failed:'
135+
throw $_
136+
}
137+
}
138+
139+
if ($NewVersion -ne $null) {
140+
try {
141+
Invoke-Build -Task UpdateVersion -NewVersion $NewVersion -ReleaseNotes $ReleaseNotes
108142
}
109143
catch {
110-
Write-Host 'Install and test of module failed:'
111144
throw $_
112145
}
113146
}

plugins/plaster/template/scaffold/Build.template

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,26 @@
33
param (
44
[parameter(Position = 0, ParameterSetName = 'Build')]
55
[switch]$BuildModule,
6-
[parameter(Position = 1, ParameterSetName = 'Build')]
7-
[switch]$UploadPSGallery,
6+
[parameter(Position = 1,ParameterSetName = 'Build')]
7+
[switch]$TestBuildAndInstallModule,
88
[parameter(Position = 2, ParameterSetName = 'Build')]
9-
[switch]$InstallAndTestModule,
9+
[switch]$UploadPSGallery,
1010
[parameter(Position = 3, ParameterSetName = 'Build')]
11-
[version]$NewVersion,
11+
[switch]$InstallAndTestModule,
1212
[parameter(Position = 4, ParameterSetName = 'Build')]
13+
[version]$NewVersion,
14+
[parameter(Position = 5, ParameterSetName = 'Build')]
1315
[string]$ReleaseNotes,
14-
[parameter(Position = 5, ParameterSetName = 'CBH')]
16+
[parameter(Position = 6, ParameterSetName = 'CBH')]
1517
[switch]$AddMissingCBH,
16-
[parameter(Position = 6, ParameterSetName = 'Tests')]
17-
[switch]$Test
18+
[parameter(Position = 7, ParameterSetName = 'Tests')]
19+
[switch]$Test,
20+
[parameter(Position = 8,ParameterSetName = 'Tests')]
21+
[switch]$TestMetaOnly,
22+
[parameter(Position = 9,ParameterSetName = 'Tests')]
23+
[switch]$TestUnitOnly,
24+
[parameter(Position = 10,ParameterSetName = 'Tests')]
25+
[switch]$TestIntergrationOnly
1826
)
1927

2028
function PrerequisitesLoaded {
@@ -80,16 +88,32 @@ switch ($psCmdlet.ParameterSetName) {
8088
throw
8189
}
8290
}
83-
}
84-
'Build' {
85-
if ($NewVersion -ne $null) {
91+
if ($TestMetaOnly) {
8692
try {
87-
Invoke-Build -Task UpdateVersion -NewVersion $NewVersion -ReleaseNotes $ReleaseNotes
93+
Invoke-Build -Task RunMetaTests
8894
}
8995
catch {
90-
throw $_
96+
throw
97+
}
98+
}
99+
if ($TestUnitOnly) {
100+
try {
101+
Invoke-Build -Task RunUnitTests
102+
}
103+
catch {
104+
throw
91105
}
92106
}
107+
if ($TestIntergrationOnly) {
108+
try {
109+
Invoke-Build -Task RunIntergrationTests
110+
}
111+
catch {
112+
throw
113+
}
114+
}
115+
}
116+
'Build' {
93117
# If no parameters were specified or the build action was manually specified then kick off a standard build
94118
if (($psboundparameters.count -eq 0) -or ($BuildModule)) {
95119
try {
@@ -101,13 +125,22 @@ switch ($psCmdlet.ParameterSetName) {
101125
}
102126
}
103127

104-
# Install and test the module?
105-
if ($InstallAndTestModule) {
128+
# Test, Build Installd and test load the module
129+
if ($TestBuildAndInstallModule) {
106130
try {
107-
Invoke-Build -Task InstallAndTestModule
131+
Invoke-Build -Task TestBuildAndInstallModule
132+
}
133+
catch {
134+
Write-Host 'Test, Build Installd and test load the module of the module failed:'
135+
throw $_
136+
}
137+
}
138+
139+
if ($NewVersion -ne $null) {
140+
try {
141+
Invoke-Build -Task UpdateVersion -NewVersion $NewVersion -ReleaseNotes $ReleaseNotes
108142
}
109143
catch {
110-
Write-Host 'Install and test of module failed:'
111144
throw $_
112145
}
113146
}

plugins/plaster/template/scaffold/CI/appveyor.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
os: WMF 5
44

55
# Skip on updates to the readme.
6-
# We can force this by adding [skip ci] or [ci skip] anywhere in commit message
6+
# We can force this by adding [skip ci] or [ci skip] anywhere in commit message
77
skip_commits:
8-
message: /updated readme.*|update readme.*s/
8+
files:
9+
- "**/*.md"
10+
message: /updated readme.*|update readme.*s|update docs.*|update version.*|update appveyor.*/
911

1012
build: false
1113

12-
#Kick off the CI/CD pipeline
14+
# Kick off the CI/CD pipeline
1315
test_script:
14-
- ps: . .\Build.ps1 -BuildModule
16+
- ps: . .\Build.ps1 -TestBuildAndInstallModule

plugins/plaster/template/scaffold/modulename.build.template

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,19 @@ task CodeHealthReport -if {$Script:BuildEnv.OptionCodeHealthReport} ValidateRequ
142142

143143
Write-Description White 'Creating a code health report of your public functions' -level 2
144144
$CodeHealthScanPathPublic = Join-Path $BuildRoot $Script:BuildEnv.PublicFunctionSource
145+
$CodeHealthScanTestPathPublic = $CodeHealthScanPathPublic -replace 'src', 'tests\\unit'
145146
$CodeHealthReportPublic = Join-Path $BuildReportsFolder 'CodeHealthReport-Public.html'
146-
Invoke-PSCodeHealth -Path $CodeHealthScanPathPublic -HtmlReportPath $CodeHealthReportPublic
147+
Invoke-PSCodeHealth -Path $CodeHealthScanPathPublic -HtmlReportPath $CodeHealthReportPublic -TestsPath $CodeHealthScanTestPathPublic
147148

148149
if (Test-Path $CodeHealthReportPublic) {
149150
(Get-Content -Path $CodeHealthReportPublic -raw) -replace [regex]::escape((Resolve-Path $CodeHealthScanPathPublic)), $Script:BuildEnv.PublicFunctionSource | Out-File -FilePath $CodeHealthReportPublic -Encoding $Script:BuildEnv.Encoding -Force
150151
}
151152

152153
Write-Description White 'Creating a code health report of your private functions' -level 2
153154
$CodeHealthScanPathPrivate = Join-Path $BuildRoot $Script:BuildEnv.PrivateFunctionSource
155+
$CodeHealthScanTestPathPrivate = $CodeHealthScanPathPrivate -replace 'src', 'tests\\unit'
154156
$CodeHealthReportPrivate = Join-Path $BuildReportsFolder 'CodeHealthReport-Private.html'
155-
Invoke-PSCodeHealth -Path $CodeHealthScanPathPrivate -HtmlReportPath $CodeHealthReportPrivate
157+
Invoke-PSCodeHealth -Path $CodeHealthScanPathPrivate -HtmlReportPath $CodeHealthReportPrivate -TestsPath $CodeHealthScanTestPathPrivate
156158

157159
if (Test-Path $CodeHealthReportPrivate) {
158160
(Get-Content -Path $CodeHealthReportPrivate -raw) -replace [regex]::escape((Resolve-Path $CodeHealthScanPathPrivate)), $Script:BuildEnv.PrivateFunctionSource | Out-File -FilePath $CodeHealthReportPrivate -Encoding $Script:BuildEnv.Encoding -Force
@@ -872,21 +874,21 @@ task BuildSessionCleanup CleanScratchDirectory, {
872874

873875
#region Main tasks
874876
# Synopsis: Run all tests
875-
task Tests RunMetaTests, RunUnitTests, RunIntergrationTests {
877+
task Tests RunMetaTests, RunUnitTests, RunIntergrationTests, {
876878

877879
}
878880
# Synopsis: Build the module
879881
task Build Configure, CodeHealthReport, PrepareStage, GetPublicFunctions, SanitizeCode, CreateHelp, CreateModulePSM1, CreateModuleManifest, AnalyzeModuleRelease, PushVersionRelease, PushCurrentRelease, CreateProjectHelp, PostBuildTasks, BuildSessionCleanup, {
880882

881883
}
882884

883-
# Synopsis: Build, install and Test load the module.
884-
task BuildAndInstallModule Build, InstallModule, TestImportInstalledModule, BuildSessionCleanup, {
885+
# Synopsis: Test, Build, install and Test load the module.
886+
task TestBuildAndInstallModule Tests, Build, InstallModule, TestImportInstalledModule, BuildSessionCleanup, {
885887

886888
}
887889

888-
# Synopsis: Build, Install, Test load and Publish the module
889-
task BuildInstallTestAndPublishModule BuildAndInstallModule, PublishPSGallery, BuildSessionCleanup, {
890+
# Synopsis: Test, Build, Install, Test load and Publish the module
891+
task BuildInstallTestAndPublishModule TestBuildAndInstallModule, PublishPSGallery, BuildSessionCleanup, {
890892

891893
}
892894

@@ -896,5 +898,5 @@ task AddMissingCBH Configure, CleanScratchDirectory, InsertCBHInPublicFunctions,
896898
}
897899

898900
# Synopsis: Default task when running Invoke-Build
899-
task . Tests, Build
900-
#endregion
901+
task . Build
902+
#endregion

plugins/plaster/template/scaffold/vscode/tasks.json

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,37 +54,16 @@
5454
}
5555
},
5656
{
57-
"label": "Build, Install, and Load Module",
57+
"label": "Test, Build, Install, and Load Module",
5858
"type": "shell",
5959
"windows": {
60-
"command": "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File ${workspaceRoot}\\Build.ps1 -BuildModule -InstallAndTestModule"
60+
"command": "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File ${workspaceRoot}\\Build.ps1 -TestBuildAndInstallModule"
6161
},
6262
"linux": {
63-
"command": "/usr/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -BuildModule -InstallAndTestModule"
63+
"command": "/usr/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -TestBuildAndInstallModule"
6464
},
6565
"osx": {
66-
"command": "/usr/local/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -BuildModule -InstallAndTestModule"
67-
},
68-
"group": {
69-
"kind": "build",
70-
"isDefault": true
71-
},
72-
"presentation": {
73-
"reveal": "always",
74-
"panel": "new"
75-
}
76-
},
77-
{
78-
"label": "Build, Install, Load, and Publish Module",
79-
"type": "shell",
80-
"windows": {
81-
"command": "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File ${workspaceRoot}\\Build.ps1 -BuildModule -InstallAndTestModule -UploadPSGallery"
82-
},
83-
"linux": {
84-
"command": "/usr/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -BuildModule -InstallAndTestModule -UploadPSGallery"
85-
},
86-
"osx": {
87-
"command": "/usr/local/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -BuildModule -InstallAndTestModule -UploadPSGallery"
66+
"command": "/usr/local/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -TestBuildAndInstallModule"
8867
},
8968
"group": {
9069
"kind": "build",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy