|
| 1 | +#---------------------------------# |
| 2 | +# environment configuration # |
| 3 | +#---------------------------------# |
| 4 | +version:1.0.{build} |
| 5 | +image:WMF 5 |
| 6 | + |
| 7 | +#---------------------------------# |
| 8 | +# install configuration # |
| 9 | +#---------------------------------# |
| 10 | +install: |
| 11 | + -ps:| |
| 12 | + Write-Host "Install prerequisites" -ForegroundColor Yellow |
| 13 | + $null = Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -ErrorAction Stop |
| 14 | + Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Force -ErrorAction Stop |
| 15 | + Install-Module -Name Pester -Repository PSGallery -Force -ErrorAction Stop |
| 16 | + # Validate |
| 17 | + $RequiredModules = 'PSScriptAnalyzer','Pester' |
| 18 | + $InstalledModules = Get-Module -Name $RequiredModules -ListAvailable |
| 19 | + Write-Host "Installed modules:" -ForegroundColor Yellow |
| 20 | + $InstalledModules | ft Name, Version |
| 21 | + if ( ($InstalledModules.count -lt $RequiredModules.Count) -or ($Null -eq $InstalledModules)) { |
| 22 | + throw "Required modules are missing." |
| 23 | + } else { |
| 24 | + Write-Host "All required modules found!" -ForegroundColor Green |
| 25 | + } |
| 26 | +
|
| 27 | +#---------------------------------# |
| 28 | +# build configuration # |
| 29 | +#---------------------------------# |
| 30 | +build_script: |
| 31 | + -ps:| |
| 32 | + Write-Host "Build project" -ForegroundColor Yellow |
| 33 | + Write-Host "Build version : $env:APPVEYOR_BUILD_VERSION" |
| 34 | + Write-Host "Branch : $env:APPVEYOR_REPO_BRANCH" |
| 35 | + Write-Host "Repo : $env:APPVEYOR_REPO_NAME" |
| 36 | + Write-Host "Running Build.ps1..." -ForegroundColor Yellow |
| 37 | + . .\Build.ps1 |
| 38 | +# - cd ..\Build\ExchangeTrackingGUI |
| 39 | +# - mkdir "%ProgramFiles%\WindowsPowerShell\Modules\ExchangeTrackingGUI" |
| 40 | +# - copy ExchangeTrackingGUI.psm1 "%ProgramFiles%\WindowsPowerShell\Modules\ExchangeTrackingGUI" |
| 41 | +# - copy ExchangeTrackingGUI.psd1 "%ProgramFiles%\WindowsPowerShell\Modules\ExchangeTrackingGUI" |
| 42 | + -ps:| |
| 43 | + Import-Module -Name .\ExchangeTrackingGUI.psm1 |
| 44 | + Write-Host "...completed!" -ForegroundColor Green |
| 45 | +
|
| 46 | +#---------------------------------# |
| 47 | +# test configuration # |
| 48 | +#---------------------------------# |
| 49 | +test_script: |
| 50 | + -ps:| |
| 51 | + Write-Host "Running Test script" -ForegroundColor Yellow |
| 52 | + $testResultsFile = ".\TestsResults.xml" |
| 53 | + $res = Invoke-Pester -ExcludeTag 'Markdown','Examples' -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru |
| 54 | + $URI = "https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)" |
| 55 | + $WC = New-Object 'System.Net.WebClient' |
| 56 | + Write-Host "About to upload file: $(Resolve-Path $testResultsFile)" |
| 57 | + try { |
| 58 | + $WC.UploadFile($URI, (Resolve-Path $testResultsFile)) |
| 59 | + } catch { |
| 60 | + Write-Host "Uploading failed!" -ForegroundColor Red |
| 61 | + } |
| 62 | +
|
| 63 | + if (($res.FailedCount -gt 0) -or ($res.PassedCount -eq 0) -or ($null -eq $res)) { |
| 64 | + throw "$($res.FailedCount) tests failed." |
| 65 | + } else { |
| 66 | + Write-Host "All tests passed!" -ForegroundColor Green |
| 67 | + } |