-
Notifications
You must be signed in to change notification settings - Fork 155
/
build.ps1
139 lines (119 loc) · 3.49 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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<#
.Synopsis
Build script <https://github.com/nightroman/Invoke-Build>
.Example
PS> ./Novell.Directory.Ldap.NetStandard.build.ps1 build -Configuration Release
#>
param(
[Parameter(Position=0)]
[string[]]$Tasks,
[ValidateSet('Debug', 'Release')]
[string]$Configuration = 'Release',
# stress tests params
[ValidateSet('net8', 'net6')]
[string]$Fx = 'net6',
[string]$ConcurrencyLevel = 20,
[ValidateSet('off', 'tls', 'ssl')]
[string]$TransportSecurity = 'off'
)
# Ensure and call the module.
if ([System.IO.Path]::GetFileName($MyInvocation.ScriptName) -ne 'Invoke-Build.ps1') {
$InvokeBuildVersion = '5.11.0'
$ErrorActionPreference = 'Stop'
try {
Import-Module InvokeBuild -RequiredVersion $InvokeBuildVersion
}
catch {
Install-Module InvokeBuild -RequiredVersion $InvokeBuildVersion -Scope CurrentUser -Force
Import-Module InvokeBuild -RequiredVersion $InvokeBuildVersion
}
Invoke-Build -Task $Tasks -File $MyInvocation.MyCommand.Path @PSBoundParameters
return
}
$script:SupportedNetVersions = @(
"net8"
"net6"
)
task build {
exec {
dotnet build -c $Configuration
}
}
task test-unit {
foreach($netVersion in $SupportedNetVersions) {
exec {
dotnet test --configuration $Configuration --no-build `
test/Novell.Directory.Ldap.NETStandard.UnitTests/Novell.Directory.Ldap.NETStandard.UnitTests.csproj -f $netVersion
}
}
}
task configure-opendj {
exec { whoami }
exec {
# run openjd in docker
docker run -d -h ldap-01.example.com -p 4389:1389 -p 4636:1636 -p 4444:4444 --name opendj --env-file opendj-docker-env.props openidentityplatform/opendj
}
exec {
# give openldap enough time to start
sleep 30
docker ps -a
}
}
task internal-test-functional {
foreach($netVersion in $SupportedNetVersions) {
exec {
dotnet test --configuration $CONFIGURATION --no-build `
test/Novell.Directory.Ldap.NETStandard.FunctionalTests/Novell.Directory.Ldap.NETStandard.FunctionalTests.csproj -f $netVersion
}
}
}
task test-functional configure-opendj, configure-openldap, {
$env:TRANSPORT_SECURITY="OFF"
Invoke-Build internal-test-functional $BuildFile
$env:TRANSPORT_SECURITY="SSL"
Invoke-Build internal-test-functional $BuildFile
$env:TRANSPORT_SECURITY="TLS"
Invoke-Build internal-test-functional $BuildFile
}
task remove-opendj -After test-functional {
exec {
docker kill opendj
}
exec {
docker rm opendj
}
}
task test test-unit, test-functional, {
}
task configure-openldap {
exec {
sudo apt-get update
}
exec {
sudo DEBIAN_FRONTEND=noninteractive apt-get install `
ldap-utils gnutls-bin ssl-cert slapd `
sasl2-bin libsasl2-2 libsasl2-modules libsasl2-modules-ldap `
-y
}
exec {
bash configure-openldap.sh
}
}
task remove-openldap -After test-stress {
exec {
bash build/remove-openldap.sh
}
}
task test-stress configure-openldap, {
$env:TRANSPORT_SECURITY=$TransportSecurity.ToUpper()
exec {
dotnet run --configuration $CONFIGURATION `
--project test/Novell.Directory.Ldap.NETStandard.StressTests/Novell.Directory.Ldap.NETStandard.StressTests.csproj `
$ConcurrencyLevel 30 -f $Fx
}
}
task clean {
remove bin, obj
}
task . build, test
task reset-openldap remove-openldap, configure-openldap