This repository has been archived by the owner on Jul 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
147 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
kind: pipeline | ||
type: docker | ||
name: Linux_PWSH7_Build | ||
|
||
platform: | ||
os: linux | ||
arch: amd64 | ||
|
||
steps: | ||
- name: Environments | ||
image: mcr.microsoft.com/powershell:latest | ||
commands: | ||
- pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1' -Verbose; Invoke-ShowEnv -Verbose}" | ||
- pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1' -Verbose; Invoke-InstallDependencies -Verbose}" | ||
- name: LintTests | ||
image: mcr.microsoft.com/powershell:latest | ||
commands: | ||
- pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-InstallDependencies}" | ||
- pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-Linter}" | ||
- name: UnitTests | ||
image: mcr.microsoft.com/powershell:latest | ||
commands: | ||
- pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-InstallDependencies}" | ||
- pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-UnitTests}" | ||
- name: coverage | ||
image: plugins/codecov | ||
settings: | ||
token: | ||
from_secret: CodeCovToken | ||
files: | ||
- coverage.xml |
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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
$Global:ProgressPreference = 'SilentlyContinue' | ||
|
||
function Invoke-ShowEnv() { | ||
[CmdletBinding()] | ||
param() | ||
|
||
process { | ||
Get-ChildItem -Path 'Env:' | Format-Table | Out-String | ||
} | ||
} | ||
|
||
function Invoke-InstallDependencies() { | ||
[CmdletBinding()] | ||
[OutputType()] | ||
param() | ||
|
||
process { | ||
try { | ||
Install-Module -Name 'PSScriptAnalyzer' -Scope CurrentUser -RequiredVersion '1.19.1' -Force -SkipPublisherCheck -AllowClobber -Verbose:$VerbosePreference -ErrorAction 'Stop' | ||
Install-Module -Name 'Pester' -Scope CurrentUser -RequiredVersion '4.10.1' -Force -SkipPublisherCheck -AllowClobber -Verbose:$VerbosePreference -ErrorAction 'Stop' | ||
Install-Module -Name 'posh-git' -Scope CurrentUser -RequiredVersion '0.7.3' -Force -SkipPublisherCheck -AllowClobber -Verbose:$VerbosePreference -ErrorAction 'Stop' | ||
Install-Module -Name 'PSCoverage' -Scope CurrentUser -Force -SkipPublisherCheck -AllowClobber -RequiredVersion '1.2.108' -Verbose:$VerbosePreference -ErrorAction 'Stop' | ||
} | ||
catch { | ||
$ExceParams = @{ | ||
Exception = [System.Exception]::new( | ||
'Could not install required build dependencies!', | ||
$PSItem.Exception | ||
) | ||
ErrorAction = 'Stop' | ||
} | ||
Write-Error @ExceParams | ||
} | ||
|
||
} | ||
} | ||
|
||
function Invoke-Linter () { | ||
[CmdletBinding()] | ||
param() | ||
|
||
process { | ||
$LintRes = Invoke-ScriptAnalyzer -Path './src/' -Recurse | ||
if (-not ($Env:CI_COMMIT_MESSAGE -match 'SkipLint')) { | ||
if ($LintRes ) { | ||
$LintRes | Format-List | ||
Write-Error -Message 'Lint Errors found!' -ErrorAction Stop | ||
} | ||
else { | ||
Write-Host '== No Lint Errors found! ==' | ||
} | ||
} | ||
} | ||
} | ||
|
||
function Invoke-UnitTests { | ||
[CmdletBinding()] | ||
Param() | ||
|
||
process { | ||
|
||
try { | ||
Write-Host '===== Preload internal private functions =====' -ForegroundColor Black -BackgroundColor Yellow | ||
|
||
$Privates = Get-ChildItem -Path (Join-Path -Path $Env:DRONE_WORKSPACE -ChildPath '/src/Private/*') -Include "*.ps1" -Recurse -ErrorAction Stop | ||
foreach ($File in $Privates) { | ||
if (Test-Path -Path $File.FullName) { | ||
. $File.FullName | ||
Write-Verbose -Message ('Private function dot-sourced: {0}' -f $File.FullName) -Verbose | ||
} | ||
else { | ||
Write-Warning -Message ('Could not find file: {0} !' -f $File.FullName) | ||
} | ||
} | ||
} | ||
catch { | ||
$_.Exception.Message | Write-Error | ||
throw 'Could not load required private functions!' | ||
} | ||
|
||
Write-Host '===== Running Pester =====' -ForegroundColor Black -BackgroundColor Yellow | ||
$srcFiles = Get-ChildItem -Path "./src/*.ps1" -Recurse | Sort-Object -Property 'Name' | Select-Object -ExpandProperty 'FullName' | ||
$TestFiles = Get-ChildItem -Path (Join-Path -Path '.' -ChildPath './tests/*.Tests.ps1') -Recurse | Sort-Object -Property Name | ||
$TestResults = Invoke-Pester -Path $testFiles -CodeCoverage $srcFiles -PassThru -CodeCoverageOutputFile "./coverage.xml" -CodeCoverageOutputFileEncoding ascii -CodeCoverageOutputFileFormat JaCoCo | ||
|
||
if ($TestResults.FailedCount -gt 0) { | ||
throw ('{0} tests failed!' -f $TestResults.FailedCount) | ||
} | ||
} | ||
} |