forked from OCram85/PSCredentialStore
Modernize Build Pipeline (#48)
This commit is contained in:
parent
b6e791f709
commit
045adbf647
32
.drone.yml
Normal file
32
.drone.yml
Normal file
@ -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
|
@ -1,6 +1,7 @@
|
|||||||
[![AppVeyor branch](https://img.shields.io/appveyor/ci/OCram85/PSCredentialStore/master.svg?style=plastic "Master Branch Build Status")](https://ci.appveyor.com/project/OCram85/pscredentialstore/branch/master)
|
[![AppVeyor branch](https://img.shields.io/appveyor/ci/OCram85/PSCredentialStore/master.svg?style=plastic "Master Branch Build Status")](https://ci.appveyor.com/project/OCram85/pscredentialstore/branch/master)
|
||||||
[![AppVeyor tests branch](https://img.shields.io/appveyor/tests/OCram85/PSCredentialStore/master.svg?style=plastic "Pester Tests Results")](https://ci.appveyor.com/project/OCram85/pscredentialstore/branch/master/tests)
|
[![AppVeyor tests branch](https://img.shields.io/appveyor/tests/OCram85/PSCredentialStore/master.svg?style=plastic "Pester Tests Results")](https://ci.appveyor.com/project/OCram85/pscredentialstore/branch/master/tests)
|
||||||
[![Coveralls github](https://img.shields.io/coveralls/github/OCram85/PSCredentialStore.svg?style=plastic "Coveralls.io Coverage Report")](https://coveralls.io/github/OCram85/PSCredentialStore?branch=master)
|
[![Coveralls github](https://img.shields.io/coveralls/github/OCram85/PSCredentialStore.svg?style=plastic "Coveralls.io Coverage Report")](https://coveralls.io/github/OCram85/PSCredentialStore?branch=master)
|
||||||
|
[![codecov](https://codecov.io/gh/OCram85/PSCredentialStore/branch/master/graph/badge.svg)](https://codecov.io/gh/OCram85/PSCredentialStore)
|
||||||
[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/PSCredentialStore.svg?style=plastic "PowershellGallery Published Version")](https://www.powershellgallery.com/packages/PSCredentialStore)
|
[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/PSCredentialStore.svg?style=plastic "PowershellGallery Published Version")](https://www.powershellgallery.com/packages/PSCredentialStore)
|
||||||
[![PowerShell Gallery](https://img.shields.io/powershellgallery/vpre/PSCredentialStore.svg?label=latest%20preview&style=plastic "PowershellGallery Latest Preview Version")](https://www.powershellgallery.com/packages/PSCredentialStore)
|
[![PowerShell Gallery](https://img.shields.io/powershellgallery/vpre/PSCredentialStore.svg?label=latest%20preview&style=plastic "PowershellGallery Latest Preview Version")](https://www.powershellgallery.com/packages/PSCredentialStore)
|
||||||
[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/PSCredentialStore.svg?style=plastic "PowershellGallery Downloads")](https://www.powershellgallery.com/packages/PSCredentialStore)
|
[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/PSCredentialStore.svg?style=plastic "PowershellGallery Downloads")](https://www.powershellgallery.com/packages/PSCredentialStore)
|
||||||
|
13
appveyor.yml
13
appveyor.yml
@ -1,6 +1,8 @@
|
|||||||
# pre release version:
|
# pre release version:
|
||||||
version: 1.0.{build}
|
version: 1.0.{build}
|
||||||
|
|
||||||
|
#cache:
|
||||||
|
|
||||||
#branches:
|
#branches:
|
||||||
# only:
|
# only:
|
||||||
# - master
|
# - master
|
||||||
@ -9,9 +11,7 @@ version: 1.0.{build}
|
|||||||
|
|
||||||
skip_tags: true
|
skip_tags: true
|
||||||
|
|
||||||
#image: WMF 5
|
image: Visual Studio 2019
|
||||||
# Test ne build image:
|
|
||||||
image: Visual Studio 2017
|
|
||||||
|
|
||||||
# Install pester module and init the Appveyor support.
|
# Install pester module and init the Appveyor support.
|
||||||
|
|
||||||
@ -28,6 +28,8 @@ environment:
|
|||||||
secure: 835qfZIkC9mE7QhkYfOZVAdR8rZhPvxG8BO4CbeaelRQOhlqmaSr8G1DWRJzZ/bS
|
secure: 835qfZIkC9mE7QhkYfOZVAdR8rZhPvxG8BO4CbeaelRQOhlqmaSr8G1DWRJzZ/bS
|
||||||
CoverallsToken:
|
CoverallsToken:
|
||||||
secure: eTjWqHL48MBr8wp1rSgLrXHdtpfDV/uClacP3svlWJfCvn/zVokpuaMnWM5RoyIY
|
secure: eTjWqHL48MBr8wp1rSgLrXHdtpfDV/uClacP3svlWJfCvn/zVokpuaMnWM5RoyIY
|
||||||
|
CodeCovToken:
|
||||||
|
secure: LJOvamWIlVORDE7120KcmWVkHxOFYBSN99linyICXXmXLtYm81K/31YeMGiPlgTm
|
||||||
|
|
||||||
build: false
|
build: false
|
||||||
|
|
||||||
@ -59,15 +61,14 @@ deploy:
|
|||||||
- provider: GitHub
|
- provider: GitHub
|
||||||
auth_token:
|
auth_token:
|
||||||
secure: M+bBX5/nKdJB0eViP7xtrLVTwf3vGDUA9N2MMprZp2i+9ZR3CBVcJnSzJWUmalhB
|
secure: M+bBX5/nKdJB0eViP7xtrLVTwf3vGDUA9N2MMprZp2i+9ZR3CBVcJnSzJWUmalhB
|
||||||
artifact: PSCredentialStore.zip # upload all NuGet packages to release assets
|
artifact: PSCredentialStore.zip # upload all NuGet packages to release assets
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
on:
|
on:
|
||||||
branch: master # build release on master branch changes
|
branch: master # build release on master branch changes
|
||||||
|
|
||||||
after_deploy:
|
after_deploy:
|
||||||
- ps: Invoke-AppVeyorPSGallery -OnBranch 'master'
|
- ps: Invoke-AppVeyorPSGallery -OnBranch 'master'
|
||||||
|
|
||||||
# Pause build until `lock` on desktop is deleted.
|
# Pause build until `lock` on desktop is deleted.
|
||||||
#on_finish:
|
#on_finish:
|
||||||
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
CompanyName = ''
|
CompanyName = ''
|
||||||
|
|
||||||
# Copyright statement for this module
|
# Copyright statement for this module
|
||||||
Copyright = '(c) 2019 OCram85. All rights reserved.'
|
Copyright = '(c) 2020 OCram85. All rights reserved.'
|
||||||
|
|
||||||
# Description of the functionality provided by this module
|
# Description of the functionality provided by this module
|
||||||
Description = 'A simple credential manager to store and reuse multiple credential objects.'
|
Description = 'A simple credential manager to store and reuse multiple credential objects.'
|
||||||
|
@ -16,13 +16,19 @@ Function Invoke-InstallDependencies() {
|
|||||||
|
|
||||||
Process {
|
Process {
|
||||||
Try {
|
Try {
|
||||||
|
Write-Host 'Available PS modules are:' -ForegroundColor Green -BackgroundColor Black
|
||||||
|
Get-Module -ListAvailable -Name Pester | Format-Table | Out-String
|
||||||
Get-PackageProvider -ListAvailable
|
Get-PackageProvider -ListAvailable
|
||||||
Install-PackageProvider -Name NuGet -RequiredVersion '2.8.5.208' -Force -Verbose
|
Install-PackageProvider -Name NuGet -RequiredVersion '2.8.5.208' -Force -Verbose
|
||||||
Import-PackageProvider -Name NuGet -RequiredVersion '2.8.5.208' -Force
|
Import-PackageProvider -Name NuGet -RequiredVersion '2.8.5.208' -Force
|
||||||
Install-Module -Name 'Pester' -Scope CurrentUser -RequiredVersion '4.4.2' -Force -SkipPublisherCheck -AllowClobber
|
Write-Host 'Installing build deps...' -ForegroundColor Red -BackgroundColor Black
|
||||||
Install-Module -Name 'posh-git' -Scope CurrentUser -RequiredVersion '1.0.0-beta2' -Force -SkipPublisherCheck -AllowClobber -AllowPrerelease
|
Install-Module -Name 'Pester' -Scope CurrentUser -RequiredVersion '4.10.1' -Force -SkipPublisherCheck -AllowClobber -Verbose
|
||||||
Install-Module -Name 'PSCoverage' -Scope CurrentUser -Force -SkipPublisherCheck -AllowClobber -RequiredVersion '1.0.78'
|
Install-Module -Name 'posh-git' -Scope CurrentUser -RequiredVersion '0.7.3' -Force -SkipPublisherCheck -AllowClobber
|
||||||
Import-Module -Name 'Pester', 'posh-git' , 'PSCoverage'
|
Install-Module -Name 'PSCoverage' -Scope CurrentUser -Force -SkipPublisherCheck -AllowClobber -RequiredVersion '1.2.108' -Verbose
|
||||||
|
Import-Module -Name 'posh-git'
|
||||||
|
Remove-Module -Name 'Pester' -Force -ErrorAction SilentlyContinue
|
||||||
|
Import-Module -Name 'Pester' -RequiredVersion '4.10.1' -Verbose -Force
|
||||||
|
Import-Module -Name 'PSCoverage' -RequiredVersion '1.2.108' -Verbose -Force
|
||||||
}
|
}
|
||||||
Catch {
|
Catch {
|
||||||
$MsgParams = @{
|
$MsgParams = @{
|
||||||
@ -33,7 +39,8 @@ Function Invoke-InstallDependencies() {
|
|||||||
Add-AppveyorMessage @MsgParams
|
Add-AppveyorMessage @MsgParams
|
||||||
Throw $MsgParams.Message
|
Throw $MsgParams.Message
|
||||||
}
|
}
|
||||||
|
Write-Host 'Loaded PS modules are:' -ForegroundColor Green -BackgroundColor Black
|
||||||
|
Get-Module -Name Pester | Format-Table | Out-String
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Function Invoke-AppVeyorBumpVersion() {
|
Function Invoke-AppVeyorBumpVersion() {
|
||||||
@ -42,7 +49,7 @@ Function Invoke-AppVeyorBumpVersion() {
|
|||||||
|
|
||||||
Write-Host "Listing Env Vars for debugging:" -ForegroundColor Black -BackgroundColor Yellow
|
Write-Host "Listing Env Vars for debugging:" -ForegroundColor Black -BackgroundColor Yellow
|
||||||
# Filter Results to prevent exposing secure vars.
|
# Filter Results to prevent exposing secure vars.
|
||||||
Get-ChildItem -Path "Env:*" | Where-Object { $_.name -notmatch "(NuGetToken|CoverallsToken)"} | Sort-Object -Property Name | Format-Table
|
Get-ChildItem -Path "Env:*" | Where-Object { $_.name -notmatch "(NuGetToken|CoverallsToken|CodeCovToken)" } | Sort-Object -Property Name | Format-Table
|
||||||
|
|
||||||
Try {
|
Try {
|
||||||
$ModManifest = Get-Content -Path (".\src\{0}.psd1" -f $CALLSIGN)
|
$ModManifest = Get-Content -Path (".\src\{0}.psd1" -f $CALLSIGN)
|
||||||
@ -112,6 +119,7 @@ Function Invoke-AppVeyorTests() {
|
|||||||
Write-Warning -Message ('Could not find file: {0} !' -f $File.FullName)
|
Write-Warning -Message ('Could not find file: {0} !' -f $File.FullName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Write-Host '===== Preload done. =====' -ForegroundColor Black -BackgroundColor Yellow
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
$_.Exception.Message | Write-Error
|
$_.Exception.Message | Write-Error
|
||||||
@ -121,7 +129,7 @@ Function Invoke-AppVeyorTests() {
|
|||||||
#$testresults = Invoke-Pester -Path ( Get-ChildItem -Path ".\tests\*.Tests.ps1" -Recurse | Sort-Object -Property Name ) -ExcludeTag 'Disabled' -PassThru
|
#$testresults = Invoke-Pester -Path ( Get-ChildItem -Path ".\tests\*.Tests.ps1" -Recurse | Sort-Object -Property Name ) -ExcludeTag 'Disabled' -PassThru
|
||||||
$srcFiles = Get-ChildItem -Path ".\src\*.ps1" -Recurse | Sort-Object -Property 'Name' | Select-Object -ExpandProperty 'FullName'
|
$srcFiles = Get-ChildItem -Path ".\src\*.ps1" -Recurse | Sort-Object -Property 'Name' | Select-Object -ExpandProperty 'FullName'
|
||||||
$testFiles = Get-ChildItem -Path ".\tests\*.Tests.ps1" -Recurse | Sort-Object -Property 'Name' | Select-Object -ExpandProperty 'FullName'
|
$testFiles = Get-ChildItem -Path ".\tests\*.Tests.ps1" -Recurse | Sort-Object -Property 'Name' | Select-Object -ExpandProperty 'FullName'
|
||||||
$TestResults = Invoke-Pester -Path $testFiles -CodeCoverage $srcFiles -PassThru
|
$TestResults = Invoke-Pester -Path $testFiles -CodeCoverage $srcFiles -PassThru -CodeCoverageOutputFile ".\coverage.xml" -CodeCoverageOutputFileEncoding ascii -CodeCoverageOutputFileFormat JaCoCo
|
||||||
ForEach ($Item in $TestResults.TestResult) {
|
ForEach ($Item in $TestResults.TestResult) {
|
||||||
Switch ($Item.Result) {
|
Switch ($Item.Result) {
|
||||||
"Passed" {
|
"Passed" {
|
||||||
@ -193,6 +201,7 @@ Function Invoke-CoverageReport() {
|
|||||||
Publish-CoverageReport -CoverageReport $CoverageReport
|
Publish-CoverageReport -CoverageReport $CoverageReport
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Function Invoke-AppVeyorPSGallery() {
|
Function Invoke-AppVeyorPSGallery() {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
Param(
|
Param(
|
||||||
|
90
tools/DroneIO.psm1
Normal file
90
tools/DroneIO.psm1
Normal file
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user