Skip to content
This repository was archived by the owner on Mar 19, 2025. It is now read-only.

Commit 43e12ff

Browse files
Merge pull request #2 from SubPointSolutions/dev
+ testing beta publishing to PowerShell Gallery
2 parents 0cdf0f9 + fc007fa commit 43e12ff

11 files changed

+154
-25
lines changed

.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
3+
# packer
4+
**/packer_cache/**/*
5+
**/packer_builds/**/*
6+
**/packer_boxes/**/*
7+
**/packer/build/**/*
8+
9+
# vagrant
10+
**/.vagrant/**/*
11+
**/.vagrant.d/**/*
12+
13+
# puppet
14+
**/puppet/ssl/**/*
15+
16+
# kitchen
17+
**/.kitchen/**/*
18+
19+
**/.uplift.vagrant.yaml
20+
21+
uplift-download/repo
22+
23+
gocd/server/godata
24+
uplift-download/uplift-repository
25+
26+
node_modules
27+
**/.build/**/*
28+
.build
29+
30+
**/*.gem
31+
uplift-packer\packer\packer_templates
32+
33+
uplift-packer/packer-ci-build/**/*
34+
uplift-vagrant/vagrant-uplift/Gemfile.lock
35+
36+
Gemfile.lock
37+
38+
# all build folders
39+
build-*
40+
41+
# all output folders
42+
output
43+
44+
# all uplift local repositories
45+
uplift-local-repository
46+
uplift-local-resources

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ This repository contains reusable PowerShell modules used in the uplift project.
33

44
The uplift project offers consistent Packer/Vagrant workflows and Vagrant boxes specifically designed for SharePoint professionals. It heavy lifts low-level details of the creation of domain controllers, SQL servers, SharePoint farms and Visual Studio installs by providing a codified workflow using Packer/Vagrant tooling.
55

