From b0a5ccd19287f615822d31cb681055de539f08c4 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Thu, 4 Jun 2020 09:23:55 +0200 Subject: [PATCH] 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(