Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[report]
include =
src/collective/*
omit =
*/test*
*/upgrades/*
71 changes: 35 additions & 36 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,92 +1,91 @@
# This is a basic workflow to help you get started with Actions
# 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:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- python: 2.7.18
plone: 4.3
# - python: 2.7.18
# plone: 4.3
# - python: 3.7.14
# plone: 5.2
# - python: 3.10.11
# plone: "6.0"
- python: 3.13.1
plone: "6.1"
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up pyenv and Python
uses: "gabrielfalcao/pyenv-action@v14"
uses: "gabrielfalcao/pyenv-action@v18"
with:
default: "${{ matrix.python }}"
command: pyenv -v
- name: Setup Env
run: |
pip install -r requirements.txt coverage==5.3.1
pip install --upgrade pip
pip install -r requirements-${{ matrix.plone }}.txt
- name: Cache eggs
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-eggs
with:
path: ~/buildout-cache/eggs
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ matrix.plone }}
restore-keys: ${{ runner.os }}-test-${{ env.cache-name }}-${{ matrix.plone }}
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ matrix.python }}-${{ matrix.plone }}
- name: buildout
run: |
sed -ie "s#test-4.3#test-${{matrix.plone}}#" 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: test
run: |
bin/test -t !robot
coverage:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- python: 2.7.18
PLONE_VERSION: 4
continue-on-error: false
- python: 3.10.11
plone: "6.0"
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up pyenv and Python
uses: "gabrielfalcao/pyenv-action@v14"
uses: "gabrielfalcao/pyenv-action@v18"
with:
default: "${{ matrix.python }}"
command: pyenv -v
- name: Setup Env
run: |
pip install -r requirements.txt coverage==5.3.1
pip install --upgrade pip
pip install -r requirements-${{matrix.plone}}.txt
pip install -U coveralls coverage
- name: Cache eggs
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-eggs
with:
path: ~/buildout-cache/eggs
key: ${{ runner.os }}-coverage-${{ env.cache-name }}
restore-keys: ${{ runner.os }}-coverage-${{ env.cache-name }}
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ matrix.python }}-${{ matrix.plone }}
- name: buildout
run: |
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 -t !robot
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install Coveralls
run: |
pip3 install -U pip setuptools --no-cache-dir
pip3 install -U "coveralls>=3.0.0" coverage==5.3.1 --no-cache-dir
coverage run bin/test -t !robot
- name: Publish to Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.pyc
.installed.cfg
.mr.developer.cfg
.plone.versioncheck.tracked.json
.project
.pydevproject
pyvenv.cfg
Expand Down
97 changes: 97 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/make
# pyenv is a requirement, with 3.10, 3.13 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

SHELL=/bin/bash
plones=6.0 6.1
b_o=
old_plone=$(shell [ -e .plone-version ] && cat .plone-version)

ifeq (, $(shell which pyenv))
$(error "pyenv command not found! Aborting")
endif

ifndef plone
ifeq (,$(filter setup,$(MAKECMDGOALS)))
plone=$(old_plone)
endif
endif

ifneq ($(wildcard bin/instance),)
b_o=-N
endif

ifndef python
ifeq ($(plone),6.0)
python=3.10
endif
ifeq ($(plone),6.1)
python=3.13
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-$(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

.PHONY: oneof-%
oneof-%:
@ if ! echo "${${*}s}" | tr " " '\n' |grep -Fqx "${${*}}"; then echo "Invalid '$*' parameter ('${${*}}') : must be one of '${${*}s}'"; exit 1; fi
19 changes: 13 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ Features
--------

This behavior adds some metadata related to scanning:
* scan_id : scan identification as a barcode
* version : version number
* pages_number : pages number
* scan_date : scan date
* scan_user : scan user
* scanner : scanner or pc information

- scan_id : scan identification as a barcode
- version : version number
- pages_number : pages number
- scan_date : scan date
- scan_user : scan user
- scanner : scanner or pc information

Translations
------------
Expand All @@ -36,6 +37,12 @@ Install collective.dms.scanbehavior by adding it to your buildout::

and then running "bin/buildout"

Versions
--------

- Version 2.x is for Plone 6+ only
- Version 1.x is for Plone 4

Contribute
----------

Expand Down
103 changes: 103 additions & 0 deletions base.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
[buildout]
package-name = collective.dms.scanbehavior
package-extras = [test]

extends =
https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg
checkouts.cfg

extensions =
mr.developer
plone.versioncheck

parts +=
instance
omelette
ploneversioncheck
createcoverage
robot
# coverage
# test-coverage
# plone-helper-scripts

develop = .

eggs +=
Plone
Pillow
# Products.PDBDebugMode
# collective.profiler
# ipdb
pdbp
# plone.reload

package-extras +=
pdbp

always-checkout = force

[instance]
environment-vars +=
PYTHONBREAKPOINT pdbp.set_trace
eggs +=
${buildout:eggs}
zcml +=

[test]
environment = testenv
initialization +=
os.environ['PYTHONBREAKPOINT'] = 'pdbp.set_trace'

[testenv]
zope_i18n_compile_mo_files = true

[omelette]
recipe = collective.recipe.omelette
eggs = ${test:eggs}

[ploneversioncheck]
recipe = zc.recipe.egg
eggs = plone.versioncheck

[code-analysis]
recipe = plone.recipe.codeanalysis
pre-commit-hook = True
return-status-codes = True
directory = ${buildout:directory}/src/collective/dms/scanbehavior
flake8-ignore = E123,E124,E501,E126,E127,E128,W391,C901,W503,W504
flake8-extensions =
flake8-isort

[robot]
recipe = zc.recipe.egg
eggs =
Pillow
${test:eggs}
plone.app.robotframework[reload, debug]

[coverage]
recipe = zc.recipe.egg
eggs = coverage

[test-coverage]
recipe = collective.recipe.template
input = inline:
#!/bin/bash
export TZ=UTC
${buildout:directory}/bin/coverage run bin/test $*
${buildout:directory}/bin/coverage html
${buildout:directory}/bin/coverage report -m --fail-under=90
# Fail (exit status 1) if coverage returns exit status 2 (this happens
# when test coverage is below 100%.
output = ${buildout:directory}/bin/test-coverage
mode = 755

[plone-helper-scripts]
recipe = zc.recipe.egg
eggs =
Products.CMFPlone
${instance:eggs}
interpreter = zopepy
scripts =
zopepy
plone-compile-resources
2 changes: 0 additions & 2 deletions buildout.cfg

This file was deleted.

15 changes: 0 additions & 15 deletions buildout.d/base.cfg

This file was deleted.

Loading