Skip to content

Commit

Permalink
Merge pull request #75 from acsone/v14-and-stuff-sbi
Browse files Browse the repository at this point in the history
Various improvements to project template
  • Loading branch information
sbidoul authored Dec 28, 2020
2 parents 69cdb84 + 5daae57 commit afa5851
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 134 deletions.
20 changes: 8 additions & 12 deletions acsoo/templates/project/+project.name+/.gitlab-ci.yml.bob
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
stages:
- code quality
- build
- test
- deploy
Expand All @@ -8,7 +7,7 @@ before_script:
- |
function install_acsoo {
virtualenv --python=$PYTHON venv-acsoo
venv-acsoo/bin/pip install acsoo==x.y.z # pin acsoo!
venv-acsoo/bin/pip install acsoo
ln -s venv-acsoo/bin/acsoo
}
function install_pre_commit {
Expand Down Expand Up @@ -39,7 +38,7 @@ variables:
DB_NAME: "${CI_PROJECT_NAME}-${CI_JOB_ID}"

pre-commit:
stage: code quality
stage: test
tags:
- python
cache:
Expand All @@ -49,6 +48,7 @@ pre-commit:
script:
- install_pre_commit
- PRE_COMMIT_HOME=$PWD/.pre-commit ./pre-commit run --all-files
needs: []

build:
stage: build
Expand All @@ -59,7 +59,7 @@ build:
script:
- start_ssh_agent
- virtualenv --python=$PYTHON venv
- venv/bin/pip wheel --no-deps -r requirements.txt -e . --wheel-dir=release
- venv/bin/pip wheel --no-deps -r requirements.txt -e . --wheel-dir=./release
artifacts:
expire_in: 1 week
paths:
Expand All @@ -81,16 +81,12 @@ test:
- virtualenv --python=$PYTHON venv
- venv/bin/pip install coverage
# use --no-index so missing dependencies that would not be in *.whl are detected
- venv/bin/pip install --no-index release/*.whl
# although the project is part of *.whl, install it in editable mode so coverage sees it
- venv/bin/pip install --no-index -e .
# install the project in editable mode (-e) so coverage sees it
- venv/bin/pip install --no-index --find-links release -e .
- ADDONS_INIT=$(./acsoo addons list-depends)
- echo Installing ${ADDONS_INIT}
- unbuffer venv/bin/click-odoo-initdb -c odoo-ci.cfg --new-database ${DB_NAME} --cache-prefix {{{ project.trigram }}} -m ${ADDONS_INIT} | ./acsoo checklog
# do not test server_environment_files because server_environment depends on it,
# so testing server_environment_files implies testing server_environment,
# and the server_environment tests require a very specific server_environment_files
- ADDONS_TEST=$(./acsoo addons --exclude server_environment_files list)
- ADDONS_TEST=$(./acsoo addons list)
- echo Testing ${ADDONS_TEST}
- unbuffer venv/bin/coverage run --branch venv/bin/{{{ odoocmd }}} -c odoo-ci.cfg -d ${DB_NAME} --stop-after-init --no-xmlrpc -i ${ADDONS_TEST} --test-enable | ./acsoo checklog
- venv/bin/coverage html
Expand All @@ -111,7 +107,7 @@ deploy-test:
- start_ssh_agent
- ./deploy-test
environment:
name: test
name: {{{ project.name }}}-test
url: https://odoo-{{{ project.name }}}-test.acsone.eu
only:
- /^\d+\.\d+\.\d+$/
Expand Down
160 changes: 77 additions & 83 deletions acsoo/templates/project/+project.name+/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,87 +1,81 @@
exclude: "^(?!odoo/)|.pot$|.po$"
default_language_version:
python: python3
node: "14.13.0"
repos:
- repo: https://github.com/psf/black
rev: 19.10b0
hooks:
- id: black
- repo: https://github.com/prettier/prettier
rev: 2.0.2
hooks:
- id: prettier
additional_dependencies:
- "@prettier/[email protected]"
args:
- --plugin=@prettier/plugin-xml
files: "\\.(\
css|less|scss\
|graphql|gql\
|html\
|js|jsx\
|json\
|md|markdown|mdown|mkdn\
|mdx\
|ts|tsx\
|vue\
|yaml|yml\
|xml\
)$"
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v6.8.0
hooks:
- id: eslint
verbose: true
args:
- --color
- --fix
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- id: flake8
name: flake8 except __init__.py
args: [--exclude=__init__.py]
additional_dependencies: [
"flake8-bugbear==19.8.0",
"flake8-per-file-ignores==0.8.1",
]
- id: flake8
name: flake8 only __init__.py
args: ["--extend-ignore=F401"] # ignore unused imports in __init__.py
files: __init__.py
- id: fix-encoding-pragma
args: ["--remove"]
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-merge-conflict
# exclude files where underlines are not distinguishable from merge conflicts
exclude: /README\.rst$|^docs/.*\.rst$
- id: check-symlinks
- id: check-xml
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v2.3.1
hooks:
- id: pylint
name: pylint odoo
# check only specific Odoo addons
files: odoo/addons/
types: ['file', 'python'] # to not check .csv and .conf files
args: []
additional_dependencies: [pylint-odoo==3.1.0]
- repo: https://github.com/asottile/pyupgrade
rev: v1.26.2
hooks:
- id: pyupgrade
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
hooks:
- id: isort
name: isort except __init__.py
exclude: /__init__\.py$
- repo: https://github.com/myint/autoflake
rev: v1.4
hooks:
- id: autoflake
args: ["-i", "--ignore-init-module-imports"]
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.2.1
hooks:
- id: prettier
name: prettier + plugin-xml
additional_dependencies:
- "[email protected]"
- "@prettier/[email protected]"
args:
- --plugin=@prettier/plugin-xml
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v7.14.0
hooks:
- id: eslint
verbose: true
args:
- --color
- --fix
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- id: fix-encoding-pragma
args: ["--remove"]
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-merge-conflict
# exclude files where underlines are not distinguishable from merge conflicts
exclude: /README\.rst$|^docs/.*\.rst$
- id: check-symlinks
- id: check-xml
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
name: flake8 except __init__.py
exclude: /__init__\.py$
additional_dependencies: ["flake8-bugbear==19.8.0"]
- id: flake8
name: flake8 only __init__.py
args: ["--extend-ignore=F401"] # ignore unused imports in __init__.py
files: /__init__\.py$
additional_dependencies: ["flake8-bugbear==19.8.0"]
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v2.6.0
hooks:
- id: pylint
name: pylint
files: odoo/addons/
args: []
additional_dependencies: [pylint-odoo==3.5.0]
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.4
hooks:
- id: pyupgrade
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.6.4
hooks:
- id: isort
name: isort except __init__.py
exclude: /__init__\.py$
38 changes: 10 additions & 28 deletions acsoo/templates/project/+project.name+/README.rst.bob
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,19 @@ Initialize virtualenv

- create and activate virtualenv, using python 3's standard `python -m venv` or possibly with virtualenvwrapper's
``mkvirtualenv odoo-{{{ project.name }}} -a . --python=$(which {{{ python_version }}})``
- make sure acsoo [#]_ is installed and in your PATH
- make sure acsoo [#]_ and pip-deepfreeze [#]_ are installed and in your PATH
- to save some time it is recommended to configure git-autoshare [#]_.

Install everything
------------------

.. code:: bash
In an activated python 3.6 virtualenv, run::

pip install -r requirements.txt -e .
pip-df sync

Only when there is a need to refresh the frozen dependencies,
review ``gitaggregate.yaml`` and ``requirements.txt.in``, then
run:

.. code:: bash

gitaggregate -c gitaggregate.yaml -p
rmvirtualenv odoo-{{{ project.name }}}
mkvirtualenv odoo-{{{ project.name }}} -a . --python=$(which {{{ python_version }}})
pip install --pre -r requirements.txt.in
./freeze.sh
git commit requirements.txt
When dependencies change, use ``pip-df sync`` again, possibly with
``--update``. Add unmerged VCS dependencies in ``requirements.txt.in``. See the
pip-deepfreeze documentation for more information.

Run
---
Expand All @@ -50,7 +41,7 @@ Copy ``odoo.cfg.template`` to ``odoo.cfg`` and update it as needed, then run::
Develop
-------

This project uses Black [#]_ as code formatting convention.
This project uses Black [#]_ and other code formatters.
To make sure local coding convention are respected before
you commit, install pre-commit [#]_ and
run ``pre-commit install`` after cloning the repository.
Expand All @@ -59,25 +50,16 @@ Release
-------

First make sure you have been testing using the correct dependencies by
running ``./freeze.sh`` and checking there is no change in ``requirements.txt``.
running ``pip-df sync`` and checking there is no change in ``requirements.txt``.

To release using gitlab-ci
.........................
..........................

- run acsoo tag, the deploy to the test environment will be automatic, and
gitlab will show a button on the pipeline to deploy to production.

To release manually
...................

- update version in ``acsoo.cfg`` and ``{{{ project.name }}}_all/__{{% if odoo.series in ['8.0', '9.0'] %}}openerp{{% else %}}manifest{{% endif %}}__.py``
- commit everything
- run ``acsoo release``

At that point the resulting wheel files in ``./release`` contain all the
code to be deployed.

.. [#] https://pypi.python.org/pypi/acsoo/#installation
.. [#] https://pypi.python.org/pypi/pip-deepfreeze
.. [#] https://pypi.python.org/pypi/git-autoshare
.. [#] https://github.com/ambv/black
.. [#] https://github.com/pre-commit/pre-commit
8 changes: 0 additions & 8 deletions acsoo/templates/project/+project.name+/freeze.bob

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,3 @@ odoo-autodiscover>=2.0

# patched OCA addons
# odoo{short_version}-addon-{addon} @ git+https://github.com/acsone/{oca-project}.git@{{{ odoo.series }}}-{{{ project.trigram }}}_master#subdirectory=setup/{addon}

# local project
-e .
2 changes: 2 additions & 0 deletions acsoo/templates/project/+project.name+/setup.py.bob
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ setup(
setup_requires=['setuptools-odoo'],
install_requires=[
'click-odoo-contrib>=1.4.1',
'xlrd',
{{% if odoo.enterprise }}'odoo-addons-enterprise',{{% endif -%}}
],
odoo_addons=True,
)

0 comments on commit afa5851

Please sign in to comment.