Skip to content

Commit

Permalink
Merge branch 'main' into fb_pip_using_pyproject_toml
Browse files Browse the repository at this point in the history
  • Loading branch information
drfho authored Nov 28, 2024
2 parents bf3831e + 6d51fd6 commit a3ba8d6
Show file tree
Hide file tree
Showing 22 changed files with 323 additions and 132 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.devcontainer
.github
.ropeproject
.vscode
build
dist
docker/alpine/var
docker/elastic
docker/solr
docker/ubuntu/var
docker/zeo/var
docker/zope/var
87 changes: 44 additions & 43 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,49 @@
name: tests

on:
push:
pull_request:
schedule:
- cron: '0 12 * * 0' # run once a week on Sunday
# Allow to run this workflow manually from the Actions tab
workflow_dispatch:
push:
pull_request:
schedule:
- cron: "0 12 * * 0" # run once a week on Sunday
# Allow to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
strategy:
# We want to see all failures:
fail-fast: false
matrix:
os:
- ubuntu
config:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
runs-on: ${{ matrix.os }}-latest
name: ${{ matrix.os }}-${{ matrix.config }}
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.config }}
- name: Pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.config }}-${{ hashFiles('setup.*', 'requirements*') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.config }}-
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip pytest
pip install -e .
- name: Test
run: |
tree -L 1
pytest ./tests/
build:
strategy:
# We want to see all failures:
fail-fast: false
matrix:
os:
- ubuntu
config:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
runs-on: ${{ matrix.os }}-latest
name: ${{ matrix.os }}-${{ matrix.config }}
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.config }}
- name: Pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.config }}-${{ hashFiles('setup.*', 'requirements*') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.config }}-
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip pytest
pip install -e .
- name: Test
run: |
tree -L 1
pytest ./tests/
29 changes: 15 additions & 14 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
{
"version": "0.2.0",

"configurations": [
{
"name": "ZMS5-DEV",
"type": "python",
"request": "launch",
"program": "~/vpy38/bin/runwsgi",
"program": "~/vpy313/bin/runwsgi",
"justMyCode": false,
"console": "integratedTerminal",
"args": [
"--debug",
"--verbose",
"~/instance/zms5_dev/etc/zope.ini",
"debug-mode=on",
// "http_port=8086",
"debug-mode=on"
],
"env": {
"PYTHONUNBUFFERED":"1",
"PYTHONUNBUFFERED": "1",
"CONFIG_FILE": "~/instance/zms5_dev/etc/zope.ini",
"INSTANCE_HOME": "~/instance/zms5_dev",
"CLIENT_HOME": "~/instance/zms5_dev",
"PYTHON": "~/vpy38/bin/python",
"SOFTWARE_HOME": "~/vpy38/bin/"
"PYTHON": "~/vpy313/bin/python",
"SOFTWARE_HOME": "~/vpy313/bin/"
},
"serverReadyAction":{
"pattern":"Serving on http://127.0.0.1:8081",
"serverReadyAction": {
"pattern": "Serving on http://127.0.0.1:8081",
"uriFormat": "http://127.0.0.1:8081/manage_main",
"action": "openExternally",
},
"action": "openExternally"
}
},



{
"name": "Python Debugger: Python File",
"type": "debugpy",
"request": "launch",
"program": "${file}"
}
]
}
4 changes: 3 additions & 1 deletion Products/zms/_fileutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ def extractZipArchive(file):

zf = zipfile.ZipFile( file, 'r')
for name in zf.namelist():
if name.startswith('__MACOSX/') or name.endswith('.DS_Store'):
continue
dir = getOSPath( name)
i = dir.rfind( os.sep)
if i > 0:
Expand Down Expand Up @@ -516,4 +518,4 @@ def tail_lines(filename,linesback=10,returnlist=0):
for l in lines[start:len(lines)-1]: out=out + l + "\n"
return out

################################################################################
################################################################################
10 changes: 8 additions & 2 deletions Products/zms/repositoryutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import inspect
import os
import re
import sys
# Product Imports.
from Products.zms import IZMSConfigurationProvider
from Products.zms import IZMSRepositoryProvider
Expand Down Expand Up @@ -65,8 +66,13 @@ def get_repo_providers(context):
"""
def get_class(py):
id = re.findall('class (.*?):', py)[0]
exec(py)
return eval(id)
if sys.version_info >= (3, 13):
py = py + "\nglobal c\nc = " + id
exec(py, globals=globals(), locals=locals())
return eval("c", globals=globals(), locals=locals())
else:
exec(py)
return eval(id)


"""
Expand Down
5 changes: 5 additions & 0 deletions bin/run_tests_in_docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

