-
Notifications
You must be signed in to change notification settings - Fork 33
209 lines (203 loc) · 8.01 KB
/
testing.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
name: Build
on:
push:
pull_request:
schedule:
- cron: '0 15 * * 5'
jobs:
ubuntu:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
env:
PYTHON: ${{ matrix.python-version }}
OS: ubuntu
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install OS dependencies
run: |
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
- name: Install Python dependencies
run: |
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
- name: Build Docker image
run: docker build -t bonsai -f ./.ci/docker/Dockerfile .
- name: Configure Docker container
run: |
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
- name: Check container and LDAP tools
run: |
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
- name: Check Python sysconfig
run: python -m sysconfig
- name: Install package
run: |
printf "\n\n[options]\nzip_safe = False" >> setup.cfg
export CFLAGS="-coverage"
python -m pip install -v .
- name: Run tests
run: |
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 -m pytest -v --cov-config .coveragerc --cov-report= --cov=$BONSAI_INSTALL_PATH
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
directory: "."
env_vars: OS,PYTHON
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
macos:
runs-on: macos-13
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
env:
PYTHON: ${{ matrix.python-version }}
OS: macos
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install Python dependencies
run: |
echo "python_final_release=$(python -c 'import sys;print(str(sys.version_info.releaselevel == "final").lower())')" >> $GITHUB_ENV
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 install --force-reinstall --no-binary gevent delocate
python -m pip list
- name: Install Docker
run: bash ./.github/workflows/scripts/install_docker_mac.sh
- name: Wait on Docker
run: |
bash ./.github/workflows/scripts/wait_docker_mac.sh
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.Kerberos.kdc.plist
- name: Build Docker image
run: |
docker build -t bonsai -f ./.ci/docker/Dockerfile .
- name: Configure Docker container
run: |
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
- name: Check container and LDAP tools
run: |
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
- name: Check Python sysconfig
run: python -m sysconfig
- name: Install package
run: |
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 .
- name: Check linking
run: |
otool -L ./build/*/bonsai/*.so
- name: Run tests
run: |
export KRB5_CONFIG="`pwd`/.ci/krb5/krb5.conf"
export BONSAI_INSTALL_PATH=`python -c "import bonsai; print(bonsai.__file__[:-12])"`
echo $BONSAI_INSTALL_PATH
py.test -v --cov-config .coveragerc --cov-report= --cov=$BONSAI_INSTALL_PATH
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
directory: "."
env_vars: OS,PYTHON
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
if: ${{ github.event_name != 'schedule' }}
- name: Create wheel
run: |
rm -rf ./build
ARCHFLAGS='-arch x86_64' _PYTHON_HOST_PLATFORM=$(python -c "import sysconfig;print(f\"{'-'.join(sysconfig.get_platform().split('-')[:-1])}-x86_64\")") python -m build -w
delocate-wheel -v ./dist/bonsai-*.whl
if: ${{ env.python_final_release == 'true' }}
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-amd64-${{ matrix.python-version }}
path: ./dist/bonsai-*.whl
retention-days: 5
if: ${{ env.python_final_release == 'true' }}
macos-arm64-wheels:
needs: macos
runs-on: macos-14
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
env:
PYTHON: ${{ matrix.python-version }}
OS: macos
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install Python build dependencies
run: |
echo "python_final_release=$(python -c 'import sys;print(str(sys.version_info.releaselevel == "final").lower())')" >> $GITHUB_ENV
python -m pip install --upgrade pip
python -m pip install delocate build wheel
python -m pip list
- name: Check Python sysconfig
run: python -m sysconfig
- name: Create wheel
run: |
printf "[build_ext]\ninclude_dirs=/usr/include/sasl:/opt/homebrew/opt/openldap/include\nlibrary_dirs=/opt/homebrew/opt/openldap/lib" > ./setup.cfg
printf "\n\n[options]\nzip_safe = False" >> setup.cfg
ARCHFLAGS='-arch arm64' _PYTHON_HOST_PLATFORM=$(python -c "import sysconfig;print(f\"{'-'.join(sysconfig.get_platform().split('-')[:-1])}-arm64\")") python -m build -w
delocate-wheel --require-archs arm64 -v ./dist/bonsai-*.whl
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-arm64-${{ matrix.python-version }}
path: ./dist/bonsai-*.whl
retention-days: 5
if: ${{ env.python_final_release == 'true' }}