From 9b2ca57a8d85a3468108da12da1a0965ff8f62d8 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Thu, 4 Jun 2020 08:59:55 +0200 Subject: [PATCH 01/20] update meta data --- src/PSCredentialStore.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PSCredentialStore.psd1 b/src/PSCredentialStore.psd1 index 35ae51b..e77283e 100644 --- a/src/PSCredentialStore.psd1 +++ b/src/PSCredentialStore.psd1 @@ -19,7 +19,7 @@ CompanyName = '' # 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 = 'A simple credential manager to store and reuse multiple credential objects.' -- 2.40.1 From b0a5ccd19287f615822d31cb681055de539f08c4 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Thu, 4 Jun 2020 09:23:55 +0200 Subject: [PATCH 02/20] add pester debug output --- appveyor.yml | 26 ++++++++++++++--------- tools/AppVeyor.psm1 | 52 ++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 63 insertions(+), 15 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index a1d8a37..3d0213d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -28,6 +28,8 @@ environment: secure: 835qfZIkC9mE7QhkYfOZVAdR8rZhPvxG8BO4CbeaelRQOhlqmaSr8G1DWRJzZ/bS CoverallsToken: secure: eTjWqHL48MBr8wp1rSgLrXHdtpfDV/uClacP3svlWJfCvn/zVokpuaMnWM5RoyIY + CodeCovToken: + secure: LJOvamWIlVORDE7120KcmWVkHxOFYBSN99linyICXXmXLtYm81K/31YeMGiPlgTm build: false @@ -38,14 +40,19 @@ build_script: - ps: Invoke-AppVeyorBuild test_script: + #- ps: | + # $CodeCoverage = Invoke-AppVeyorTests + # if ($null -ne $Env:CoverallsToken) { + # Invoke-CoverageReport -PesterCoverageReport $CodeCoverage + # } + # else { + # Write-Warning "No CoverallsToken found. This build seems to be triggered by a PR. Skipping this step..." + # } - ps: | - $CodeCoverage = Invoke-AppVeyorTests - if ($null -ne $Env:CoverallsToken) { - Invoke-CoverageReport -PesterCoverageReport $CodeCoverage - } - else { - Write-Warning "No CoverallsToken found. This build seems to be triggered by a PR. Skipping this step..." - } + Invoke-CodeCoveTests + $env:PATH = 'C:\msys64\usr\bin;' + $env:PATH + Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh + bash codecov.sh -f "coverage.xml" -t $Env:CodeCovToken deploy: #- provider: GitHub @@ -59,15 +66,14 @@ deploy: - provider: GitHub auth_token: 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 prerelease: false on: - branch: master # build release on master branch changes + branch: master # build release on master branch changes after_deploy: - ps: Invoke-AppVeyorPSGallery -OnBranch 'master' - # Pause build until `lock` on desktop is deleted. #on_finish: # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) diff --git a/tools/AppVeyor.psm1 b/tools/AppVeyor.psm1 index 52069be..f412b82 100644 --- a/tools/AppVeyor.psm1 +++ b/tools/AppVeyor.psm1 @@ -16,13 +16,19 @@ Function Invoke-InstallDependencies() { Process { Try { + Write-Host 'Available PS modules are:' -ForegroundColor Green -BackgroundColor Black + Get-Module -ListAvailable -Name Pester | Format-Table | Out-String Get-PackageProvider -ListAvailable Install-PackageProvider -Name NuGet -RequiredVersion '2.8.5.208' -Force -Verbose 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 'Pester' -Scope CurrentUser -RequiredVersion '4.10.1' -Force -SkipPublisherCheck -AllowClobber -Verbose Install-Module -Name 'posh-git' -Scope CurrentUser -RequiredVersion '1.0.0-beta2' -Force -SkipPublisherCheck -AllowClobber -AllowPrerelease - Install-Module -Name 'PSCoverage' -Scope CurrentUser -Force -SkipPublisherCheck -AllowClobber -RequiredVersion '1.0.78' - Import-Module -Name 'Pester', 'posh-git' , 'PSCoverage' + #Install-Module -Name 'PSCoverage' -Scope CurrentUser -Force -SkipPublisherCheck -AllowClobber -RequiredVersion '1.0.78' + Import-Module -Name 'posh-git' + #Import-Module -Name 'PSCoverage' + Remove-Module -Name 'Pester' -Force -ErrorAction SilentlyContinue + Import-Module -Name 'Pester' -RequiredVersion '4.10.1' -Verbose } Catch { $MsgParams = @{ @@ -33,7 +39,8 @@ Function Invoke-InstallDependencies() { Add-AppveyorMessage @MsgParams Throw $MsgParams.Message } - + Write-Host 'Loaded PS modules are:' -ForegroundColor Green -BackgroundColor Black + Get-Module -Name Pester | Format-Table | Out-String } } Function Invoke-AppVeyorBumpVersion() { @@ -42,7 +49,7 @@ Function Invoke-AppVeyorBumpVersion() { Write-Host "Listing Env Vars for debugging:" -ForegroundColor Black -BackgroundColor Yellow # 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)" } | Sort-Object -Property Name | Format-Table Try { $ModManifest = Get-Content -Path (".\src\{0}.psd1" -f $CALLSIGN) @@ -174,6 +181,41 @@ Function Invoke-AppVeyorTests() { } +Function Invoke-CodeCoveTests() { + [CmdletBinding()] + Param() + + $MsgParams = @{ + Message = 'Starting Pester tests' + Category = 'Information' + Details = 'Now running all test found in .\tests\ dir.' + } + Add-AppveyorMessage @MsgParams + + try { + Write-Host '===== Preload internal private functions =====' -ForegroundColor Black -BackgroundColor Yellow + + $Privates = Get-ChildItem -Path (Join-Path -Path $Env:APPVEYOR_BUILD_FOLDER -ChildPath '/src/Private/*') -Include "*.ps1" -Recurse + 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!' + } + + #$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' + $testFiles = Get-ChildItem -Path ".\tests\*.Tests.ps1" -Recurse | Sort-Object -Property 'Name' | Select-Object -ExpandProperty 'FullName' + $PesterRes = Invoke-Pester -Path $testFiles -CodeCoverage $srcFiles -CodeCoverageOutputFile ".\coverage.xml" -CodeCoverageOutputFileEncoding ascii -CodeCoverageOutputFileFormat JaCoCo +} Function Invoke-CoverageReport() { [CmdletBinding()] Param( -- 2.40.1 From 117f29886bd2be5d003c5d9999af0f435e3884f2 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Thu, 4 Jun 2020 14:38:16 +0200 Subject: [PATCH 03/20] add CodeCov reports --- appveyor.yml | 23 ++++++++++++++++++----- tools/AppVeyor.psm1 | 11 ++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 3d0213d..29d0b90 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,8 @@ # pre release version: version: 1.0.{build} +cache: + #branches: # only: # - master @@ -40,6 +42,17 @@ build_script: - ps: Invoke-AppVeyorBuild test_script: + - ps: | + $CodeCoverage = Invoke-AppVeyorTests + if ($null -ne $Env:CoverallsToken) { + Invoke-CoverageReport -PesterCoverageReport $CodeCoverage + } + else { + Write-Warning "No CoverallsToken found. This build seems to be triggered by a PR. Skipping this step..." + } + $env:PATH = 'C:\msys64\usr\bin;' + $env:PATH + Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh + bash codecov.sh -f "coverage.xml" -t $Env:CodeCovToken #- ps: | # $CodeCoverage = Invoke-AppVeyorTests # if ($null -ne $Env:CoverallsToken) { @@ -48,11 +61,11 @@ test_script: # else { # Write-Warning "No CoverallsToken found. This build seems to be triggered by a PR. Skipping this step..." # } - - ps: | - Invoke-CodeCoveTests - $env:PATH = 'C:\msys64\usr\bin;' + $env:PATH - Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh - bash codecov.sh -f "coverage.xml" -t $Env:CodeCovToken + #- ps: | + # Invoke-CodeCoveTests + # $env:PATH = 'C:\msys64\usr\bin;' + $env:PATH + # Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh + # bash codecov.sh -f "coverage.xml" -t $Env:CodeCovToken deploy: #- provider: GitHub diff --git a/tools/AppVeyor.psm1 b/tools/AppVeyor.psm1 index f412b82..80f81b8 100644 --- a/tools/AppVeyor.psm1 +++ b/tools/AppVeyor.psm1 @@ -23,12 +23,12 @@ Function Invoke-InstallDependencies() { Import-PackageProvider -Name NuGet -RequiredVersion '2.8.5.208' -Force Write-Host 'Installing build deps...' -ForegroundColor Red -BackgroundColor Black Install-Module -Name 'Pester' -Scope CurrentUser -RequiredVersion '4.10.1' -Force -SkipPublisherCheck -AllowClobber -Verbose - Install-Module -Name 'posh-git' -Scope CurrentUser -RequiredVersion '1.0.0-beta2' -Force -SkipPublisherCheck -AllowClobber -AllowPrerelease - #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 -AllowPrerelease + Install-Module -Name 'PSCoverage' -Scope CurrentUser -Force -SkipPublisherCheck -AllowClobber -RequiredVersion '1.1.89' -Verbose Import-Module -Name 'posh-git' - #Import-Module -Name 'PSCoverage' Remove-Module -Name 'Pester' -Force -ErrorAction SilentlyContinue - Import-Module -Name 'Pester' -RequiredVersion '4.10.1' -Verbose + Import-Module -Name 'Pester' -RequiredVersion '4.10.1' -Verbose -Force + Import-Module -Name 'PSCoverage' -RequiredVersion '1.1.89' -Verbose -Force } Catch { $MsgParams = @{ @@ -119,6 +119,7 @@ Function Invoke-AppVeyorTests() { Write-Warning -Message ('Could not find file: {0} !' -f $File.FullName) } } + Write-Host '===== Preload done. =====' -ForegroundColor Black -BackgroundColor Yellow } catch { $_.Exception.Message | Write-Error @@ -128,7 +129,7 @@ Function Invoke-AppVeyorTests() { #$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' $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) { Switch ($Item.Result) { "Passed" { -- 2.40.1 From 432108c18a2477979af3d43647a0674ad04ca85b Mon Sep 17 00:00:00 2001 From: OCram85 Date: Wed, 26 Aug 2020 14:28:23 +0200 Subject: [PATCH 04/20] test alternate buld image --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 29d0b90..e518f0d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,7 +13,7 @@ skip_tags: true #image: WMF 5 # Test ne build image: -image: Visual Studio 2017 +image: Visual Studio 2013 # Install pester module and init the Appveyor support. -- 2.40.1 From 19f37147300238576004fdd230ff7c965e525a7a Mon Sep 17 00:00:00 2001 From: OCram85 Date: Wed, 26 Aug 2020 14:31:54 +0200 Subject: [PATCH 05/20] fix powershellget syntax for alternate build image --- tools/AppVeyor.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/AppVeyor.psm1 b/tools/AppVeyor.psm1 index 80f81b8..3e2e532 100644 --- a/tools/AppVeyor.psm1 +++ b/tools/AppVeyor.psm1 @@ -23,7 +23,7 @@ Function Invoke-InstallDependencies() { Import-PackageProvider -Name NuGet -RequiredVersion '2.8.5.208' -Force Write-Host 'Installing build deps...' -ForegroundColor Red -BackgroundColor Black Install-Module -Name 'Pester' -Scope CurrentUser -RequiredVersion '4.10.1' -Force -SkipPublisherCheck -AllowClobber -Verbose - Install-Module -Name 'posh-git' -Scope CurrentUser -RequiredVersion '0.7.3' -Force -SkipPublisherCheck -AllowClobber -AllowPrerelease + Install-Module -Name 'posh-git' -Scope CurrentUser -RequiredVersion '0.7.3' -Force -SkipPublisherCheck -AllowClobber Install-Module -Name 'PSCoverage' -Scope CurrentUser -Force -SkipPublisherCheck -AllowClobber -RequiredVersion '1.1.89' -Verbose Import-Module -Name 'posh-git' Remove-Module -Name 'Pester' -Force -ErrorAction SilentlyContinue -- 2.40.1 From a766ee95a0716541d458094a58e45bbf22acdc0e Mon Sep 17 00:00:00 2001 From: OCram85 Date: Mon, 28 Sep 2020 13:06:46 +0200 Subject: [PATCH 06/20] update pscoverage --- tools/AppVeyor.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/AppVeyor.psm1 b/tools/AppVeyor.psm1 index 3e2e532..e1fc43d 100644 --- a/tools/AppVeyor.psm1 +++ b/tools/AppVeyor.psm1 @@ -24,7 +24,7 @@ Function Invoke-InstallDependencies() { Write-Host 'Installing build deps...' -ForegroundColor Red -BackgroundColor Black Install-Module -Name 'Pester' -Scope CurrentUser -RequiredVersion '4.10.1' -Force -SkipPublisherCheck -AllowClobber -Verbose Install-Module -Name 'posh-git' -Scope CurrentUser -RequiredVersion '0.7.3' -Force -SkipPublisherCheck -AllowClobber - Install-Module -Name 'PSCoverage' -Scope CurrentUser -Force -SkipPublisherCheck -AllowClobber -RequiredVersion '1.1.89' -Verbose + 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 -- 2.40.1 From db8c04c00866e0c637c111a887f09583cfdafec3 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Mon, 28 Sep 2020 13:10:40 +0200 Subject: [PATCH 07/20] fix coverall upload --- tools/AppVeyor.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/AppVeyor.psm1 b/tools/AppVeyor.psm1 index e1fc43d..04bdc6a 100644 --- a/tools/AppVeyor.psm1 +++ b/tools/AppVeyor.psm1 @@ -28,7 +28,7 @@ Function Invoke-InstallDependencies() { 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.1.89' -Verbose -Force + Import-Module -Name 'PSCoverage' -RequiredVersion '1.2.108' -Verbose -Force } Catch { $MsgParams = @{ -- 2.40.1 From b9e884a2e6b46c9b0744639cbb648c891139d618 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Mon, 28 Sep 2020 13:10:57 +0200 Subject: [PATCH 08/20] ignore curl output --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index e518f0d..404eee3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -52,7 +52,7 @@ test_script: } $env:PATH = 'C:\msys64\usr\bin;' + $env:PATH Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh - bash codecov.sh -f "coverage.xml" -t $Env:CodeCovToken + Invoke-Expression "bash codecov.sh -f 'coverage.xml' -t $Env:CodeCovToken" 2<&1 #- ps: | # $CodeCoverage = Invoke-AppVeyorTests # if ($null -ne $Env:CoverallsToken) { -- 2.40.1 From 697e443a5984fa30f3e6de3108e9642ad9145c30 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Mon, 28 Sep 2020 13:12:32 +0200 Subject: [PATCH 09/20] add CodeCove badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5d14b26..864d043 100644 --- a/README.md +++ b/README.md @@ -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 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) +[![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/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) -- 2.40.1 From bc6ac5cd73805e2a60c27cab5ae9af2a871997a5 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Mon, 28 Sep 2020 13:39:59 +0200 Subject: [PATCH 10/20] fix typo --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 404eee3..a669a91 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -52,7 +52,7 @@ test_script: } $env:PATH = 'C:\msys64\usr\bin;' + $env:PATH Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh - Invoke-Expression "bash codecov.sh -f 'coverage.xml' -t $Env:CodeCovToken" 2<&1 + Invoke-Expression "bash codecov.sh -f 'coverage.xml' -t $Env:CodeCovToken" 2>&1 #- ps: | # $CodeCoverage = Invoke-AppVeyorTests # if ($null -ne $Env:CoverallsToken) { -- 2.40.1 From 42f47eb95aa9f29ea975962a41e80bc5e661c37c Mon Sep 17 00:00:00 2001 From: OCram85 Date: Thu, 1 Oct 2020 14:06:51 +0200 Subject: [PATCH 11/20] Cleanup helper function --- appveyor.yml | 26 +++++++---------------- tools/AppVeyor.psm1 | 50 ++++++++++++++------------------------------- 2 files changed, 22 insertions(+), 54 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index a669a91..2cffc72 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,9 +11,7 @@ cache: skip_tags: true -#image: WMF 5 -# Test ne build image: -image: Visual Studio 2013 +image: Visual Studio 2017 # Install pester module and init the Appveyor support. @@ -50,22 +48,12 @@ test_script: else { Write-Warning "No CoverallsToken found. This build seems to be triggered by a PR. Skipping this step..." } - $env:PATH = 'C:\msys64\usr\bin;' + $env:PATH - Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh - Invoke-Expression "bash codecov.sh -f 'coverage.xml' -t $Env:CodeCovToken" 2>&1 - #- ps: | - # $CodeCoverage = Invoke-AppVeyorTests - # if ($null -ne $Env:CoverallsToken) { - # Invoke-CoverageReport -PesterCoverageReport $CodeCoverage - # } - # else { - # Write-Warning "No CoverallsToken found. This build seems to be triggered by a PR. Skipping this step..." - # } - #- ps: | - # Invoke-CodeCoveTests - # $env:PATH = 'C:\msys64\usr\bin;' + $env:PATH - # Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh - # bash codecov.sh -f "coverage.xml" -t $Env:CodeCovToken + if ($null -neq $Env:CodeCovToken) { + Invoke-CodeCove + } + else { + Write-Warning "No CodeCovToken found. This build seems to be triggered by a PR. Skipping this step..." + } deploy: #- provider: GitHub diff --git a/tools/AppVeyor.psm1 b/tools/AppVeyor.psm1 index 04bdc6a..1882f1f 100644 --- a/tools/AppVeyor.psm1 +++ b/tools/AppVeyor.psm1 @@ -182,41 +182,6 @@ Function Invoke-AppVeyorTests() { } -Function Invoke-CodeCoveTests() { - [CmdletBinding()] - Param() - - $MsgParams = @{ - Message = 'Starting Pester tests' - Category = 'Information' - Details = 'Now running all test found in .\tests\ dir.' - } - Add-AppveyorMessage @MsgParams - - try { - Write-Host '===== Preload internal private functions =====' -ForegroundColor Black -BackgroundColor Yellow - - $Privates = Get-ChildItem -Path (Join-Path -Path $Env:APPVEYOR_BUILD_FOLDER -ChildPath '/src/Private/*') -Include "*.ps1" -Recurse - 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!' - } - - #$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' - $testFiles = Get-ChildItem -Path ".\tests\*.Tests.ps1" -Recurse | Sort-Object -Property 'Name' | Select-Object -ExpandProperty 'FullName' - $PesterRes = Invoke-Pester -Path $testFiles -CodeCoverage $srcFiles -CodeCoverageOutputFile ".\coverage.xml" -CodeCoverageOutputFileEncoding ascii -CodeCoverageOutputFileFormat JaCoCo -} Function Invoke-CoverageReport() { [CmdletBinding()] Param( @@ -236,6 +201,21 @@ Function Invoke-CoverageReport() { Publish-CoverageReport -CoverageReport $CoverageReport } + +Function Invoke-CodeCove() { + [CmdletBinding()] + Param() + + $env:PATH = 'C:\msys64\usr\bin;' + $env:PATH + Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile 'codecov.sh' -ErrorAction 'Stop' + if (Test-Path -Path 'coverage.xml') { + Invoke-Expression "bash codecov.sh -f 'coverage.xml' -t $Env:CodeCovToken" 2>&1 + } + else { + Write-Error -Message 'Could not find pester coverage report!' -ErrorAction 'Stop' + } +} + Function Invoke-AppVeyorPSGallery() { [CmdletBinding()] Param( -- 2.40.1 From e5ba3c8e1e348b65e9b5b2b311af03f32023ce32 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Thu, 1 Oct 2020 14:09:16 +0200 Subject: [PATCH 12/20] fix typo --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 2cffc72..a68a30f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -48,7 +48,7 @@ test_script: else { Write-Warning "No CoverallsToken found. This build seems to be triggered by a PR. Skipping this step..." } - if ($null -neq $Env:CodeCovToken) { + if ($null -ne $Env:CodeCovToken) { Invoke-CodeCove } else { -- 2.40.1 From 73a0829a63e0bacd9a9b667e6e8bf6d352958a36 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Thu, 1 Oct 2020 14:26:51 +0200 Subject: [PATCH 13/20] fix typo --- appveyor.yml | 2 +- tools/AppVeyor.psm1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index a68a30f..e157170 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,7 +11,7 @@ cache: skip_tags: true -image: Visual Studio 2017 +image: Visual Studio 2019 # Install pester module and init the Appveyor support. diff --git a/tools/AppVeyor.psm1 b/tools/AppVeyor.psm1 index 1882f1f..26d8b38 100644 --- a/tools/AppVeyor.psm1 +++ b/tools/AppVeyor.psm1 @@ -49,7 +49,7 @@ Function Invoke-AppVeyorBumpVersion() { Write-Host "Listing Env Vars for debugging:" -ForegroundColor Black -BackgroundColor Yellow # 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 { $ModManifest = Get-Content -Path (".\src\{0}.psd1" -f $CALLSIGN) -- 2.40.1 From 28097674181cd18f41072b57d1b89b9b5d9bc876 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Thu, 1 Oct 2020 14:34:30 +0200 Subject: [PATCH 14/20] remove cache --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index e157170..394f27c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ # pre release version: version: 1.0.{build} -cache: +#cache: #branches: # only: -- 2.40.1 From 7b43973c598cf6cf0e78a42468003290fa72fa23 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Fri, 2 Oct 2020 13:05:01 +0200 Subject: [PATCH 15/20] adds Drone.io support (SkipLint) --- .drone.yml | 25 +++++++++++++ tools/DroneIO.psm1 | 89 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 .drone.yml create mode 100644 tools/DroneIO.psm1 diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..d3710c5 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,25 @@ +--- +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}" diff --git a/tools/DroneIO.psm1 b/tools/DroneIO.psm1 new file mode 100644 index 0000000..21eadf9 --- /dev/null +++ b/tools/DroneIO.psm1 @@ -0,0 +1,89 @@ +$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 + $TestFiles = Get-ChildItem -Path (Join-Path -Path '.' -ChildPath './tests/*.Tests.ps1') -Recurse | Sort-Object -Property Name + $TestResults = Invoke-Pester -Script $TestFiles -ExcludeTag 'Disabled' -PassThru + + if ($TestResults.FailedCount -gt 0) { + throw ('{0} tests failed!' -f $TestResults.FailedCount) + } + } +} -- 2.40.1 From 398445c73daef1b68226f91ac6736a42bfa79bb8 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Fri, 2 Oct 2020 15:05:19 +0200 Subject: [PATCH 16/20] trigger CodeCov from drone.io build (SkipLint) --- .drone.yml | 1 + appveyor.yml | 6 ------ tools/DroneIO.psm1 | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.drone.yml b/.drone.yml index d3710c5..88d3859 100644 --- a/.drone.yml +++ b/.drone.yml @@ -23,3 +23,4 @@ steps: commands: - pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-InstallDependencies}" - pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-UnitTests}" + - bash <(curl -s https://codecov.io/bash) diff --git a/appveyor.yml b/appveyor.yml index 394f27c..5b9615d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -48,12 +48,6 @@ test_script: else { Write-Warning "No CoverallsToken found. This build seems to be triggered by a PR. Skipping this step..." } - if ($null -ne $Env:CodeCovToken) { - Invoke-CodeCove - } - else { - Write-Warning "No CodeCovToken found. This build seems to be triggered by a PR. Skipping this step..." - } deploy: #- provider: GitHub diff --git a/tools/DroneIO.psm1 b/tools/DroneIO.psm1 index 21eadf9..acc8596 100644 --- a/tools/DroneIO.psm1 +++ b/tools/DroneIO.psm1 @@ -80,7 +80,7 @@ function Invoke-UnitTests { Write-Host '===== Running Pester =====' -ForegroundColor Black -BackgroundColor Yellow $TestFiles = Get-ChildItem -Path (Join-Path -Path '.' -ChildPath './tests/*.Tests.ps1') -Recurse | Sort-Object -Property Name - $TestResults = Invoke-Pester -Script $TestFiles -ExcludeTag 'Disabled' -PassThru + $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) -- 2.40.1 From 611468f6d0d0af0afe543b99b490093a02aa5d80 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Fri, 2 Oct 2020 15:12:54 +0200 Subject: [PATCH 17/20] fix bash syntax (SkipLint) --- .drone.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 88d3859..8253a94 100644 --- a/.drone.yml +++ b/.drone.yml @@ -23,4 +23,5 @@ steps: commands: - pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-InstallDependencies}" - pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-UnitTests}" - - bash <(curl -s https://codecov.io/bash) + - bash curl -s https://codecov.io/bash -o codecov.sh + - bash codecov.sh -f 'coverage.xml' -- 2.40.1 From d675caa81d4d899f86729a9bbbb18a7e5cdfcf0b Mon Sep 17 00:00:00 2001 From: OCram85 Date: Fri, 2 Oct 2020 15:21:40 +0200 Subject: [PATCH 18/20] use codecov plugin (SkipLint) --- .drone.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 8253a94..8e876df 100644 --- a/.drone.yml +++ b/.drone.yml @@ -23,5 +23,10 @@ steps: commands: - pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-InstallDependencies}" - pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-UnitTests}" - - bash curl -s https://codecov.io/bash -o codecov.sh - - bash codecov.sh -f 'coverage.xml' + - name: coverage + image: plugins/codecov + settings: + token: + from_secret: CodeCovToken + files: + - coverage.xml -- 2.40.1 From cb0ee01e33110641d46654d586c2b08a027fe12d Mon Sep 17 00:00:00 2001 From: OCram85 Date: Fri, 2 Oct 2020 15:24:11 +0200 Subject: [PATCH 19/20] fix pester test (SkipLint) --- tools/DroneIO.psm1 | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/DroneIO.psm1 b/tools/DroneIO.psm1 index acc8596..5f626e4 100644 --- a/tools/DroneIO.psm1 +++ b/tools/DroneIO.psm1 @@ -79,6 +79,7 @@ function Invoke-UnitTests { } 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 -- 2.40.1 From 69b52bc76189fe3b14deacbaff62c01f0948952c Mon Sep 17 00:00:00 2001 From: OCram85 Date: Fri, 2 Oct 2020 15:29:29 +0200 Subject: [PATCH 20/20] switch to drone.io (SkipLint) --- .travis.yml => _.travis.yml | 0 tools/AppVeyor.psm1 | 14 -------------- 2 files changed, 14 deletions(-) rename .travis.yml => _.travis.yml (100%) diff --git a/.travis.yml b/_.travis.yml similarity index 100% rename from .travis.yml rename to _.travis.yml diff --git a/tools/AppVeyor.psm1 b/tools/AppVeyor.psm1 index 26d8b38..3ea9c45 100644 --- a/tools/AppVeyor.psm1 +++ b/tools/AppVeyor.psm1 @@ -202,20 +202,6 @@ Function Invoke-CoverageReport() { } -Function Invoke-CodeCove() { - [CmdletBinding()] - Param() - - $env:PATH = 'C:\msys64\usr\bin;' + $env:PATH - Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile 'codecov.sh' -ErrorAction 'Stop' - if (Test-Path -Path 'coverage.xml') { - Invoke-Expression "bash codecov.sh -f 'coverage.xml' -t $Env:CodeCovToken" 2>&1 - } - else { - Write-Error -Message 'Could not find pester coverage report!' -ErrorAction 'Stop' - } -} - Function Invoke-AppVeyorPSGallery() { [CmdletBinding()] Param( -- 2.40.1