Skip to content
This repository was archived by the owner on Mar 19, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@


# packer
**/packer_cache/**/*
**/packer_builds/**/*
**/packer_boxes/**/*
**/packer/build/**/*

# vagrant
**/.vagrant/**/*
**/.vagrant.d/**/*

# puppet
**/puppet/ssl/**/*

# kitchen
**/.kitchen/**/*

**/.uplift.vagrant.yaml

uplift-download/repo

gocd/server/godata
uplift-download/uplift-repository

node_modules
**/.build/**/*
.build

**/*.gem
uplift-packer\packer\packer_templates

uplift-packer/packer-ci-build/**/*
uplift-vagrant/vagrant-uplift/Gemfile.lock

Gemfile.lock

# all build folders
build-*

# all output folders
output

# all uplift local repositories
uplift-local-repository
uplift-local-resources
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ This repository contains reusable PowerShell modules used in the uplift project.

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.

## Build status
| Branch | Status |
| ------------- | ------------- |
| 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) |
| 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) |
| 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) |
## How this works
The uplift project is split into several repositories to address particular a piece of functionality:

Expand Down
72 changes: 64 additions & 8 deletions _shared/.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ task UnitTest {
Write-Build Green " [~] Unit testing..."

exec {
pwsh -c 'Invoke-Pester ./tests/unit* -EnableExit'
if($null -ne $script:PS6 ) {
pwsh -c 'Invoke-Pester ./tests/unit* -EnableExit'
} else {
Write-Build Green " [~] Using PowerShell"
powershell -c 'Invoke-Pester ./tests/unit* -EnableExit'
}
}
}

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

exec {
pwsh -c 'Invoke-Pester ./tests/integration* -EnableExit'
if($null -ne $script:PS6 ) {
Write-Build Green " [~] Using PS6"
pwsh -c 'Invoke-Pester ./tests/integration* -EnableExit'
} else {
Write-Build Green " [~] Using PowerShell"
powershell -c 'Invoke-Pester ./tests/integration* -EnableExit'
}
}
}

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

$script:Version = "0.1.$stamp"

$script:Version = "0.1.$stamp"

if($null -ne $env:APPVEYOR_REPO_BRANCH) {
Write-Build Green " [~] Running under APPVEYOR branch: $($env:APPVEYOR_REPO_BRANCH)"

if($env:APPVEYOR_REPO_BRANCH -ine "beta" -and $env:APPVEYOR_REPO_BRANCH -ine "master") {
Write-Build Green " skipping APPVEYOR versioning for branch: $($env:APPVEYOR_REPO_BRANCH)"
} else {
Write-Build Green " using APPVEYOR versioning for branch: $($env:APPVEYOR_REPO_BRANCH)"

## 1902.build-no
$stamp = Get-Date -f "yyMM"
$buildNumber = $env:APPVEYOR_BUILD_NUMBER;

$script:Version = "0.2.$stamp.$buildNumber"
}
}

