Skip to content

Commit

Permalink
Merge pull request #128 from emc-isilon/modernize2
Browse files Browse the repository at this point in the history
Modernize package and build infrastructure
  • Loading branch information
masenf committed Dec 21, 2022
2 parents 76ad7f2 + 8b41271 commit e490283
Show file tree
Hide file tree
Showing 67 changed files with 389 additions and 178 deletions.
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
__pycache__
.coverage
.coverage.*
.idea
.pytest_cache
.tox

*.pyc
*.egg-info/

build
dist
doc/source/stubs
wheelhouse
31 changes: 0 additions & 31 deletions .github/workflows/publishpackage.yml

This file was deleted.

61 changes: 61 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Build and Publish Wheels

on: [push, pull_request]

jobs:
build_wheels:
name: Build py3 wheels on ubuntu-22.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.11.3
- name: Build wheels
run: ./samba/dc.sh ./build_and_test_wheels.sh
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

build_wheels_py27:
name: Build py27 wheel on ubuntu-22.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- name: Build wheels
run: ./samba/dc.sh ./build_and_test_wheels27.sh
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_wheels_py27, build_sdist]
runs-on: ubuntu-latest
# upload to PyPI on every tag starting with 'v'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@v1.5.0
with:
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
__pycache__
.coverage
.coverage.*
.idea
.pytest_cache
.tox

*.pyc
*.egg-info/

build
dist
Pike.egg-info/
doc/source/stubs
wheelhouse
2 changes: 2 additions & 0 deletions .gitignorerevs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# blackify
03f70b27c00a188790c40a0a59e4cbfce29b9719
e347aeb25405a29e43492c125e532c969aa6d6c7
# move to /src
384b32c2436a974d8260b65c663567e669d5b2d5
24 changes: 0 additions & 24 deletions build_all_wheels.sh

This file was deleted.

8 changes: 8 additions & 0 deletions buildwheel/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM quay.io/pypa/manylinux2010_x86_64
COPY . /src/pike
RUN yum install -y krb5-devel krb5-workstation python27 && \
source /opt/rh/python27/enable && \
python2.7 -m pip install -U 'pip<21' && \
python2.7 -m pip install build

CMD /src/pike/buildwheel/wheel27.sh
8 changes: 8 additions & 0 deletions buildwheel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# buildwheel

build pike-smb2 manylinux wheel (including for python2.7)

```
docker build -t pike-buildwheel buildwheel
docker run -it -v /tmp/wheelhouse:/src/pike/wheelhouse pike-buildwheel
```
22 changes: 22 additions & 0 deletions buildwheel/wheel27.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

# source before bash "strict mode"
source /opt/rh/python27/enable

set -euxo pipefail

