-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.build.ps1
52 lines (41 loc) · 2.23 KB
/
.build.ps1
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
$testFiles = Get-Item "${PSScriptRoot}\src\*.Tests.ps1"
$sourceFiles = Get-Item "${PSScriptRoot}\src\*.ps1" -Exclude *.Tests.ps1
$sourceFiles += Get-Item "${PSScriptRoot}\PSForge.psm1"
$excludeTag = "not" + [environment]::OSVersion.Platform
task Clean {
git clean -f -X -d
}
task CI {
Import-LocalizedData -BaseDirectory "." -FileName "PSForge.psd1" -BindingVariable metadata
$moduleVersion = $metadata.ModuleVersion
$buildNumber = "$moduleVersion-$(Get-Date -Format 'yyyyMMddHHmmss')"
Write-Host "##vso[task.setvariable variable=moduleversion]${moduleVersion}"
Write-Host "##vso[build.updatebuildnumber]${buildNumber}"
}
task FixModulesOnUnix -before ImportModule -If ([environment]::OSVersion.platform -eq "Unix") {
$TestPlasterManifest = "./packages/Plaster/TestPlasterManifest.ps1"
(Get-Content $TestPlasterManifest).replace('$schemaPath = "$PSScriptRoot\Schema\PlasterManifest-v1.xsd"', '$schemaPath = [io.path]::combine($PSScriptRoot, "Schema", "PlasterManifest-v1.xsd")') | Set-Content $TestPlasterManifest
$mockFile = "./packages/Pester/Functions/Mock.ps1"
(Get-Content $mockFile).replace('if ($PSVersionTable.PSVersion -ge ''5.0.10586.122'')', 'if (''5.0.10586.122'' -le $PSVersionTable.PSVersion)') | Set-Content $mockFile
}
task FetchDependencies -before ImportModule {
if([Environment]::OSVersion.Platform -eq "Unix"){
$env:PSModulePath = "${PWD}/packages:" + $env:PSModulePath
mono .nuget/nuget.exe install -ExcludeVersion
}else{
$env:PSModulePath = "${PWD}\packages;" + $env:PSModulePath
.nuget\nuget.exe install -ExcludeVersion
}
}
task ImportModule -before UnitTest, SmokeTest {
Get-Module | Remove-Module -Force -ErrorAction SilentlyContinue
Get-ChildItem -Depth 1 -Recurse *.psm1 | Import-Module -Force
}
task UnitTest {
Invoke-Pester -Path $testFiles -OutputFormat NUnitXml -OutputFile TestResults.xml -PassThru -CodeCoverage $sourceFiles -CodeCoverageOutputFile coverage.xml -ExcludeTag @("SmokeTest", $excludeTag)
}
task SmokeTest {
Invoke-Pester -Path $testFiles -OutputFormat NUnitXml -OutputFile TestResults.xml -PassThru -CodeCoverage $sourceFiles -CodeCoverageOutputFile coverage.xml -Tag SmokeTest -ExcludeTag $excludeTag
}
task Test {
}