if($null -ne $buildVersion ) {
Write-Build Yello " [+] Using version from params: $buildVersion"
$script:Version = $buildVersion
Expand Down Expand Up @@ -141,19 +168,19 @@ task BuildModule {

# Synopsis: Installes a PowerShell module
task InstallModule {

Write-Build Green "[~] ensuring repository: $devRepositoryName"
New-UpliftPSRepository $devRepositoryName `
$moduleRepositoryFolder `
$moduleRepositoryFolder

Write-Build Green " [+] Fetching repo: $devRepositoryName"
Get-PSRepository $devRepositoryName

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

Write-Build Green " [~] Install-Module -Name $moduleName -Force"
Write-Build Green " [~] Install-Module -Name $moduleName -Repository $devRepositoryName -Force"
Install-Module -Name $moduleName -Repository $devRepositoryName -Force

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

if($null -ne $env:APPVEYOR_REPO_BRANCH) {
Write-Build Green " [~] Running under APPVEYOR branch: $($env:APPVEYOR_REPO_BRANCH)"

if($env:APPVEYOR_REPO_BRANCH -ine "dev" -and $env:APPVEYOR_REPO_BRANCH -ine "beta" -and $env:APPVEYOR_REPO_BRANCH -ine "master") {
Write-Build Green " skipping publishing for branch: $($env:APPVEYOR_REPO_BRANCH)"
return;
}

$repoNameEnvName = ("SPS_REPO_NAME_" + $env:APPVEYOR_REPO_BRANCH)
$repoSrcEnvName = ("SPS_REPO_SRC_" + $env:APPVEYOR_REPO_BRANCH)
$repoPushEnvName = ("SPS_REPO_PUSH_" + $env:APPVEYOR_REPO_BRANCH)
$repoKeyEnvName = ("SPS_REPO_KEY_" + $env:APPVEYOR_REPO_BRANCH)

$publishRepoName = (get-item env:$repoNameEnvName).Value;

$publishRepoSourceLocation = (get-item env:$repoSrcEnvName).Value;
$publishRepoPublishLocation = (get-item env:$repoPushEnvName).Value;

$publishRepoNuGetApiKey = (get-item env:$repoKeyEnvName).Value;
}

Confirm-Variable "publishRepoName" $publishRepoName "publishRepoName"

Confirm-Variable "publishRepoSourceLocation" $publishRepoSourceLocation "publishRepoSourceLocation"
Expand Down Expand Up @@ -221,6 +269,11 @@ task PublishModule {
Write-Build Green "Completed!"
}

# Synopsis: Executes Appveyor specific setup
task AppveyorPrepare {
npm install http-server -g
}

# Synopsis: Runs PSScriptAnalyzer
task AnalyzeModule {
exec {
Expand Down Expand Up @@ -251,4 +304,7 @@ task . DefaultBuild
task QA AnalyzeModule, DefaultBuild, IntegrationTest

# Synopsis: Default module publishing task
task ReleaseModule AnalyzeModule, DefaultBuild, IntegrationTest, PublishModule
task ReleaseModule AnalyzeModule, DefaultBuild, IntegrationTest, PublishModule

task Appveyor AppveyorPrepare,
ReleaseModule
7 changes: 7 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
test: off

build_script:
- ps: Install-Module -Name InvokeBuild -Force
- ps: pwsh -c Install-Module -Name InvokeBuild -Force
- ps: cd $env:APPVEYOR_BUILD_FOLDER/invoke-uplift; pwsh -c invoke-build Appveyor
- ps: cd $env:APPVEYOR_BUILD_FOLDER/uplift.core; powershell -c invoke-build Appveyor
2 changes: 2 additions & 0 deletions invoke-uplift/.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ $moduleName = "InvokeUplift"
. "$dirPath/../_shared/.build-helpers.ps1"
. "$dirPath/../_shared/.build.ps1"

$script:PS6 = $true;

task PrepareResourceFiles -After PrepareModule {

New-Item "$moduleFolder/$moduleName/resource-files" -ItemType directory -Force | Out-Null
Expand Down
6 changes: 3 additions & 3 deletions invoke-uplift/src/Invoke-Uplift-ActionResourceDownload.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ function Get-ResourceContainer($resource, $dstDir, $force = $false) {
StagingDirPath = (Join-Path -Path $resourceDir -ChildPath "download-staging")
StagingFilePath = (Join-Path -Path $resourceDir -ChildPath "download-staging" -AdditionalChildPath $resourceFileName)

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

ResourceDirPath = $resourceDir
DestinationPath = $dstDir
Expand Down Expand Up @@ -171,7 +171,7 @@ function Invoke-ResourceFolderDownload($resourceContainer, $src, $dst) {
Write-DebugMessage " -dst: $dst"

# download
$preferredTool = Get-CommandOptionValue @("-t", "-tool") $null "wget"
$preferredTool = Get-CommandOptionValue @("-t", "-tool") $null $null
Invoke-DownloadFile `
$src `
$dst `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Get-LocalResourceContainer($resourceId, $dstDir, $force = $false) {

Metadata = $null

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

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

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

if($result -eq $False) {
Write-InfoMessage "[~] downloading files..."
Expand Down
11 changes: 10 additions & 1 deletion invoke-uplift/src/Invoke-Uplift-ActionResourceDownloadVS17.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,16 @@ function Invoke-DownloadResourceVS17Dist ($resourceContainer, $vsClientPath) {

Write-InfoMessage "[~] ensuring vs layour folder"
$vsClientPath = $resourceContainer.CacheFilePath
$layoutFolderPath = Join-Path -Path $resourceContainer.CacheDirPath -ChildPath "vs17-layout"
$layoutFolderPath = Join-Path -Path $resourceContainer.CacheDirPath -ChildPath "vs17"

if($layoutFolderPath.Length -gt 80) {

$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"
$err = "Layout folder for VS17 is greater than 80 chars! - $help"

Write-ErrorMessage $err
throw $err
}

New-Folder $layoutFolderPath

Expand Down
4 changes: 4 additions & 0 deletions invoke-uplift/src/Invoke-Uplift-HTTP.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,16 @@ function Invoke-DownloadFile($src, $dst, $preferredTool = $null) {
if( $tools.wget.IsAvailable -eq $True) {
Invoke-DownloadFileAsWget $tools.wget $src $dst
return
} else {
Write-DebugMessage "wget is not here, fallback: wget -> curl -> InvokeWebRequest"
}

# is curl available?
if( $tools.curl.IsAvailable -eq $True) {
Invoke-DownloadFileAsCurl $tools.curl $src $dst
return
} else {
Write-DebugMessage "curl is not here, fallback: wget -> curl -> InvokeWebRequest"
}

# default is Invoke-WebRequest
Expand Down
6 changes: 2 additions & 4 deletions uplift.core/src/Uplift.Core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -750,11 +750,9 @@ function Repair-UpliftMachineKeys {
$fileName = $file.Name
if (!$fileName.EndsWith($machGUID))
{
cp "$machineKeyFolder\$fileName" "$machineKeyFolder\$fileName.OLD"
Copy-Item "$machineKeyFolder\$fileName" "$machineKeyFolder\$fileName.OLD"
Rename-Item "$machineKeyFolder\$fileName" "$key1$machGUID"
break


}
}

Expand All @@ -767,7 +765,7 @@ function Repair-UpliftMachineKeys {
$fileName = $file.Name
if (!$fileName.EndsWith($machGUID))
{
cp "$machineKeyFolder\$fileName" "$machineKeyFolder\$fileName.OLD"
Copy-Item "$machineKeyFolder\$fileName" "$machineKeyFolder\$fileName.OLD"
Rename-Item "$machineKeyFolder\$fileName" "$key2$machGUID"
break

Expand Down
15 changes: 8 additions & 7 deletions uplift.core/tests/integration/Uplift.Core.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ $srcPath = Resolve-Path "$dirPath/../../src"

$skipSourceInclude = $True

Describe 'uplift.core.integration' {
Context "Cdefault" {
It 'can import module' {
Import-Module Uplift.Core
}
}
}
Write-Host "PSHome: $PSHome"
Write-Host "Is64BitProcess: $([Environment]::Is64BitProcess)"

Write-Host "Listing installed modules:"
Get-InstalledModule

Write-Host "Importing module: Uplift.Core"
Import-Module Uplift.Core

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