Build #486
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] | |
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'] | |
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 }} | |
- 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'] | |
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 }} | |
- name: Install Python build dependencies | |
run: | | |
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 |