# build py27 wheel
cd /src/pike
python2.7 -m build
auditwheel repair dist/*.whl

# Test the wheel
export PIKE_SERVER=$SAMBA_SERVER
export PIKE_SHARE=s1

./samba/krb5.conf.sh
python2.7 -m pip install wheelhouse/*-cp27*.whl
python2.7 -m unittest pike.test.session

# if the wheelhouse dir is mounted, copy tested wheels to host
[[ -d /wheelhouse ]] && cp wheelhouse/* /wheelhouse/
21 changes: 20 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
[build-system]
requires = ["setuptools>=30.3.0", "wheel", "setuptools_scm[toml]"]
requires = ["setuptools>=44", "wheel", "setuptools_scm[toml]"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]

[tool.cibuildwheel]
# skip x86 pypi since pycryptodome packages
# are broken on these playforms (at least py37)
skip = ["pp*-manylinux_i686"]
before-test = ["{project}/samba/krb5.conf.sh"]
test-command = [
"export PIKE_SERVER=$SAMBA_SERVER",
"export PIKE_SHARE=s1",
"python -m unittest pike.test.session",
]

[tool.cibuildwheel.linux]
environment-pass = ["HOST_IPV4", "SAMBA_REALM", "SAMBA_SERVER", "ADMIN_PASSWORD"]
before-all = "yum install -y krb5-devel krb5-workstation"

[[tool.cibuildwheel.overrides]]
select = "*-musllinux*"
before-all = "apk add krb5 krb5-dev"
2 changes: 2 additions & 0 deletions samba/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
s1
krb5.conf
5 changes: 5 additions & 0 deletions samba/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM debian:11

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y krb5-user libkrb5-dev python2-dev python3-dev build-essential python3-pip git
29 changes: 29 additions & 0 deletions samba/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Samba DC environment

This environment exists for running tests using kerberos authentication.

## Requirements

The host requires `docker compose` installed and functional.

## Run All Tests

Using kerberos authentication:

```shell
./samba/dc.sh docker compose up runner
```

## Build Wheels

Must run on linux; will use docker containers for the build.

```shell
pip install --user cibuildwheel
./samba/dc.sh ./build_and_test_wheels.sh
```

After each wheel is built, it will be installed and used to establish a kerberos
session to the Samba DC.

Built wheels will be placed in pike/wheelhouse.
1 change: 1 addition & 0 deletions samba/admin_password
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pik3IzC00lss
9 changes: 9 additions & 0 deletions samba/build_and_test_wheels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -euxo pipefail

SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
cd $SCRIPTPATH/..

python3 -m cibuildwheel --platform linux "$@"
11 changes: 11 additions & 0 deletions samba/build_and_test_wheels27.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -euxo pipefail

SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
cd $SCRIPTPATH/..

docker build -t pike-buildwheel -f buildwheel/Dockerfile .
docker run -e HOST_IPV4 -e SAMBA_REALM -e SAMBA_SERVER -e ADMIN_PASSWORD \
-v $SCRIPTPATH/../wheelhouse:/wheelhouse pike-buildwheel
28 changes: 28 additions & 0 deletions samba/dc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

set -euxo pipefail

SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")

IF=$(/sbin/ip route|awk '/default/ { print $5 }')
export HOST_IPV4=$(ip -4 addr show $IF | grep -Po 'inet \K[\d.]+')
export SAMBADC_INTERFACES=$IF
export SAMBADC_HOSTNAME=dc
export SAMBA_WORKGROUP=PIKE
export SAMBA_REALM=${SAMBA_WORKGROUP}.TEST.LOCAL
export SAMBA_SERVER=${SAMBADC_HOSTNAME}.${SAMBA_REALM}
export ADMIN_PASSWORD=$(cat "$SCRIPTPATH/admin_password")

function cleanup ()
{
docker compose down
docker volume rm samba_lib samba_etc
}

trap cleanup EXIT
cd "$SCRIPTPATH"
docker compose up dc &
sleep 30
# pass off control to remaining args
"$@"
54 changes: 54 additions & 0 deletions samba/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
version: "3.1"

services:
runner:
build: .
environment:
- HOST_IPV4
- SAMBA_REALM
- SAMBA_SERVER
- ADMIN_PASSWORD
command: /src/pike/samba/run_all.sh
volumes:
- ${PWD}/..:/src/pike
dc:
image: ${REGISTRY_URI:-instantlinux}/samba-dc:latest
restart: always
network_mode: host
cap_add:
- CAP_SYS_ADMIN
hostname: ${SAMBADC_HOSTNAME:-dc}
environment:
INTERFACES: ${SAMBADC_INTERFACES:-lo eth0}
REALM: ${SAMBA_REALM:-pike.local}
TZ: ${TZ:-UTC}
WORKGROUP: ${SAMBA_WORKGROUP:-PIKE}
volumes:
- etc:/etc/samba
- lib:/var/lib/samba
- ${PWD}/share.conf:/etc/samba/conf.d/share.conf
- ${PWD}/samba/s1:/srv/s1
ports:
- 53:53
- 53:53/udp
- 88:88
- 88:88/udp
- 135:135
- 137-138:137-138/udp
- 139:139
- 389:389
- 389:389/udp
- 445:445
- 464:464
- 464:464/udp
- 636:636
- 3268-3269:3268-3269
- 49152-65535
secrets:
- samba-admin-password
volumes:
etc:
lib:
secrets:
samba-admin-password:
file: ${PWD}/admin_password
22 changes: 22 additions & 0 deletions samba/krb5.conf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -euxo pipefail

cat - >> /etc/hosts <<EOF
$HOST_IPV4 $SAMBA_REALM
$HOST_IPV4 $SAMBA_SERVER
EOF

cat - > /etc/krb5.conf <<EOF
[libdefaults]
default_realm = $SAMBA_REALM
[realms]
$SAMBA_REALM = {
kdc = $SAMBA_SERVER
}
EOF

cat /etc/hosts /etc/krb5.conf

printf "$ADMIN_PASSWORD\n" | kinit administrator

0 comments on commit e490283

Please sign in to comment.