-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathazure-pipelines.yml
248 lines (247 loc) · 9.32 KB
/
azure-pipelines.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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
trigger:
branches:
include:
- '*'
stages:
- stage: Test
jobs:
- job: Ubuntu
pool:
vmImage: "ubuntu-latest"
strategy:
matrix:
Python38:
python.version: '3.8'
Python39:
python.version: '3.9'
Python310:
python.version: '3.10'
Python311:
python.version: '3.11'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
architecture: 'x64'
- script: python --version
- script: |
set -e
sudo apt-get update
sudo apt-get install -y libldap2-dev libsasl2-dev ldap-utils sasl2-bin
sudo apt-get install -y krb5-user libsasl2-modules-gssapi-mit libkrb5-dev
apt list --installed
displayName: Install OS dependencies
- script: |
set -e
python -m pip install --upgrade pip
python -m pip install poetry wheel
poetry config virtualenvs.create false
poetry install --no-root -E gevent -E tornado -E trio
python -m pip list
displayName: Install Python dependencies
- script: docker build -t bonsai -f ./.ci/docker/Dockerfile .
displayName: Build Docker image
- script: |
set -e
mkdir /tmp/bonsai
sudo chown 2001:2000 /tmp/bonsai
docker run --cap-add=NET_ADMIN -v /tmp/bonsai/:/home/ldap/run/:z -d -h bonsai.test --name server bonsai
export BONSAI_DOCKER_IP=`docker inspect --format '{{ .NetworkSettings.IPAddress }}' server`
sudo bash -c 'echo -e "\n'$BONSAI_DOCKER_IP' bonsai.test" >> /etc/hosts'
cat /etc/hosts
ping -c 2 bonsai.test
sleep 4
displayName: Configure Docker container
- script: |
docker exec server ps aux
ldapwhoami -Y DIGEST-MD5 -H ldap://bonsai.test -U admin -w p@ssword
ldapsearch -H ldap://bonsai.test -b "" -s base 'objectclass=*' -x -LLL +
ldapsearch -VV
saslpluginviewer
displayName: Check container and LDAP tools
- script: python -m sysconfig
displayName: Check Python sysconfig
- script: |
set -e
printf "\n\n[options]\nzip_safe = False" >> setup.cfg
export CFLAGS="-coverage"
python -m pip install -v .
displayName: Install package
- script: |
export BONSAI_DOCKER_IP=`docker inspect --format '{{ .NetworkSettings.IPAddress }}' server`
sed -i.bak "s/127.0.0.1/$BONSAI_DOCKER_IP/g" ./tests/test.ini
export KRB5_CONFIG="`pwd`/.ci/krb5/krb5.conf"
export BONSAI_INSTALL_PATH=`python -c "import bonsai; print(bonsai.__file__[:-12])"`
echo $BONSAI_INSTALL_PATH
python -c 'import bonsai;print(bonsai.get_vendor_info(), bonsai.get_tls_impl_name())'
py.test -v --cov-config .coveragerc --junitxml=./test-results.xml --cov=$BONSAI_INSTALL_PATH
displayName: Run tests
- task: PublishTestResults@2
inputs:
testResultsFiles: test-results.xml
testRunTitle: Tests on $(Agent.OS) with Python $(python.version)
condition: succeededOrFailed()
- script: |
PATH=$HOME/.local/bin:$PATH
codecov
env:
CODECOV_TOKEN: $(codecov)
displayName: Report Coverage
condition: succeeded()
- job: macOS
pool:
vmImage: "macos-latest"
strategy:
matrix:
Python38:
python.version: '3.8'
Python39:
python.version: '3.9'
Python310:
python.version: '3.10'
Python311:
python.version: '3.11'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
architecture: 'x64'
- script: python --version
- script: |
set -e
python -m pip install --upgrade pip
python -m pip install poetry wheel build
poetry config virtualenvs.create false
poetry install --no-root -E gevent -E tornado -E trio
python -m pip list
displayName: Install Python dependencies
- script: bash ./.github/workflows/scripts/install_docker_mac.sh
displayName: Install Docker
- script: |
set -e
bash ./.github/workflows/scripts/wait_docker_mac.sh
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.Kerberos.kdc.plist
displayName: Wait on Docker
- script: docker build -t bonsai -f ./.ci/docker/Dockerfile .
displayName: Build Docker image
- script: |
set -e
mkdir /tmp/bonsai
sudo chown 2001:2000 /tmp/bonsai
docker run --cap-add=NET_ADMIN -p 389:389 -p 636:636 -p 88:88/udp -p 749:749 -p 8000:8000 -d -h bonsai.test --name server bonsai
sudo bash -c 'echo -e "\n127.0.0.1 bonsai.test" >> /etc/hosts'
sudo scutil --set HostName bonsai.test
cat /etc/hosts
ping -c 2 bonsai.test
sleep 5
displayName: Configure Docker container
- script: |
docker exec server ps aux
/usr/local/opt/openldap/bin/ldapwhoami -Y DIGEST-MD5 -H ldap://bonsai.test -U admin -w p@ssword
/usr/local/opt/openldap/bin/ldapsearch -x -H ldap://bonsai.test -b "" -s base 'objectclass=*' -LLL +
/usr/local/opt/openldap/bin/ldapsearch -VV
displayName: Check container and LDAP tools
- script: python -m sysconfig
displayName: Check Python sysconfig
- script: |
set -e
printf "[build_ext]\ninclude_dirs=/usr/local/opt/openldap/include\nlibrary_dirs=/usr/local/opt/openldap/lib" > ./setup.cfg
printf "\n\n[options]\nzip_safe = False" >> setup.cfg
export CFLAGS="-coverage"
python -m pip install -v .
displayName: Install package
- script: otool -L ./build/*/bonsai/*.so
displayName: Check linking
- script: |
export KRB5_CONFIG="`pwd`/.ci/krb5/krb5.conf"
export BONSAI_INSTALL_PATH=`python -c "import bonsai; print(bonsai.__file__[:-12])"`
echo $BONSAI_INSTALL_PATH
python -c 'import bonsai;print(bonsai.get_vendor_info(), bonsai.get_tls_impl_name())'
py.test -v --cov-config .coveragerc --junitxml=./test-results.xml --cov=$BONSAI_INSTALL_PATH
displayName: Run tests
- task: PublishTestResults@2
inputs:
testResultsFiles: test-results.xml
testRunTitle: Tests on $(Agent.OS) with Python $(python.version)
condition: succeededOrFailed()
- script: |
PATH=$HOME/.local/bin:$PATH
codecov
env:
CODECOV_TOKEN: $(codecov)
displayName: Report Coverage
condition: succeeded()
- script: |
set -e
rm -rf ./build
python -m build -w
delocate-wheel -v ./dist/bonsai-*.whl
displayName: Create wheel
- task: CopyFiles@2
inputs:
sourceFolder: '$(Build.SourcesDirectory)/dist/'
contents: '*'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: wheels
- job: Docker
pool:
vmImage: "ubuntu-latest"
strategy:
matrix:
newestOpenLDAP:
openldap.version: '2.6.3'
python.version: '3.8-slim-bullseye'
nightlyPython:
openldap.version: '2.4.57'
python.version: '3.12.0a1-slim-bullseye'
steps:
- script: docker build -t bonsai -f ./.ci/docker/Dockerfile .
displayName: Build Docker image (server)
- script: |
docker build -t client \
--build-arg=PYTHON_VERSION=$PY_VER \
--build-arg=OPENLDAP_VERSION=$OL_VER \
-f ./.ci/docker/Dockerfile-client .
env:
PY_VER: $(python.version)
OL_VER: $(openldap.version)
displayName: Build Docker image (client)
- script: |
set -e
mkdir /tmp/bonsai
sudo chown 2001:2000 /tmp/bonsai
docker network create test
docker run --cap-add=NET_ADMIN -v /tmp/bonsai/:/home/ldap/run/:z -d -h bonsai.test --network test --name bonsai bonsai
sleep 4
export BONSAI_DOCKER_IP=`docker inspect --format '{{ .NetworkSettings.Networks.test.IPAddress }}' bonsai`
echo $BONSAI_DOCKER_IP
docker run \
-e BONSAI_DOCKER_IP=$BONSAI_DOCKER_IP \
-e KRB5_CONFIG=/opt/bonsai/.ci/krb5/krb5.conf \
-v /tmp/bonsai/:/tmp/bonsai/ \
-v `pwd`:/opt/bonsai/ -d -h client.test --network test --name client client
displayName: Start Docker containers
- script: |
docker exec bonsai ps aux
docker exec client ping -c 2 bonsai.test
docker exec client ldapsearch -VV
docker exec client ldapwhoami -Y DIGEST-MD5 -H ldap://bonsai.test -U admin -w p@ssword
docker exec client ldapsearch -H ldap://bonsai.test -b "" -s base 'objectclass=*' -x -LLL +
displayName: Check container and LDAP tools
- script: |
set -e
docker exec client poetry config virtualenvs.create false
docker exec client poetry install --no-root
docker exec client python3 -m pip list
displayName: Install Python dependencies
- script: |
docker exec client python3 -m pip install -v .
displayName: Install package
- script: |
docker exec client bash -c 'sed -i.bak "s/127.0.0.1/$BONSAI_DOCKER_IP/g" ./tests/test.ini'
docker exec client python -c 'import bonsai;print(bonsai.get_vendor_info(), bonsai.get_tls_impl_name())'
docker exec client py.test -vs
displayName: Run tests