initial migration
Some checks reported errors
continuous-integration/drone/tag Build was killed

This commit is contained in:
2022-07-13 13:59:25 +02:00
parent 97761f112c
commit 8fd180b776
80 changed files with 3997 additions and 1 deletions

View File

@ -0,0 +1,32 @@
BeforeAll {
$Repo = Get-RepoPath
Import-Module $Repo.Src.Manifest.Item.FullName -Force
}
Describe 'Install-ModuleDependency' {
Context 'Default tests' -Tag 'Default' {
It 'Test Function' {
{ Get-Command -Name 'Install-ModuleDependency' -Module $Repo.Artifact } | Should -Not -Throw
}
It 'Test Help' {
{ Get-Help -Name 'Install-ModuleDependency' } | Should -Not -Throw
}
It 'Help Content' {
$foo = Get-Help -Name 'Install-ModuleDependency'
$foo.Synopsis.Length | Should -BeGreaterThan 5
$foo.Description.Count | Should -BeGreaterOrEqual 1
$foo.Description[0].Text.Length | Should -BeGreaterThan 5
}
}
Context 'Unit tests' -Tag 'Unit' {
It 'Should throw' {
{ Install-ModuleDependency -foo } | Should -Throw
}
#It 'Should not throw' {
# Mock 'Install-Module' -ModuleName $Repo.Artifact {}
# { Install-ModuleDependency } | Should -Not -Throw
#}
}
}

View File

@ -0,0 +1,74 @@
function Install-ModuleDependency {
<#
.SYNOPSIS
Install required modules of the module manifest file.
.DESCRIPTION
Use this cmdlet to install required modules of the module manifest file.
.INPUTS
[None]
.OUTPUTS
[None]
.EXAMPLE
Install-ModuleDependency
.NOTES
#>
[CmdletBinding()]
#[OutputType([String])]
param ()
begin {
}
process {
$Repo = Get-RepoPath
$ManifestContent = Import-PowerShellDataFile -Path $Repo.Src.Manifest.Item.FullName
if ($ManifestContent.RequiredModules) {
foreach ($Module in $ManifestContent.RequiredModules) {
if ($Module.RequiredVersion) {
$ParamsInstallModule = @{
Name = $Module.ModuleName
Scope = 'AllUsers'
RequiredVersion = $Module.RequiredVersion
Force = $true
AllowClobber = $true
Verbose = $VerbosePreference
ErrorAction = 'Stop'
}
}
else {
$ParamsInstallModule = @{
Name = $Module.ModuleName
Scope = 'AllUsers'
MinimumVersion = $Module.ModuleVersion
Force = $true
AllowClobber = $true
Verbose = $VerbosePreference
ErrorAction = 'Stop'
}
}
try {
Install-Module @ParamsInstallModule
$Message = 'Module <{0}> successfully installed' -f $Module.ModuleName
Write-Verbose -Message $Message
}
catch {
$Message = 'Module <{0}> could not be installed! ' -f $Module.ModuleName
$Message += $_.Exception.Message
Write-Error -Message $Message -ErrorAction 'Stop'
}
}
}
else {
Write-Verbose -Message 'no required modules found...'
}
}
end {
}
}

View File

@ -0,0 +1,21 @@
BeforeAll {
$Repo = Get-RepoPath
Import-Module $Repo.Src.Manifest.Item.FullName -Force
}
Describe 'Invoke-InstallDependency' {
Context 'Default tests' -Tag 'Default' {
It 'Test Function' {
{ Get-Command -Name 'Invoke-InstallDependency' -Module $Repo.Artifact } | Should -Not -Throw
}
It 'Test Help' {
{ Get-Help -Name 'Invoke-InstallDependency' } | Should -Not -Throw
}
It 'Help Content' {
$foo = Get-Help -Name 'Invoke-InstallDependency'
$foo.Synopsis.Length | Should -BeGreaterThan 5
$foo.Description.Count | Should -BeGreaterOrEqual 1
$foo.Description[0].Text.Length | Should -BeGreaterThan 5
}
}
}

View File

@ -0,0 +1,72 @@
function Invoke-InstallDependency {
<#
.SYNOPSIS
Install required modules for executing the DroneHelper pipeline helpers.
.DESCRIPTION
This can be used in drone.io docker pipeline if the modules are not integrated in the build image.
.INPUTS
[None] No Input required.
.OUTPUTS
[None] No Output
.EXAMPLE
Import-Module -Name DroneHelper; Invoke-Install-Dependency
#>
[CmdletBinding()]
[OutputType()]
param ()
process {
try {
$PSScriptParams = @{
Name = 'PSScriptAnalyzer'
Scope = 'CurrentUser'
RequiredVersion = '1.20.0'
Force = $true
SkipPublisherCheck = $true
AllowClobber = $true
Verbose = $VerbosePreference
ErrorAction = 'Stop'
}
Install-Module @PSScriptParams
$PesterParams = @{
Name = 'Pester'
Scope = 'CurrentUser'
RequiredVersion = '5.3.1'
Force = $true
SkipPublisherCheck = $true
AllowClobber = $true
Verbose = $VerbosePreference
ErrorAction = 'Stop'
}
Install-Module @PesterParams
$PoshParams = @{
Name = 'posh-git'
Scope = 'CurrentUser'
RequiredVersion = '1.0.0'
Force = $true
SkipPublisherCheck = $true
AllowClobber = $true
Verbose = $VerbosePreference
ErrorAction = 'Stop'
}
Install-Module @PoshParams
}
catch {
$ExecParams = @{
Exception = [System.Exception]::new(
'Could not install required build dependencies!',
$PSItem.Exception
)
ErrorAction = 'Stop'
}
Write-Error @ExecParams
}
}
}