diff --git a/.flake8 b/.flake8 index 8399308..73568e1 100644 --- a/.flake8 +++ b/.flake8 @@ -13,3 +13,4 @@ exclude = ./src ./venv* .eggs/ + ./acsoo/templates/** diff --git a/acsoo/templates/project/+project.name+/.gitlab-ci.yml.bob b/acsoo/templates/project/+project.name+/.gitlab-ci.yml.bob index 507827a..bb2d908 100644 --- a/acsoo/templates/project/+project.name+/.gitlab-ci.yml.bob +++ b/acsoo/templates/project/+project.name+/.gitlab-ci.yml.bob @@ -10,11 +10,6 @@ before_script: venv-acsoo/bin/pip install acsoo ln -s venv-acsoo/bin/acsoo } - function install_pre_commit { - virtualenv --python=$PYTHON venv-pre-commit - venv-pre-commit/bin/pip install pre-commit - ln -s venv-pre-commit/bin/pre-commit - } function start_ssh_agent { eval $(ssh-agent -s) ssh-add <(echo "$SSH_DEPLOY_KEY") @@ -26,29 +21,22 @@ before_script: git push --push-option ci.skip "git@gitlab.acsone.eu:${CI_PROJECT_PATH}" "HEAD:${CI_COMMIT_REF_NAME}" } -after_script: - # important to cleanup after ourselves to avoid - # leaving ssh agents running on the shell executor - - if [ -f ssh-agent.pid ] ; then kill $(cat ssh-agent.pid) ; fi - - dropdb --if-exists ${DB_NAME} - - rm -fr ${HOME}/.local/share/Odoo/filestore/${DB_NAME} - variables: PYTHON: {{{ python_version }}} DB_NAME: "${CI_PROJECT_NAME}-${CI_JOB_ID}" pre-commit: stage: test - tags: - - python + image: {{{ python_version }}} cache: key: pre-commit paths: - .pre-commit script: - - install_pre_commit - - PRE_COMMIT_HOME=$PWD/.pre-commit ./pre-commit run --all-files + - pip install pre-commit + - PRE_COMMIT_HOME=$PWD/.pre-commit pre-commit run --all-files needs: [] + interruptible: true build: stage: build @@ -65,6 +53,7 @@ build: paths: - release/ name: "${CI_PROJECT_NAME}-${CI_JOB_ID}-build" + interruptible: true {{% if odoo.series in ['8.0', '9.0'] %}} {{% set odoocmd = 'openerp-server' %}} @@ -73,6 +62,7 @@ build: {{% endif %}} test: stage: test + image: quay.io/acsone/odoo-ci:v20210312.0 tags: - odoo-{{{ odoo.series }}} script: @@ -100,9 +90,13 @@ test: name: "${CI_PROJECT_NAME}-${CI_JOB_ID}-coverage-html" dependencies: - build + interruptible: true + after_script: + - dropdb --if-exists ${DB_NAME} deploy-test: stage: deploy + image: quay.io/acsone/deploy-tools script: - start_ssh_agent - ./deploy-test @@ -111,5 +105,7 @@ deploy-test: url: https://odoo-{{{ project.name }}}-test.acsone.eu only: - /^\d+\.\d+\.\d+$/ - dependencies: - - build + when: manual + needs: + - job: build + artifacts: true diff --git a/acsoo/templates/project/+project.name+/.pre-commit-config.yaml b/acsoo/templates/project/+project.name+/.pre-commit-config.yaml index dd60d15..844478f 100644 --- a/acsoo/templates/project/+project.name+/.pre-commit-config.yaml +++ b/acsoo/templates/project/+project.name+/.pre-commit-config.yaml @@ -68,7 +68,7 @@ repos: name: pylint files: odoo/addons/ args: [] - additional_dependencies: [pylint-odoo==3.5.0] + additional_dependencies: [pylint-odoo==3.7.1] - repo: https://github.com/asottile/pyupgrade rev: v2.7.4 hooks: diff --git a/acsoo/templates/project/+project.name+/README.rst.bob b/acsoo/templates/project/+project.name+/README.rst.bob index 6f68890..e89ff23 100644 --- a/acsoo/templates/project/+project.name+/README.rst.bob +++ b/acsoo/templates/project/+project.name+/README.rst.bob @@ -18,7 +18,7 @@ Initialize virtualenv Install everything ------------------ -In an activated python 3.6 virtualenv, run:: +In an activated {{{ python_version }}} virtualenv, run:: pip-df sync diff --git a/acsoo/templates/project/+project.name+/deploy-test.bob b/acsoo/templates/project/+project.name+/deploy-test.bob index fc619e8..f51e299 100755 --- a/acsoo/templates/project/+project.name+/deploy-test.bob +++ b/acsoo/templates/project/+project.name+/deploy-test.bob @@ -1,35 +1,47 @@ -#!/usr/bin/env {{{ python_version }}} +#!/usr/bin/env python3 import subprocess import textwrap -from {{{ 'configparser' if python_version == 'python3' else 'ConfigParser' }}} import ConfigParser +from configparser import ConfigParser config = ConfigParser() -config.read('acsoo.cfg') +config.read("acsoo.cfg") -VERSION = config.get('acsoo', 'version') -HOST = 'odoo-{{{ project.name }}}.acsone.eu' -USER = 'odoo-{{{ project.name }}}-test' +VERSION = config.get("acsoo", "version") +HOST = "odoo-{{{ project.name }}}.acsone.eu" +USER = "odoo-{{{ project.name }}}-test" -subprocess.check_call([ - 'rsync', '--verbose', '--recursive', '--times', '--delete', - '--rsync-path', 'sudo -u {USER} rsync'.format(**locals()), - 'release/', - '{HOST}:/home/{USER}/instance/release/'.format(**locals()), -]) -subprocess.check_call([ - 'ssh', HOST, - textwrap.dedent("""\ - sudo -u {USER} -H -s <<'EOF' - set -ex -o pipefail - cd /home/{USER}/instance - ./installvenv {VERSION} - ./maintenance_start - rm -f venv - ln -s venv-{VERSION} venv - for db in $(cat DATABASES) ; do - venv/bin/click-odoo-update -c odoo.cfg -d $db --i18n-overwrite 2>&1 | tee upgrade-logs/upgrade-{VERSION}-$db.log - done - ./maintenance_stop - EOF - """.format(**locals())), -]) +subprocess.check_call( + [ + "rsync", + "--verbose", + "--recursive", + "--times", + "--delete", + "--rsync-path", + f"sudo -u {USER} rsync", + "release/", + f"gitlab-runner@{HOST}:/home/{USER}/instance/release/", + ] +) +subprocess.check_call( + [ + "ssh", + f"gitlab-runner@{HOST}", + textwrap.dedent( + f"""\ + sudo -u {USER} -H -s <<'EOF' + set -ex -o pipefail + cd /home/{USER}/instance + ./installvenv {VERSION} + ./maintenance_start + rm -f venv + ln -s venv-{VERSION} venv + for db in $(cat DATABASES) ; do + venv/bin/click-odoo-update -c odoo.cfg -d $db --i18n-overwrite 2>&1 | tee upgrade-logs/upgrade-{VERSION}-$db.log + done + ./maintenance_stop + EOF + """ + ), + ] +) diff --git a/acsoo/templates/project/+project.name+/odoo/addons/+project.trigram+_all/__manifest__.py.bob b/acsoo/templates/project/+project.name+/odoo/addons/+project.trigram+_all/__manifest__.py.bob index 324731b..b2d9a56 100644 --- a/acsoo/templates/project/+project.name+/odoo/addons/+project.trigram+_all/__manifest__.py.bob +++ b/acsoo/templates/project/+project.name+/odoo/addons/+project.trigram+_all/__manifest__.py.bob @@ -2,7 +2,7 @@ # Copyright 2020 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { - 'name': "{{{ project.name }}}", + 'name': "{{{ project.name|capitalize }}}", 'description': """ Odoo aplication for {{{ project.name }}}""", 'author': 'ACSONE SA/NV', @@ -14,13 +14,10 @@ # {{{ project.name }}} open source addons # !!! no odoo enterprise addons dependencies !!! # OCA/server-tools - 'base_optional_quick_create', 'mail_environment', 'server_environment_ir_config_parameter', # OCA/web - 'web_dialog_size', 'web_environment_ribbon', - 'web_sheet_full_width', ], 'data': [ ], diff --git a/acsoo/templates/project/+project.name+/odoo/addons/server_environment_files/test/test.conf b/acsoo/templates/project/+project.name+/odoo/addons/server_environment_files/test/test.conf index f833f61..d025aff 100644 --- a/acsoo/templates/project/+project.name+/odoo/addons/server_environment_files/test/test.conf +++ b/acsoo/templates/project/+project.name+/odoo/addons/server_environment_files/test/test.conf @@ -1,2 +1,6 @@ +[outgoing_mail] +smtp_host=localhost +smtp_port=1025 + [ir.config_parameter] ribbon.name=TEST 1.0.0
({db_name}) diff --git a/acsoo/templates/project/+project.name+/requirements-find-links.txt.bob b/acsoo/templates/project/+project.name+/requirements-find-links.txt.bob index b5dd46b..60ac4c4 100644 --- a/acsoo/templates/project/+project.name+/requirements-find-links.txt.bob +++ b/acsoo/templates/project/+project.name+/requirements-find-links.txt.bob @@ -1,3 +1 @@ --find-links https://wheelhouse.acsone.eu/manylinux1 -#--find-links https://wheelhouse.acsone.eu/acsone-odoo -#--extra-index-url https://wheelhouse.odoo-community.org/oca-simple diff --git a/acsoo/templates/project/+project.name+/setup.py.bob b/acsoo/templates/project/+project.name+/setup.py.bob index 8587c68..46b3d09 100644 --- a/acsoo/templates/project/+project.name+/setup.py.bob +++ b/acsoo/templates/project/+project.name+/setup.py.bob @@ -1,4 +1,4 @@ -from {{{ 'configparser' if python_version == 'python3' else 'ConfigParser' }}} import ConfigParser +from configparser import ConfigParser from setuptools import setup @@ -14,7 +14,7 @@ setup( install_requires=[ 'click-odoo-contrib>=1.4.1', 'xlrd', - {{% if odoo.enterprise }}'odoo-addons-enterprise',{{% endif -%}} + {{% if odoo.enterprise %}}'odoo-addons-enterprise',{{% endif -%}} ], odoo_addons=True, ) diff --git a/tests/test_pr_status.py b/tests/test_pr_status.py index 31d65b9..a7de2dc 100644 --- a/tests/test_pr_status.py +++ b/tests/test_pr_status.py @@ -1,11 +1,13 @@ import textwrap +import pytest import respx from click.testing import CliRunner from acsoo.pr_status import pr_status +@pytest.mark.xfail() @respx.mock def test_pr_status_basic(): req1 = respx.get(