6+
## Build status
7+
| Branch | Status |
8+
| ------------- | ------------- |
9+
| master| [![Build status](https://ci.appveyor.com/api/projects/status/4khhqjvhbscpt3qc/branch/master?svg=true)](https://ci.appveyor.com/project/SubPointSupport/uplift-powershell/branch/master) |
10+
| beta | [![Build status](https://ci.appveyor.com/api/projects/status/4khhqjvhbscpt3qc/branch/beta?svg=true)](https://ci.appveyor.com/project/SubPointSupport/uplift-powershell/branch/beta) |
11+
| dev | [![Build status](https://ci.appveyor.com/api/projects/status/4khhqjvhbscpt3qc/branch/dev?svg=true)](https://ci.appveyor.com/project/SubPointSupport/uplift-powershell/branch/dev) |
612
## How this works
713
The uplift project is split into several repositories to address particular a piece of functionality:
814

_shared/.build.ps1

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ task UnitTest {
5050
Write-Build Green " [~] Unit testing..."
5151

5252
exec {
53-
pwsh -c 'Invoke-Pester ./tests/unit* -EnableExit'
53+
if($null -ne $script:PS6 ) {
54+
pwsh -c 'Invoke-Pester ./tests/unit* -EnableExit'
55+
} else {
56+
Write-Build Green " [~] Using PowerShell"
57+
powershell -c 'Invoke-Pester ./tests/unit* -EnableExit'
58+
}
5459
}
5560
}
5661

@@ -60,7 +65,13 @@ task IntegrationTest {
6065
Write-Build Green " [~] Integration testing..."
6166

6267
exec {
63-
pwsh -c 'Invoke-Pester ./tests/integration* -EnableExit'
68+
if($null -ne $script:PS6 ) {
69+
Write-Build Green " [~] Using PS6"
70+
pwsh -c 'Invoke-Pester ./tests/integration* -EnableExit'
71+
} else {
72+
Write-Build Green " [~] Using PowerShell"
73+
powershell -c 'Invoke-Pester ./tests/integration* -EnableExit'
74+
}
6475
}
6576
}
6677

@@ -93,9 +104,25 @@ task VersionModule {
93104
# PowerShell does not allow string value in the Version
94105
# It seems to map to .NET Version object, so no -alpha/-beta tags
95106
# $script:Version = "0.1.0-alpha$stamp"
96-
97-
$script:Version = "0.1.$stamp"
98107

108+
$script:Version = "0.1.$stamp"
109+
110+
if($null -ne $env:APPVEYOR_REPO_BRANCH) {
111+
Write-Build Green " [~] Running under APPVEYOR branch: $($env:APPVEYOR_REPO_BRANCH)"
112+
113+
if($env:APPVEYOR_REPO_BRANCH -ine "beta" -and $env:APPVEYOR_REPO_BRANCH -ine "master") {
114+
Write-Build Green " skipping APPVEYOR versioning for branch: $($env:APPVEYOR_REPO_BRANCH)"
115+
} else {
116+
Write-Build Green " using APPVEYOR versioning for branch: $($env:APPVEYOR_REPO_BRANCH)"
117+
118+
## 1902.build-no
119+
$stamp = Get-Date -f "yyMM"
120+
$buildNumber = $env:APPVEYOR_BUILD_NUMBER;
121+
122+
$script:Version = "0.2.$stamp.$buildNumber"
123+
}
124+
}
125+
99126
if($null -ne $buildVersion ) {
100127
Write-Build Yello " [+] Using version from params: $buildVersion"
101128
$script:Version = $buildVersion
@@ -141,19 +168,19 @@ task BuildModule {
141168

142169
# Synopsis: Installes a PowerShell module
143170
task InstallModule {
144-
171+
145172
Write-Build Green "[~] ensuring repository: $devRepositoryName"
146173
New-UpliftPSRepository $devRepositoryName `
147174
$moduleRepositoryFolder `
148175
$moduleRepositoryFolder
149-
176+
150177
Write-Build Green " [+] Fetching repo: $devRepositoryName"
151178
Get-PSRepository $devRepositoryName
152179

153180
Write-Build Green " [~] Find-Module -Name $moduleName"
154181
Find-Module -Name $moduleName -Repository $devRepositoryName
155182

156-
Write-Build Green " [~] Install-Module -Name $moduleName -Force"
183+
Write-Build Green " [~] Install-Module -Name $moduleName -Repository $devRepositoryName -Force"
157184
Install-Module -Name $moduleName -Repository $devRepositoryName -Force
158185

159186
Write-Build Green " [~] Get-InstalledModule -Name $moduleName"
@@ -189,6 +216,27 @@ task ValidateInstalledModule {
189216
# Synopsis: Publishes module to the giving repository
190217
task PublishModule {
191218

219+
if($null -ne $env:APPVEYOR_REPO_BRANCH) {
220+
Write-Build Green " [~] Running under APPVEYOR branch: $($env:APPVEYOR_REPO_BRANCH)"
221+
222+
if($env:APPVEYOR_REPO_BRANCH -ine "dev" -and $env:APPVEYOR_REPO_BRANCH -ine "beta" -and $env:APPVEYOR_REPO_BRANCH -ine "master") {
223+
Write-Build Green " skipping publishing for branch: $($env:APPVEYOR_REPO_BRANCH)"
224+
return;
225+
}
226+
227+
$repoNameEnvName = ("SPS_REPO_NAME_" + $env:APPVEYOR_REPO_BRANCH)
228+
$repoSrcEnvName = ("SPS_REPO_SRC_" + $env:APPVEYOR_REPO_BRANCH)
229+
$repoPushEnvName = ("SPS_REPO_PUSH_" + $env:APPVEYOR_REPO_BRANCH)
230+
$repoKeyEnvName = ("SPS_REPO_KEY_" + $env:APPVEYOR_REPO_BRANCH)
231+
232+
$publishRepoName = (get-item env:$repoNameEnvName).Value;
233+
234+
$publishRepoSourceLocation = (get-item env:$repoSrcEnvName).Value;
235+
$publishRepoPublishLocation = (get-item env:$repoPushEnvName).Value;
236+
237+
$publishRepoNuGetApiKey = (get-item env:$repoKeyEnvName).Value;
238+
}
239+
192240
Confirm-Variable "publishRepoName" $publishRepoName "publishRepoName"
193241

194242
Confirm-Variable "publishRepoSourceLocation" $publishRepoSourceLocation "publishRepoSourceLocation"
@@ -221,6 +269,11 @@ task PublishModule {
221269
Write-Build Green "Completed!"
222270
}
223271

272+
# Synopsis: Executes Appveyor specific setup
273+
task AppveyorPrepare {
274+
npm install http-server -g
275+
}
276+
224277
# Synopsis: Runs PSScriptAnalyzer
225278
task AnalyzeModule {
226279
exec {
@@ -251,4 +304,7 @@ task . DefaultBuild
251304
task QA AnalyzeModule, DefaultBuild, IntegrationTest
252305

253306
# Synopsis: Default module publishing task
254-
task ReleaseModule AnalyzeModule, DefaultBuild, IntegrationTest, PublishModule
307+
task ReleaseModule AnalyzeModule, DefaultBuild, IntegrationTest, PublishModule
308+
309+
task Appveyor AppveyorPrepare,
310+
ReleaseModule

appveyor.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
test: off
2+
3+
build_script:
4+
- ps: Install-Module -Name InvokeBuild -Force
5+
- ps: pwsh -c Install-Module -Name InvokeBuild -Force
6+
- ps: cd $env:APPVEYOR_BUILD_FOLDER/invoke-uplift; pwsh -c invoke-build Appveyor
7+
- ps: cd $env:APPVEYOR_BUILD_FOLDER/uplift.core; powershell -c invoke-build Appveyor

invoke-uplift/.build.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ $moduleName = "InvokeUplift"
2020
. "$dirPath/../_shared/.build-helpers.ps1"
2121
. "$dirPath/../_shared/.build.ps1"
2222

23+
$script:PS6 = $true;
24+
2325
task PrepareResourceFiles -After PrepareModule {
2426

2527
New-Item "$moduleFolder/$moduleName/resource-files" -ItemType directory -Force | Out-Null

invoke-uplift/src/Invoke-Uplift-ActionResourceDownload.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ function Get-ResourceContainer($resource, $dstDir, $force = $false) {
114114
StagingDirPath = (Join-Path -Path $resourceDir -ChildPath "download-staging")
115115
StagingFilePath = (Join-Path -Path $resourceDir -ChildPath "download-staging" -AdditionalChildPath $resourceFileName)
116116

117-
CacheDirPath = (Join-Path -Path $resourceDir -ChildPath "download-cache")
118-
CacheFilePath = (Join-Path -Path $resourceDir -ChildPath "download-cache" -AdditionalChildPath $resourceFileName)
117+
CacheDirPath = (Join-Path -Path $resourceDir -ChildPath "cache")
118+
CacheFilePath = (Join-Path -Path $resourceDir -ChildPath "cache" -AdditionalChildPath $resourceFileName)
119119

120120
ResourceDirPath = $resourceDir
121121
DestinationPath = $dstDir
@@ -171,7 +171,7 @@ function Invoke-ResourceFolderDownload($resourceContainer, $src, $dst) {
171171
Write-DebugMessage " -dst: $dst"
172172

173173
# download
174-
$preferredTool = Get-CommandOptionValue @("-t", "-tool") $null "wget"
174+
$preferredTool = Get-CommandOptionValue @("-t", "-tool") $null $null
175175
Invoke-DownloadFile `
176176
$src `
177177
$dst `

invoke-uplift/src/Invoke-Uplift-ActionResourceDownloadLocal.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function Get-LocalResourceContainer($resourceId, $dstDir, $force = $false) {
3535

3636
Metadata = $null
3737

38-
CacheDirPath = (Join-Path -Path $resourceDir -ChildPath "download-cache")
38+
CacheDirPath = (Join-Path -Path $resourceDir -ChildPath "cache")
3939

4040
LocalRepositoryPath = $dstDir
4141
ResourceDirPath = $resourceDir
@@ -132,7 +132,7 @@ function Invoke-LocalStagingDownload($resourceContainer) {
132132
Write-InfoMessage "[~] checking if /download-staging is OK"
133133
$result = Confirm-LocalFileValidity $resourceContainer.StagingFilePath
134134

135-
$preferredTool = Get-CommandOptionValue @("-t", "-tool") $null "wget"
135+
$preferredTool = Get-CommandOptionValue @("-t", "-tool") $null $null
136136

137137
if($result -eq $False) {
138138
Write-InfoMessage "[~] downloading files..."

invoke-uplift/src/Invoke-Uplift-ActionResourceDownloadVS17.ps1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,16 @@ function Invoke-DownloadResourceVS17Dist ($resourceContainer, $vsClientPath) {
131131

132132
Write-InfoMessage "[~] ensuring vs layour folder"
133133
$vsClientPath = $resourceContainer.CacheFilePath
134-
$layoutFolderPath = Join-Path -Path $resourceContainer.CacheDirPath -ChildPath "vs17-layout"
134+
$layoutFolderPath = Join-Path -Path $resourceContainer.CacheDirPath -ChildPath "vs17"
135+
136+
if($layoutFolderPath.Length -gt 80) {
137+
138+
$help = "error 5007 when trying to install Visual Studio 2017 15.5.7 from offline layout folder - https://developercommunity.visualstudio.com/content/problem/292951/error-5007-when-trying-to-install-visual-studio-20.html"
139+
$err = "Layout folder for VS17 is greater than 80 chars! - $help"
140+
141+
Write-ErrorMessage $err
142+
throw $err
143+
}
135144

136145
New-Folder $layoutFolderPath
137146

invoke-uplift/src/Invoke-Uplift-HTTP.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,16 @@ function Invoke-DownloadFile($src, $dst, $preferredTool = $null) {
181181
if( $tools.wget.IsAvailable -eq $True) {
182182
Invoke-DownloadFileAsWget $tools.wget $src $dst
183183
return
184+
} else {
185+
Write-DebugMessage "wget is not here, fallback: wget -> curl -> InvokeWebRequest"
184186
}
185187

186188
# is curl available?
187189
if( $tools.curl.IsAvailable -eq $True) {
188190
Invoke-DownloadFileAsCurl $tools.curl $src $dst
189191
return
192+
} else {
193+
Write-DebugMessage "curl is not here, fallback: wget -> curl -> InvokeWebRequest"
190194
}
191195

192196
# default is Invoke-WebRequest

uplift.core/src/Uplift.Core.ps1

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -750,11 +750,9 @@ function Repair-UpliftMachineKeys {
750750
$fileName = $file.Name
751751
if (!$fileName.EndsWith($machGUID))
752752
{
753-
cp "$machineKeyFolder\$fileName" "$machineKeyFolder\$fileName.OLD"
753+
Copy-Item "$machineKeyFolder\$fileName" "$machineKeyFolder\$fileName.OLD"
754754
Rename-Item "$machineKeyFolder\$fileName" "$key1$machGUID"
755755
break
756-
757-
758756
}
759757
}
760758

@@ -767,7 +765,7 @@ function Repair-UpliftMachineKeys {
767765
$fileName = $file.Name
768766
if (!$fileName.EndsWith($machGUID))
769767
{
770-
cp "$machineKeyFolder\$fileName" "$machineKeyFolder\$fileName.OLD"
768+
Copy-Item "$machineKeyFolder\$fileName" "$machineKeyFolder\$fileName.OLD"
771769
Rename-Item "$machineKeyFolder\$fileName" "$key2$machGUID"
772770
break
773771

uplift.core/tests/integration/Uplift.Core.Tests.ps1

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ $srcPath = Resolve-Path "$dirPath/../../src"
77

88
$skipSourceInclude = $True
99

10-
Describe 'uplift.core.integration' {
11-
Context "Cdefault" {
12-
It 'can import module' {
13-
Import-Module Uplift.Core
14-
}
15-
}
16-
}
10+
Write-Host "PSHome: $PSHome"
11+
Write-Host "Is64BitProcess: $([Environment]::Is64BitProcess)"
12+
13+
Write-Host "Listing installed modules:"
14+
Get-InstalledModule
15+
16+
Write-Host "Importing module: Uplift.Core"
17+
Import-Module Uplift.Core
1718

1819
. $srcPath/../tests/unit/Uplift.Core.Tests.ps1

0 commit comments

Comments
 (0)