-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* dev: Add new version notes Increment version Update helper function name and add tests in module scope Update helper function name Removed as no longer needed Update text case of referenced files Change language to en-US Fix typo Update module template and add PSDepend Add module build options and IB tasks Add code to test for running as administrator Remove duplication of build helpers output
- Loading branch information
Showing
25 changed files
with
279 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,85 @@ | ||
[CmdletBinding()] | ||
Param ( | ||
$Task = 'build' | ||
$Task = 'build', | ||
|
||
# skips the initialization of the environment, which can be slow, and jumps | ||
# straight to the build script | ||
[switch] | ||
$Bootstrap | ||
) | ||
|
||
$dependModules = @( | ||
@{ | ||
Name = 'InvokeBuild' | ||
}, | ||
@{ | ||
Name = 'Configuration' | ||
}, | ||
@{ | ||
Name = 'PowerShellBuild' | ||
MinimumVersion = '0.3.0-beta' | ||
AllowPrerelease = $true | ||
}, | ||
@{ | ||
Name = 'Pester' | ||
MinimumVersion = 4.4.3 | ||
function Test-Administrator { | ||
if ($PSVersionTable.Platform -ne 'Unix') { | ||
$user = [Security.Principal.WindowsIdentity]::GetCurrent(); | ||
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) | ||
} else { | ||
# TODO: We are running in Linux so assume (at this stage) we have root / Admin - this needs resolved | ||
$true | ||
} | ||
@{ | ||
Name = 'PSScriptAnalyzer' | ||
MinimumVersion = '1.17.1' | ||
} | ||
|
||
if ($Bootstrap.IsPresent) { | ||
|
||
$dependencies = @{ | ||
InvokeBuild = 'latest' | ||
Configuration = 'latest' | ||
PowerShellBuild = 'latest' | ||
Pester = 'latest' | ||
PSScriptAnalyzer = 'latest' | ||
PSPesterTestHelpers = 'latest' # I don't trust this Warren guy... | ||
PSDeploy = 'latest' # Maybe pin the version in case he breaks this... | ||
} | ||
|
||
# dependencies | ||
if (-not (Get-Command -Name 'Get-PackageProvider' -ErrorAction SilentlyContinue)) { | ||
$null = Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | ||
Write-Verbose 'Bootstrapping NuGet package provider.' | ||
Get-PackageProvider -Name NuGet -ForceBootstrap | Out-Null | ||
} elseif ((Get-PackageProvider).Name -notcontains 'nuget') { | ||
Write-Verbose 'Bootstrapping NuGet package provider.' | ||
Get-PackageProvider -Name NuGet -ForceBootstrap | ||
} | ||
) | ||
|
||
.\Initialize-Build.ps1 -RequiredModule $dependModules -Verbose:$VerbosePreference | ||
#. .\tests\TestHelpers.ps1 | ||
# Trust the PSGallery is needed | ||
if ((Get-PSRepository -Name PSGallery).InstallationPolicy -ne 'Trusted') { | ||
Write-Verbose "Trusting PowerShellGallery." | ||
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | ||
} | ||
|
||
function global:Import-HelperModuleForTesting { | ||
# build the filename | ||
$moduleScript = "{0}\{1}.psm1" -f $env:BHBuildOutput, $env:BHProjectName | ||
if (Test-Path -Path $moduleScript) { | ||
Remove-Module -Name $moduleScript -ErrorAction SilentlyContinue | ||
Import-Module -Name $moduleScript -Force -ErrorAction Stop | ||
Install-Module -Name PSDepend | ||
|
||
$importedModule = Get-Module -Name $env:BHProjectName | ||
Write-Verbose "Imported module '$($importedModule.Path)'" | ||
if (Test-Administrator) { | ||
$dependencies | Invoke-PSDepend -Import -Install -Force | ||
} else { | ||
Write-Warning "Not running as Administrator - could not initialize build environment." | ||
} | ||
else { | ||
throw "Module manifest '$moduleScript' does not exist!" | ||
|
||
# Configure git | ||
if ($null -eq (Invoke-Expression -Command 'git config --get user.email')) { | ||
Write-Verbose 'Git is not configured so we need to configure it now.' | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "pauby" | ||
git config --global core.safecrlf false | ||
} | ||
} | ||
|
||
# # Used in Pester tests to import the built module and not a module already installed on the system | ||
# function global:Import-PTHBuildModule { | ||
# # build the filename | ||
# $moduleScript = "{0}\{1}.psm1" -f $env:BHBuildOutput, $env:BHProjectName | ||
# if (Test-Path -Path $moduleScript) { | ||
# Remove-Module -Name $moduleScript -ErrorAction SilentlyContinue | ||
# Import-Module -Name $moduleScript -Force -ErrorAction Stop | ||
|
||
# $importedModule = Get-Module -Name $env:BHProjectName | ||
# Write-Verbose "Imported module '$($importedModule.Path)'" | ||
# } else { | ||
# throw "Module manifest '$moduleScript' does not exist!" | ||
# } | ||
# } | ||
|
||
Write-Host "Tag : $($env:CI_COMMIT_TAG)`nBranch : $($env:CI_COMMIT_REF_NAME)" | ||
|
||
Invoke-Build -File .\.pstodotxt.build.ps1 -Task $Task -Verbose:$VerbosePreference | ||
|
||
Remove-Item function:Import-HelpersModuleForTesting -ErrorAction SilentlyContinue |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Import-HelperModuleForTesting | ||
Import-PTHBuildModule | ||
|
||
Describe "Integration Testing - PSTodoTxt" { | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.