Skip to content

Commit

Permalink
Merge pull request #32 from IMIO/plone6
Browse files Browse the repository at this point in the history
Added Plone6 compatibility
  • Loading branch information
sgeulette committed Feb 2, 2024
2 parents 6e694b2 + 45140d8 commit 9b164c9
Show file tree
Hide file tree
Showing 53 changed files with 1,258 additions and 742 deletions.
71 changes: 42 additions & 29 deletions .github/workflows/main.yml
@@ -1,7 +1,8 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: CI
name: Push tests
# run-name: ${{ github.actor }} push tests

on:
push:
Expand All @@ -15,19 +16,18 @@ jobs:
matrix:
include:
- python: 2.7.18
PLONE_VERSION: 4
continue-on-error: false
- python: 3.8.16
PLONE_VERSION: 52
continue-on-error: true
plone: 4.3
- python: 3.7.14
plone: 5.2
- python: 3.10.11
plone: "6.0"
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up pyenv and Python
uses: "gabrielfalcao/pyenv-action@v14"
with:
default: "${{ matrix.python }}"
command: pyenv -v
- name: Setup Env
run: |
sudo apt-get update -qqy
Expand All @@ -39,41 +39,51 @@ jobs:
sudo make
sudo make install
cd ..
mkdir -p buildout-cache/{eggs,downloads}
pip install -r requirements.txt coverage==5.3.1 wheel
pip install --upgrade pip
pip install -r requirements-${{ matrix.plone }}.txt
- name: Cache eggs
uses: actions/cache@v2
uses: actions/cache@v3
env:
cache-name: cache-eggs
with:
path: ~/buildout-cache/eggs
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.PLONE_VERSION }}
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ matrix.python }}-${{ matrix.plone }}
# - name: Cache eggs restore
# id: cache-restore
# uses: actions/cache/restore@v3
# env:
# cache-name: cache-eggs
# with:
# path: ~/buildout-cache/eggs
# key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ matrix.python }}-${{ matrix.plone }}
- name: buildout
run: |
cp test_plone${{matrix.PLONE_VERSION}}.cfg buildout.cfg
buildout -c ci.cfg annotate
buildout -c ci.cfg
sed -ie "s#test.cfg#test-${{matrix.plone}}.cfg#" gha.cfg
buildout -c gha.cfg annotate
buildout -c gha.cfg
# - name: Cache eggs save
# uses: actions/cache/save@v3
# with:
# path: ~/buildout-cache/eggs
# key: ${{ steps.cache-restore.outputs.cache-primary-key }}
- name: test
run: |
bin/test
continue-on-error: ${{matrix.continue-on-error}}
bin/test -t !robot
coverage:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- python: 2.7.18
PLONE_VERSION: 4
continue-on-error: false
plone: "4.3"
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up pyenv and Python
uses: "gabrielfalcao/pyenv-action@v14"
with:
default: "${{ matrix.python }}"
command: pyenv -v
- name: Setup Env
run: |
sudo apt-get update -qqy
Expand All @@ -85,26 +95,29 @@ jobs:
sudo make
sudo make install
cd ..
mkdir -p buildout-cache/{eggs,downloads}
pip install -r requirements.txt coverage==5.3.1 wheel
pip install --upgrade pip
pip install -r requirements-${{ matrix.plone }}.txt
pip install --upgrade pip
pip install -r requirements-${{matrix.plone}}.txt
pip install -U coveralls coverage
- name: Cache eggs
uses: actions/cache@v2
uses: actions/cache@v3
env:
cache-name: cache-eggs
with:
path: ~/buildout-cache/eggs
key: ${{ runner.os }}-build-${{ env.cache-name }}-coverage-${{ matrix.PLONE_VERSION }}
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ matrix.python }}-${{ matrix.plone }}
restore-keys: ${{ runner.os }}-test-${{ env.cache-name }}-${{ matrix.python }}-${{ matrix.plone }}
- name: buildout
run: |
cp test_plone${{matrix.PLONE_VERSION}}.cfg buildout.cfg
buildout -c ci.cfg annotate
buildout -c ci.cfg
sed -ie "s#test.cfg#test-${{matrix.plone}}.cfg#" gha.cfg
buildout -c gha.cfg
- name: code-analysis
run: |
bin/code-analysis
- name: test coverage
run: |
bin/coverage run bin/test
coverage run bin/test -t !robot
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,6 +4,7 @@
.installed.cfg
.mr.developer.cfg
.plone.versioncheck.*
.plone-version
.project
.pydevproject
.settings/
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -4,6 +4,8 @@ Changelog
0.81 (unreleased)
-----------------

