wip
This commit is contained in:
parent
be156ab716
commit
d2582e7194
62
.drone.yml
62
.drone.yml
@ -1,7 +1,7 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Linux_PWSH7_Build
|
||||
name: PWSH_LTS_7.2_Ubuntu-focal
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
@ -9,7 +9,7 @@ platform:
|
||||
|
||||
steps:
|
||||
- name: Environments
|
||||
image: mcr.microsoft.com/powershell:latest
|
||||
image: mcr.microsoft.com/powershell:lts-7.2-ubuntu-focal
|
||||
commands:
|
||||
- |
|
||||
pwsh -NonInteractive -c "& {
|
||||
@ -18,7 +18,7 @@ steps:
|
||||
}"
|
||||
|
||||
- name: LintTests
|
||||
image: mcr.microsoft.com/powershell:latest
|
||||
image: mcr.microsoft.com/powershell:lts-7.2-ubuntu-focal
|
||||
failure: ignore
|
||||
commands:
|
||||
- |
|
||||
@ -29,7 +29,7 @@ steps:
|
||||
}"
|
||||
|
||||
- name: UnitTests
|
||||
image: mcr.microsoft.com/powershell:latest
|
||||
image: mcr.microsoft.com/powershell:lts-7.2-ubuntu-focal
|
||||
failure: ignore
|
||||
commands:
|
||||
- |
|
||||
@ -47,61 +47,11 @@ steps:
|
||||
files:
|
||||
- coverage.xml
|
||||
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: PWSH_LTS_7.2_Ubuntu-focal
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: Environments
|
||||
image: mcr.microsoft.com/powershell:lts-7.2-ubuntu-focal
|
||||
commands:
|
||||
- |
|
||||
pwsh -NonInteractive -c "& {
|
||||
Import-Module './tools/DroneIO.psm1' -Verbose;
|
||||
Invoke-ShowEnv -Verbose
|
||||
}"
|
||||
|
||||
- name: LintTests
|
||||
image: mcr.microsoft.com/powershell:lts-7.2-ubuntu-focal
|
||||
#failure: ignore
|
||||
commands:
|
||||
- |
|
||||
pwsh -NonInteractive -c "& {
|
||||
Import-Module './tools/DroneIO.psm1';
|
||||
Invoke-InstallDependencies;
|
||||
Invoke-Linter -ErrorAction 'Stop'
|
||||
}"
|
||||
|
||||
- name: UnitTests
|
||||
image: mcr.microsoft.com/powershell:lts-7.2-ubuntu-focal
|
||||
#failure: ignore
|
||||
commands:
|
||||
- |
|
||||
pwsh -NonInteractive -c "& {
|
||||
Import-Module './tools/DroneIO.psm1';
|
||||
Invoke-InstallDependencies;
|
||||
Invoke-UnitTest -Verbosity 'Detailed' -ErrorAction 'Stop'
|
||||
}"
|
||||
|
||||
- name: FinalState
|
||||
- name: SetPipelineState
|
||||
image: mcr.microsoft.com/powershell:lts-7.2-ubuntu-focal
|
||||
commands:
|
||||
- |
|
||||
pwsh -NonInteractive -c "& {
|
||||
Import-Module './tools/DroneIO.psm1';
|
||||
Invoke-ShowEnv -Verbose
|
||||
Invoke-BuildState -ErrorAction 'Stop'
|
||||
}"
|
||||
depends_on:
|
||||
- LintTests
|
||||
- UnitTests
|
||||
|
20
STATE.xml
Normal file
20
STATE.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
|
||||
<Obj RefId="0">
|
||||
<TN RefId="0">
|
||||
<T>System.Management.Automation.PSCustomObject</T>
|
||||
<T>System.Object</T>
|
||||
</TN>
|
||||
<MS>
|
||||
<Obj N="Steps" RefId="1">
|
||||
<TN RefId="1">
|
||||
<T>System.Object[]</T>
|
||||
<T>System.Array</T>
|
||||
<T>System.Object</T>
|
||||
</TN>
|
||||
<LST>
|
||||
<S>lint</S>
|
||||
</LST>
|
||||
</Obj>
|
||||
</MS>
|
||||
</Obj>
|
||||
</Objs>
|
@ -144,6 +144,7 @@ function Invoke-Linter {
|
||||
"RuleName",
|
||||
"Message"
|
||||
) -AutoSize | Out-String | Write-Verbose -Verbose
|
||||
Update-BuildStateFile
|
||||
throw 'PS Script Analyzer failed!'
|
||||
}
|
||||
}
|
||||
@ -203,6 +204,7 @@ function Invoke-UnitTest {
|
||||
$TestResults = Invoke-Pester -Configuration $PesterConf -ErrorAction 'Stop'
|
||||
|
||||
if ($TestResults.FailedCount -gt 0) {
|
||||
Update-BuildStateFile
|
||||
throw ('{0} tests failed!' -f $TestResults.FailedCount)
|
||||
}
|
||||
|
||||
@ -211,3 +213,38 @@ function Invoke-UnitTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Update-BuildStateFile {
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
[Parameter(Mandatory = $false)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$StepName = $Env:DRONE_FAILED_STEPS
|
||||
)
|
||||
|
||||
process {
|
||||
$StateFilePath = Join-Path -Path $PWD -ChildPath './STATE.xml'
|
||||
if (Test-Path -Path $StateFilePath) {
|
||||
$StateContent = Import-Clixml -Path $StateFilePath
|
||||
$StateContent.Steps += $StepName
|
||||
}
|
||||
else {
|
||||
$StateContent = [PSCustomObject]@{
|
||||
Steps = @($StepName)
|
||||
}
|
||||
}
|
||||
Export-Clixml -Path $StateFilePath -InputObject $StateContent -Force -Encoding utf8NoBOM
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-BuildState {
|
||||
[CmdletBinding()]
|
||||
param ()
|
||||
|
||||
process {
|
||||
$StateFilePath = Join-Path -Path $PWD -ChildPath './STATE.xml'
|
||||
if ( Test-Path -Path $StateFilePath ) {
|
||||
throw 'One one more pipeline steps failed. Marking the pipeline as failed!'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user