-
Notifications
You must be signed in to change notification settings - Fork 5
/
appveyor.yml
82 lines (77 loc) · 3.8 KB
/
appveyor.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#---------------------------------#
# environment configuration #
#---------------------------------#
version: 3.0.0.{build}
image: Visual Studio 2022
#---------------------------------#
# install configuration #
#---------------------------------#
install:
- ps: |
Write-Host "Install prerequisites" -ForegroundColor Yellow
$null = Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -ErrorAction Stop
$module = "C:\Program Files\WindowsPowerShell\Modules\Pester"
$null = takeown /F $module /A /R
$null = icacls $module /reset
$null = icacls $module /grant "*S-1-5-32-544:F" /inheritance:d /T
$null = Remove-Item -Path $module -Recurse -Force -Confirm:$false
Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Force -ErrorAction Stop
Install-Module -Name Pester -Repository PSGallery -Force -ErrorAction Stop
Install-Module -Name xSmbShare -Repository PSGallery -Force -ErrorAction Stop
Install-Module -Name cNtfsAccessControl -Repository PSGallery -Force -ErrorAction Stop
# Validate
$RequiredModules = 'PSScriptAnalyzer','Pester','xSmbShare','cNtfsAccessControl'
$InstalledModules = Get-Module -Name $RequiredModules -ListAvailable
Write-Host "Installed modules:" -ForegroundColor Yellow
$InstalledModules | ft Name, Version
if ( ($InstalledModules.count -lt $RequiredModules.Count) -or ($Null -eq $InstalledModules)) {
throw "Required modules are missing."
} else {
Write-Host "All required modules found!" -ForegroundColor Green
}
#---------------------------------#
# build configuration #
#---------------------------------#
build_script:
- ps: |
Write-Host "Build project" -ForegroundColor Yellow
Write-Host "Build version : $env:APPVEYOR_BUILD_VERSION"
Write-Host "Branch : $env:APPVEYOR_REPO_BRANCH"
Write-Host "Repo : $env:APPVEYOR_REPO_NAME"
Write-Host "Current dir : $pwd"
Write-Host "Build cMDTBuildLab..." -ForegroundColor Yellow
. .\Build.ps1
Write-Host "...completed!" -ForegroundColor Green
- cd ..\Build\cMDTBuildLab
- mkdir "%ProgramFiles%\WindowsPowerShell\Modules\cMDTBuildLab"
- copy cMDTBuildLab.psm1 "%ProgramFiles%\WindowsPowerShell\Modules\cMDTBuildLab"
- copy cMDTBuildLab.psd1 "%ProgramFiles%\WindowsPowerShell\Modules\cMDTBuildLab"
#---------------------------------#
# test configuration #
#---------------------------------#
test_script:
- ps: |
Write-Host "Running Test script" -ForegroundColor Yellow
Import-Module Pester
$BuildDir = 'C:\Projects\Build\cMDTBuildLab'
$testResultsFile = "$BuildDir\TestsResults.xml"
$config = [PesterConfiguration]::Default
$config.TestResult.Enabled = $true
$config.TestResult.OutputPath = $testResultsFile
$config.Output.Verbosity = 'Detailed'
$config.Run.PassThru = $true
$config.Run.Path = "$BuildDir\Tests\cMDTBuildLab.tests.ps1"
$res = Invoke-Pester -Configuration $config
$URI = "https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)"
$WC = New-Object 'System.Net.WebClient'
Write-Host "About to upload file: $(Resolve-Path $testResultsFile)"
try {
$WC.UploadFile($URI, (Resolve-Path $testResultsFile))
} catch {
Write-Host "Uploading failed!" -ForegroundColor Red
}
if (($res.FailedCount -gt 0) -or ($res.PassedCount -eq 0) -or ($null -eq $res)) {
throw "$($res.FailedCount) tests failed."
} else {
Write-Host "All tests passed!" -ForegroundColor Green
}