Skip to content

Commit

Permalink
Initial implementation of classic.demo.plone.org
Browse files Browse the repository at this point in the history
  • Loading branch information
ericof committed Dec 14, 2022
1 parent 78e60ac commit 66a113b
Show file tree
Hide file tree
Showing 71 changed files with 3,022 additions and 5 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,54 @@ jobs:
run: |
PYTHONWARNINGS=ignore zope-testrunner --auto-color --auto-progress --test-path src/plone_6_demo_site/src/
classic-black:
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v3

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

classic-flake8:
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v3

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

classic-isort:
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v3

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

classic-zpretty:
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v3

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

frontend-eslint:
runs-on: ubuntu-latest
defaults:
Expand Down Expand Up @@ -180,6 +228,10 @@ jobs:
- backend-isort
- backend-zpretty
- backend-tests
- classic-black
- classic-flake8
- classic-isort
- classic-zpretty
- frontend-eslint
- frontend-prettier
- frontend-i18n
Expand All @@ -195,6 +247,9 @@ jobs:
- image: frontend
context: frontend
file: Dockerfile
- image: classic
context: classic
file: Dockerfile
steps:

- name: Checkout
Expand Down
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
{ "eslint.workingDirectories": ["./frontend"] }
{
"eslint.workingDirectories": [
"./frontend"
],
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": "./.github/workflows/deploy.yml"
}
}
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ install: ## Install
@echo "Install Backend & Frontend"
$(MAKE) install-backend
$(MAKE) install-frontend
$(MAKE) install-classic

# TODO production build

Expand All @@ -69,6 +70,7 @@ build: ## Build in development mode
@echo "Build"
$(MAKE) build-backend
$(MAKE) install-frontend
$(MAKE) build-classic


.PHONY: start
Expand Down Expand Up @@ -113,6 +115,26 @@ build-images: ## Build docker images
@echo "Build"
$(MAKE) -C "./backend/" build-image
$(MAKE) -C "./frontend/" build-image
$(MAKE) -C "./classic/" build-image

## Classic

.PHONY: install-classic
install-classic: ## Create virtualenv and install Plone
$(MAKE) -C "./classic/" build-dev
$(MAKE) create-site-classic

.PHONY: build-backend
build-classic: ## Build classic
$(MAKE) -C "./classic/" build-dev

.PHONY: create-site-classic
create-site-classic: ## Create a Plone site with default content
$(MAKE) -C "./classic/" create-site

.PHONY: start-backend
start-classic: ## Start Plone Backend
$(MAKE) -C "./classic/" start

## Docker stack
.PHONY: start-stack
Expand Down
12 changes: 12 additions & 0 deletions classic/.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 classic/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHANGES.md merge=union
43 changes: 43 additions & 0 deletions classic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.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
28 changes: 28 additions & 0 deletions classic/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# syntax=docker/dockerfile:1
ARG SEED=1000
ARG PLONE_VERSION=6.0.0
FROM plone/plone-backend:${PLONE_VERSION}


LABEL maintainer="Plone Foundation <[email protected]>" \
org.label-schema.name="demo-classic" \
org.label-schema.description="Plone 6 Demo Site Classic 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}
./docker-entrypoint.sh create-site
EOT
166 changes: 166 additions & 0 deletions classic/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
### 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`

PLONE_VERSION=6.0.0

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-classic
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),0)
$(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 "pip" "wheel" "cookiecutter" "mxdev"

.PHONY: config
config: bin/pip ## Create instance configuration
@echo "$(GREEN)==> Create instance configuration$(RESET)"
bin/cookiecutter -f --no-input --config-file instance.yaml gh:plone/cookiecutter-zope-instance

# 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/plonedemo.site/src/

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

.PHONY: create-site
create-site: instance/etc/zope.ini ## Create a new site from scratch
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 classic/constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-c https://dist.plone.org/release/6.0.0/constraints.txt
8 changes: 8 additions & 0 deletions classic/instance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
default_context:
initial_user_name: 'admin'
initial_user_password: 'admin'

load_zcml:
package_includes: ['plonedemo.site']

db_storage: direct
Loading

0 comments on commit 66a113b

Please sign in to comment.