This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cicd.ps1
73 lines (55 loc) · 2 KB
/
cicd.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
$ErrorActionPreference = "Stop"
Push-Location Eklee.Azure.Functions.Http.Tests
dotnet test
Pop-Location
if ($lastexitcode -ne 0){
return;
}
$buildConfig = "Release"
$app = "Eklee.Azure.Functions.Http"
$currentDir = Get-Location
pushd Examples\Eklee.Azure.Functions.Http.Example
dotnet build --configuration=$buildConfig
popd
pushd Examples\Eklee.Azure.Functions.Http.Example\bin\Release\netstandard2.0
npm install --save-dev azure-functions-core-tools@3
npm install --save-dev newman
popd
$hostJob = Start-Job -ScriptBlock {
param([string]$currentDir)
Write-Host $currentDir
cd $currentDir
Get-Location
pushd Examples\Eklee.Azure.Functions.Http.Example\bin\Release\netstandard2.0
node_modules\.bin\func host start
} -ArgumentList $currentDir
Start-Sleep -s 10
Receive-Job -Name $hostJob.Name
$testJob = Start-Job -ScriptBlock {
param([string]$currentDir)
Write-Host $currentDir
cd $currentDir
pushd Examples\Eklee.Azure.Functions.Http.Example\bin\Release\netstandard2.0
node_modules\.bin\newman run ..\..\..\..\..\tests\Eklee.Azure.Functions.Http.Tests.postman_collection.json -e ..\..\..\..\..\tests\Eklee.Azure.Functions.Http.Local.postman_environment.json
} -ArgumentList $currentDir
Wait-Job -Name $testJob.Name
$testResult = Receive-Job -Name $testJob.Name
$testResult
Write-Host "Stopping Jobs"
Stop-Job $hostJob
Stop-Job $testJob
if ($testResult -like "*AssertionError*") {
Write-Host "Failed!" -ForegroundColor red
} else {
Write-Host "All good!" -ForegroundColor green
Write-Host "Generating nuget package"
pushd .\$app
dotnet clean --configuration $buildConfig
dotnet build --configuration $buildConfig
Move-Item -Path bin\Release\netstandard2.0\bin\$app.dll -Destination bin\Release\netstandard2.0\$app.dll -Force
popd
Remove-Item $currentDir\*.nupkg
Copy-Item $currentDir\LICENSE $currentDir\LICENSE.txt
nuget.exe pack $app\$app.csproj -Properties Configuration=$buildConfig -IncludeReferencedProjects
Remove-Item $currentDir\LICENSE.txt
}