Skip to content

Commit

Permalink
Create a separte backend for plain volto
Browse files Browse the repository at this point in the history
restore the create_site.py in this backend from before we added the plone.distribution support/setup
Update GHA to build a separate backend
Add separate network for plain volto backend<>frontend communication
  • Loading branch information
fredvd committed May 15, 2024
1 parent 3306cea commit c4c2127
Show file tree
Hide file tree
Showing 70 changed files with 1,632 additions and 4 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/build_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,86 @@ jobs:
run: |
PYTHONWARNINGS=ignore zope-testrunner --auto-color --auto-progress --test-path src/plone_6_demo_site/src/
backend-volto-black:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Run check
uses: plone/code-analysis-action@v2
with:
base_dir: 'backend-volto'
check: 'black'

backend-volto-flake8:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Run check
uses: plone/code-analysis-action@v2
with:
base_dir: 'backend-volto'
check: 'flake8'

backend-volto-isort:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Run check
uses: plone/code-analysis-action@v2
with:
base_dir: 'backend-volto'
check: 'isort'

backend-volto-zpretty:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Run check
uses: plone/code-analysis-action@v2
with:
base_dir: 'backend-volto'
check: 'zpretty'

backend-volto-tests:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./backend-volto

steps:
- uses: actions/checkout@v4

- name: Setup Plone ${{ env.plone }} with Python ${{ env.python }}
uses: plone/setup-plone@v2.0.0
with:
python-version: ${{ env.python }}
plone-version: ${{ env.plone }}

- name: Install package
run: |
pip install mxdev
mxdev -c mx.ini
pip install -r requirements-mxdev.txt
- name: Run tests
run: |
PYTHONWARNINGS=ignore zope-testrunner --auto-color --auto-progress --test-path src/plone_6_demo_site/src/
classic-black:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
Expand Down Expand Up @@ -339,6 +419,9 @@ jobs:
- image: backend
context: backend
file: Dockerfile
- image: backend-volto
context: backend-volto
file: Dockerfile
- image: frontend
context: frontend
file: Dockerfile
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ on:
paths:
- "backend/**"
- "frontend/**"
- "frontend-volto/**"

- ".github/workflows/ci.yml"
pull_request:
paths:
- "backend/**"
- "backend-volto/**"

- "frontend/**"
- ".github/workflows/ci.yml"