exec docker compose run --rm zope \
watching_testrunner --basepath Products --basepath tests \
-- pytest --tb=short $@
77 changes: 54 additions & 23 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,56 @@
services:
zope:
build: ./docker/base
image: zope:latest
depends_on:
- zeo
stop_grace_period: 1s # SIGKILL after 1s, as zope is always taking the full 10 seconds
ports:
- 80:80
volumes:
- .:/home/zope/venv/src/zms/
- ./docker/zope/etc/:/home/zope/etc/
- ./docker/zope/var/:/home/zope/var/
# To share external methods between Zope/ZEO/Docker clients folder needs to be mounted
- ./docker/zope/Extensions/:/home/zope/Extensions/
# allow attaching to the container to debug with `breakpoint()`
stdin_open: true
tty: true
zope:
build:
context: .
dockerfile: ./docker/base/Dockerfile
image: localhost/zms:latest
depends_on:
- zeo
stop_grace_period: 1s # SIGKILL after 1s, as zope is always taking the full 10 seconds
command: runwsgi --debug --verbose etc/zope.ini debug-mode=on http_port=80
ports:
- 80:80
volumes:
- ./docker/zope/etc/:/home/zope/etc/
- ./docker/zope/var/:/home/zope/var/
# To share external methods between Zope/ZEO/Docker clients folder needs to be mounted
- ./docker/zope/Extensions/:/home/zope/Extensions/
# source code
- ./tests:/home/zope/tests
- ./test_output:/home/zope/test_output
- ./selenium_tests:/home/zope/selenium_tests
develop:
watch:
# sync+restart
- action: sync+restart
path: ./Products
target: /home/zope/Products
# rebuild
- action: rebuild
path: docker/base/Dockerfile
- action: rebuild
path: requirements.txt
- action: rebuild
path: requirements-zeo.txt
- action: rebuild
path: requirements-full.txt
- action: rebuild
path: requirements-dev.txt
- action: rebuild
path: setup.py
- action: rebuild
path: setup.cfg

zeo:
image: zope:latest
command: runzeo --configure etc/zeo.conf
volumes:
- ./docker/zeo/etc/:/home/zope/etc/
- ./docker/zeo/var/:/home/zope/var/
# allow attaching to the container to debug with `breakpoint()`
stdin_open: true
tty: true

zeo:
build:
context: .
dockerfile: ./docker/base/Dockerfile
image: localhost/zms:latest
command: runzeo --configure etc/zeo.conf
volumes:
- ./docker/zeo/etc/:/home/zope/etc/
- ./docker/zeo/var/:/home/zope/var/
15 changes: 9 additions & 6 deletions docker/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@
- [X] Starting the bare docker file will give you a basic zope / zms
- [x] everything as similar to our server deployment as possible to allow easy migration
- [x] modern os and python
- [ ] simple to use and develop in vscode -> .devcontainer!
- [x] simple to use and develop in vscode -> .devcontainer! FH has different solution
- [x] all mutable data in mounted volumes
- [ ] example systemd files to run everything
- [ ] this should show how automated container updates are done!
- [ ] example nginx config so you get the same experience as on the server
- [x] Allow working on zms inside the container
- [x] example systemd files to run everything
- [x] this should show how automated container updates are done!
- [ ] example nginx config so you get the same experience as on the server
- [ ] Full development experience with all dependennt services locally (mariadb, memcached, …)

# TODOs

- [x] Create basic Dockerfile for the project
- [x] specialize them for zeoserver and zope
- [x] create docker-compose file that runs each server separately
- [ ] add devcontainer.json to develop and run everything from vscode
- [ ] mount the zms source live into the container so working within it becomes possible
- [x] add devcontainer.json to develop and run everything from vscode
- [x] mount the zms source live into the container so working within it becomes possible
- [x] remove debug mode from zope Dockerfile
- [x] add script to run tests in docker
- [ ] add nginx, mariadb, memcached to docker-compose for a fully featured development environment, that can run production like configs
11 changes: 10 additions & 1 deletion docker/alpine/Extensions/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Externalizing Extensions for Docker

Hint: Mounting the folder ./Extensions keeps the external functions
synchronous to all all ZEO clients and Docker containers.
synchronous to all all ZEO clients and Docker containers.

Hint: if the docker container cannot write to the ./Extensions or ./var folder,
on a dev system you can simply set the permissions to 777.
Important:this not recommended for production!

```bash
chmod -R 777 Extensions
chmod -R 777 var
```
4 changes: 2 additions & 2 deletions docker/alpine/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: "3.7"
services:
zms5:
zms5-alpine:
build: .
image: zms5:latest
image: zms5-alpine:latest
ports:
- 8085:8085
- 8086:8086
Expand Down
8 changes: 6 additions & 2 deletions docker/alpine/dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine
FROM python:3.13-alpine

EXPOSE 8085
EXPOSE 8086
Expand All @@ -18,7 +18,11 @@ ENV VIRTUAL_ENV=/home/zope/venv
RUN python3 -m venv venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN pip install -U pip wheel setuptools
RUN pip install -U -e git+https://github.com/zms-publishing/ZMS.git@main#egg=ZMS
# RUN pip install -U -e git+https://github.com/zms-publishing/ZMS.git@main#egg=ZMS
# Install Zope --editable first, so that the toml-setup can be used
# https://github.com/zms-publishing/ZMS/pull/302#issuecomment-2327312673
RUN pip install -e git+https://github.com/zopefoundation/Zope.git@master#egg=Zope
RUN pip install -e git+https://github.com/zms-publishing/ZMS.git@fb_pip_using_pyproject_toml#egg=ZMS
RUN pip install -r https://raw.githubusercontent.com/zms-publishing/ZMS5/master/requirements-full.txt
RUN pip install ZEO
RUN pip install itsdangerous
Expand Down
Loading

0 comments on commit a3ba8d6

Please sign in to comment.