- Require `pathlib2` in `setup.py`, backport `pathlib` for `py2.7`.
[gbastien]
- Added `security.setup_app` to be used in run scripts.
[sgeulette]
- Added `setup.load_xml_tool_only_from_package` to load only main tool xml file.
Expand Down
108 changes: 88 additions & 20 deletions Makefile
@@ -1,29 +1,97 @@
#!/usr/bin/make
#
all: run
py:=2.7
plone:=4
# pyenv is a requirement, with 2.7, 3.7 and 3.10 python versions, and virtualenv installed in each version
# plone parameter must be passed to create environment 'make setup plone=6.0' or after a make cleanall
# The original Makefile can be found on https://github.com/IMIO/scripts-buildout

.PHONY: bootstrap buildout run test cleanall
bootstrap:
virtualenv -p python$(py) .
bin/pip install -r requirements.txt
SHELL=/bin/bash
plones=4.3 5.2 6.0
b_o=
old_plone=$(shell [ -e .plone-version ] && cat .plone-version)

buildout:
cp test_plone$(plone).cfg buildout.cfg
if ! test -f bin/buildout;then make bootstrap;fi
bin/buildout
ifeq (, $(shell which pyenv))
$(error "pyenv command not found! Aborting")
endif

run:
if ! test -f bin/instance;then make buildout;fi
bin/instance fg
ifndef plone
ifeq (,$(filter setup,$(MAKECMDGOALS)))
plone=$(old_plone)
b_o=-N
endif
endif

test: buildout
bin/test
ifndef python
ifeq ($(plone),4.3)
python=2.7
endif
ifeq ($(plone),5.2)
python=3.7
endif
ifeq ($(plone),6.0)
python=3.10
endif
endif

all: buildout

.PHONY: help
help:
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)

.python-version: ## Setups pyenv version
@pyenv local `pyenv versions |grep " $(python)" |tail -1 |xargs`
@echo "Local pyenv version is `cat .python-version`"
@ if [[ `pyenv which virtualenv` != `pyenv prefix`* ]] ; then echo "You need to install virtualenv in `cat .python-version` pyenv python (pip install virtualenv)"; exit 1; fi

bin/buildout: .python-version ## Setups environment
virtualenv .
./bin/pip install --upgrade pip
./bin/pip install -r requirements-$(plone).txt
@echo "$(plone)" > .plone-version

.PHONY: setup
setup: oneof-plone backup cleanall bin/buildout restore ## Setups environment

.PHONY: buildout
buildout: oneof-plone bin/buildout ## Runs setup and buildout
rm -f .installed.cfg .mr.developer.cfg
bin/buildout -t 5 -c test-$(plone).cfg ${b_o}

.PHONY: test
test: oneof-plone bin/buildout ## run bin/test without robot
# can be run by example with: make test opt='-t "settings"'
bin/test -t \!robot ${opt}

.PHONY: cleanall
cleanall: ## Cleans all installed buildout files
rm -fr bin include lib local share develop-eggs downloads eggs parts .installed.cfg .mr.developer.cfg .python-version pyvenv.cfg

.PHONY: backup
backup: ## Backups db files
@if [ '$(old_plone)' != '' ] && [ -f var/filestorage/Data.fs ]; then mv var/filestorage/Data.fs var/filestorage/Data.fs.$(old_plone); mv var/blobstorage var/blobstorage.$(old_plone); fi

.PHONY: restore
restore: ## Restores db files
@if [ '$(plone)' != '' ] && [ -f var/filestorage/Data.fs.$(plone) ]; then mv var/filestorage/Data.fs.$(plone) var/filestorage/Data.fs; mv var/blobstorage.$(plone) var/blobstorage; fi

.PHONY: which-python
which-python: oneof-plone ## Displays versions information
@echo "current plone = $(old_plone)"
@echo "current python = `cat .python-version`"
@echo "plone var = $(plone)"
@echo "python var = $(python)"

.PHONY: vcr
vcr: ## Shows requirements in checkversion-r.html
bin/versioncheck -rbo checkversion-r.html ${cfg}
@bin/versioncheck -rbo checkversion-r-$(plone).html test-$(plone).cfg

.PHONY: vcn
vcn: ## Shows newer packages in checkversion-n.html
@bin/versioncheck -npbo checkversion-n-$(plone).html test-$(plone).cfg

.PHONY: guard-%
guard-%:
@ if [ "${${*}}" = "" ]; then echo "You must give a value for variable '$*' : like $*=xxx"; exit 1; fi

cleanall:
rm -fr bin develop-eggs htmlcov include .installed.cfg lib .mr.developer.cfg parts downloads eggs
.PHONY: oneof-%
oneof-%:
@ if ! echo "${${*}s}" | tr " " '\n' |grep -Fqx "${${*}}"; then echo "Invalid '$*' parameter ('${${*}}') : must be one of '${${*}s}'"; exit 1; fi

0 comments on commit 9b164c9

Please sign in to comment.