Expand Down
12 changes: 12 additions & 0 deletions backend-volto/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.editorconfig
.gitattributes
bin
Dockerfile
include
instance
instance.yaml
lib
lib64
Makefile
pyvenv.cfg
var
1 change: 1 addition & 0 deletions backend-volto/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHANGES.md merge=union
44 changes: 44 additions & 0 deletions backend-volto/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.coverage
*.egg-info
*.log
*.mo
*.py?
*.swp
# dirs
bin/
buildout-cache/
data/*.json
develop-eggs/
eggs/
etc/
htmlcov/
include/
instance/
lib/
lib64/
local/
node_modules/
parts/
src/plone6demo/setuphandlers/data/*.json
dist/*
test.plone_addon/
var/
# files
.installed.cfg
.mr.developer.cfg
lib64
log.html
output.xml
pip-selfcheck.json
report.html
.vscode/
.tox/
reports/
venv/
*-mxdev.txt
# excludes
live.cfg
inituser
pip-wheel-metadata
pyvenv.cfg
instance-local.yaml
29 changes: 29 additions & 0 deletions backend-volto/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# syntax=docker/dockerfile:1
ARG SEED=1000
ARG PLONE_VERSION=6.0.11
FROM plone/plone-backend:${PLONE_VERSION}


LABEL maintainer="Plone Foundation <collective@plone.org>" \
org.label-schema.name="demo-backend-volto" \
org.label-schema.description="Plone 6 Demo Plain Volto Site backend image." \
org.label-schema.vendor="Plone Foundation"

# Add local code
COPY . .

# Install local requirements and fix permissions
RUN <<EOT
./bin/pip install mxdev
mv requirements-docker.txt requirements.txt
./bin/mxdev -c mx.ini
./bin/pip install -r requirements-mxdev.txt
chown -R plone: /app
EOT

# Create a new site with content
RUN <<EOT
SEED=${SEED}
ADDITIONAL_PROFILES=plone6demo:initial
./docker-entrypoint.sh create-site
EOT
175 changes: 175 additions & 0 deletions backend-volto/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
### Defensive settings for make:
# https://tech.davis-hansson.com/p/make/
SHELL:=bash
.ONESHELL:
.SHELLFLAGS:=-xeu -o pipefail -O inherit_errexit -c
.SILENT:
.DELETE_ON_ERROR:
MAKEFLAGS+=--warn-undefined-variables
MAKEFLAGS+=--no-builtin-rules

# We like colors
# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects
RED=`tput setaf 1`
GREEN=`tput setaf 2`
RESET=`tput sgr0`
YELLOW=`tput setaf 3`

# Set distributions still in development
DISTRIBUTIONS="voltodemo"
ALLOWED_DISTRIBUTIONS="voltodemo"

PLONE_VERSION=6.0.11

BACKEND_FOLDER=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

CODE_QUALITY_VERSION=2.0.2
ifndef LOG_LEVEL
LOG_LEVEL=INFO
endif
CURRENT_USER=$$(whoami)
USER_INFO=$$(id -u ${CURRENT_USER}):$$(getent group ${CURRENT_USER}|cut -d: -f3)
LINT=docker run --rm -e LOG_LEVEL="${LOG_LEVEL}" -v "${BACKEND_FOLDER}":/github/workspace plone/code-quality:${CODE_QUALITY_VERSION} check
FORMAT=docker run --rm --user="${USER_INFO}" -e LOG_LEVEL="${LOG_LEVEL}" -v "${BACKEND_FOLDER}":/github/workspace plone/code-quality:${CODE_QUALITY_VERSION} format

IMAGE_NAME=ghcr.io/plone/demo-backend-volto
IMAGE_TAG=latest

# Python checks
PYTHON?=python3

# installed?
ifeq (, $(shell which $(PYTHON) ))
$(error "PYTHON=$(PYTHON) not found in $(PATH)")
endif

# version ok?
PYTHON_VERSION_MIN=3.8
PYTHON_VERSION_OK=$(shell $(PYTHON) -c "import sys; print((int(sys.version_info[0]), int(sys.version_info[1])) >= tuple(map(int, '$(PYTHON_VERSION_MIN)'.split('.'))))")
ifeq ($(PYTHON_VERSION_OK),False)
$(error "Need python $(PYTHON_VERSION) >= $(PYTHON_VERSION_MIN)")
endif


# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
.PHONY: help
help: ## This help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: clean
clean: clean-build clean-pyc clean-test clean-venv clean-instance ## remove all build, test, coverage and Python artifacts

.PHONY: clean-instance
clean-instance: ## remove existing instance
rm -fr instance etc inituser var

.PHONY: clean-venv
clean-venv: ## remove virtual environment
rm -fr bin include lib lib64

.PHONY: clean-build
clean-build: ## remove build artifacts
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -rf {} +

.PHONY: clean-pyc
clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +

.PHONY: clean-test
clean-test: ## remove test and coverage artifacts
rm -f .coverage
rm -fr htmlcov/

bin/pip:
@echo "$(GREEN)==> Setup Virtual Env$(RESET)"
$(PYTHON) -m venv .
bin/pip install -U "setuptools" "pip" "wheel" "cookiecutter" "mxdev"

.PHONY: config
config: bin/pip ## Create instance configuration
@echo "$(GREEN)==> Create instance configuration$(RESET)"
if [[ -s instance-override.yaml ]]; then \
echo " Using instance-local.yaml"; \
bin/cookiecutter -f --no-input --config-file instance-local.yaml gh:plone/cookiecutter-zope-instance ;\
else \
bin/cookiecutter -f --no-input --config-file instance.yaml gh:plone/cookiecutter-zope-instance ;\
fi

# i18n
bin/i18ndude: bin/pip
@echo "$(GREEN)==> Install translation tools$(RESET)"
bin/pip install i18ndude

.PHONY: i18n
i18n: bin/i18ndude ## Update locales
@echo "$(GREEN)==> Updating locales$(RESET)"
bin/update_locale

# TODO `make build`
# build:

.PHONY: build-dev
build-dev: config ## pip install Plone packages
@echo "$(GREEN)==> Setup Build$(RESET)"
bin/mxdev -c mx.ini
bin/pip install -r requirements-mxdev.txt

.PHONY: format
format: ## Format the codebase according to our standards
@echo "$(GREEN)==> Format codebase$(RESET)"
$(FORMAT)

.PHONY: lint
lint: lint-isort lint-black lint-flake8 lint-zpretty ## check code style

.PHONY: lint-black
lint-black: ## validate black formating
$(LINT) black

.PHONY: lint-flake8
lint-flake8: ## validate black formating
$(LINT) flake8

.PHONY: lint-isort
lint-isort: ## validate using isort
$(LINT) isort

.PHONY: lint-pyroma
lint-pyroma: ## validate using pyroma
$(LINT) pyroma

.PHONY: lint-zpretty
lint-zpretty: ## validate ZCML/XML using zpretty
$(LINT) zpretty

.PHONY: test
test: ## run tests
./bin/zope-testrunner --auto-color --auto-progress --test-path src/plone6demo/src/

.PHONY: test_quiet
test_quiet: ## run tests removing deprecation warnings
PYTHONWARNINGS=ignore ./bin/zope-testrunner --auto-color --auto-progress --test-path src/plone6demo/src/

.PHONY: create-site
create-site: ## Create a new site using default distribution and default answers
DEVELOP_DISTRIBUTIONS=$(DISTRIBUTIONS) ALLOWED_DISTRIBUTIONS=$(DISTRIBUTIONS) PYTHONWARNINGS=ignore ./bin/zconsole run instance/etc/zope.conf scripts/create_site.py

.PHONY: start
start: ## Start a Plone instance on localhost:8080
PYTHONWARNINGS=ignore ./bin/runwsgi instance/etc/zope.ini

.PHONY: debug
debug: instance/etc/zope.ini ## Run debug console
PYTHONWARNINGS=ignore ./bin/zconsole debug instance/etc/zope.conf

.PHONY: build-image
build-image: ## Build Docker Image
@docker build . -t $(IMAGE_NAME):$(IMAGE_TAG) -f Dockerfile --build-arg PLONE_VERSION=$(PLONE_VERSION)
1 change: 1 addition & 0 deletions backend-volto/constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-c https://dist.plone.org/release/6.0.11/constraints.txt
7 changes: 7 additions & 0 deletions backend-volto/instance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
default_context:
initial_user_name: 'admin'
initial_user_password: 'admin'

zcml_package_includes: 'plone6demo'

db_storage: direct
Loading

0 comments on commit c4c2127

Please sign in to comment.