Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQT-compatible pre-commit + GitHub actions for 10, 11, 12 #132

Merged
merged 7 commits into from
Apr 29, 2022
Merged
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
2 changes: 1 addition & 1 deletion .flake8
10 changes: 10 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,19 @@ jobs:
- 3.6
- 3.8
odoo-version:
- 11.0
- 12.0
- 13.0
- 14.0
- 15.0
include:
- python-version: 2.7
odoo-version: 10.0
exclude:
- python-version: 3.8
odoo-version: 11.0
- python-version: 3.8
odoo-version: 12.0
Comment on lines +27 to +34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the test of the template, why does it depend on the Odoo/python version combination ?

steps:
# Prepare environment
- uses: actions/checkout@v2.3.3
Expand Down
2 changes: 1 addition & 1 deletion .isort.cfg
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ repos:
rev: v2.4.1
hooks:
- id: prettier
# https://github.com/prettier/prettier/issues/12143
exclude: "}$"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.yml
3 changes: 3 additions & 0 deletions copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ odoo_version:
type: float
default: 15.0
choices:
- 10.0
- 11.0
- 12.0
- 13.0
- 14.0
- 15.0
Expand Down
5 changes: 4 additions & 1 deletion src/.pre-commit-config.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
{%- endif %}

{#- Older versions that differ a lot have their own hardcoded templates for readability #}
{%- if odoo_version < 14 %}
{%- if odoo_version < 13 %}
{%- include "version-specific/mqt-compat/.pre-commit-config.yaml.jinja" %}

{%- elif odoo_version < 14 %}
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that this line breaks updates for version < 13 as there is only one version-specific/13.0 folder... ?

@carmenbianca @sbidoul

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems unlikely to me. It includes version-specific/mqt-compat, not version-specific/12.0.

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's about the line {%- elif odoo_version < 14 %}

That includes the {%- include "version-specific/%s/.pre-commit-config.yaml" % odoo_version %}part.

The line under mqt-compat 😃

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh I see; it's an elif.

But it seems to pass in that one for a 12.0 version.

Maybe the blank line ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's a string/float problem? It expects a float where there should be a string, or vice versa? Frankly I'm not sure. I wish I knew how to help.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can try replacing odoo_version with odoo_version|float or odoo_version|int in these checks. Just in case you're passing the version as a string for some reason.

Also make sure you're using the latest copier.

{%- include "version-specific/%s/.pre-commit-config.yaml" % odoo_version %}

{#- Newer versions without hacks are rendered here directly #}
Expand Down
4 changes: 4 additions & 0 deletions src/.pylintrc-mandatory.jinja
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{%- if odoo_version < 13 %}
{%- include "version-specific/mqt-compat/.pylintrc-mandatory.jinja" %}
{%- else %}
[MASTER]
load-plugins=pylint_odoo
score=n
Expand Down Expand Up @@ -97,3 +100,4 @@ enable=anomalous-backslash-in-string,
msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
output-format=colorized
reports=no
{%- endif %}
4 changes: 4 additions & 0 deletions src/.pylintrc.jinja
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{%- if odoo_version < 13 %}
{%- include "version-specific/mqt-compat/.pylintrc.jinja" %}
{%- else %}
{% extends "src/.pylintrc-mandatory.jinja" %}
{% block note %}
# This .pylintrc contains optional AND mandatory checks and is meant to be
Expand Down Expand Up @@ -25,3 +28,4 @@
too-complex,
unnecessary-utf8-coding-comment
{% endblock %}
{%- endif %}
1 change: 1 addition & 0 deletions src/{% if odoo_version < 13 %}.flake8{% endif %}.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{%- include "version-specific/mqt-compat/.flake8" %}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 7 additions & 4 deletions tests/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@ def test_bootstrap(tmp_path: Path, odoo_version: float, cloned_template: Path):
assert answers[key] == value
# Assert linter config files look like they were looking before
pylintrc_mandatory = (tmp_path / ".pylintrc-mandatory").read_text()
assert "disable=all\n\nenable=" in pylintrc_mandatory
assert "disable=all\n" in pylintrc_mandatory
assert "enable=" in pylintrc_mandatory
assert f"valid_odoo_versions={odoo_version}" in pylintrc_mandatory
assert SOME_PYLINT_OPTIONAL_CHECK not in pylintrc_mandatory
pylintrc_optional = (tmp_path / ".pylintrc").read_text()
assert "disable=all\n\n# This .pylintrc" in pylintrc_optional
assert "disable=all\n" in pylintrc_optional
assert "# This .pylintrc contains" in pylintrc_optional
assert f"valid_odoo_versions={odoo_version}" in pylintrc_optional
assert SOME_PYLINT_OPTIONAL_CHECK in pylintrc_optional
flake8 = (tmp_path / ".flake8").read_text()
assert "[flake8]" in flake8
isort = (tmp_path / ".isort.cfg").read_text()
assert "[settings]" in isort
if odoo_version > 12:
isort = (tmp_path / ".isort.cfg").read_text()
assert "[settings]" in isort
assert not (tmp_path / ".gitmodules").is_file()
# Assert other files
license_ = (tmp_path / "LICENSE").read_text()
Expand Down
10 changes: 10 additions & 0 deletions version-specific/mqt-compat/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[flake8]
# E123,E133,E226,E241,E242 are ignored by default by pep8 and flake8
# F811 is legal in odoo 8 when we implement 2 interfaces for a method
# F601 pylint support this case with expected tests
# W503 changed by W504 and OCA prefers allow both
# E203: whitespace before ':' (black behaviour and not pep8 compliant)
ignore = E123,E133,E226,E241,E242,F811,F601,W503,W504,E203
max-line-length = 88
per-file-ignores=
__init__.py:F401
61 changes: 61 additions & 0 deletions version-specific/mqt-compat/.pre-commit-config.yaml.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
exclude: |
(?x)
# NOT INSTALLABLE ADDONS
# END NOT INSTALLABLE ADDONS
# Files and folders generated by bots, to avoid loops
^setup/|/static/description/index\.html$|
# We don't want to mess with tool-generated files
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|
# Maybe reactivate this when all README files include prettier ignore tags?
^README\.md$|
# Library files can have extraneous formatting (even minimized)
/static/(src/)?lib/|
# Repos using Sphinx to generate docs don't need prettying
^docs/_templates/.*\.html$|
# You don't usually want a bot to modify your legal texts
(LICENSE.*|COPYING.*)
default_language_version:
python: python3
repos:
- repo: https://github.com/oca/maintainer-tools
rev: ab1d7f6
hooks:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
- id: oca-fix-manifest-website
args: ["{{ repo_website }}"]
- repo: https://github.com/acsone/setuptools-odoo
rev: 3.0.6
hooks:
- id: setuptools-odoo-make-default
{%- if generate_requirements_txt %}
- id: setuptools-odoo-get-requirements
args:
- --output
- requirements.txt
- --header
- "# generated from manifests external_dependencies"
{%- endif %}
- repo: https://github.com/OCA/mirrors-flake8
rev: v3.4.1
hooks:
- id: flake8
language_version: python{% if odoo_version < 11 %}2{% else %}3.6{% endif %}
name: flake8 excluding __init__.py
exclude: __init__\.py
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v2.5.3
hooks:
- id: pylint
name: pylint with optional checks
args:
- --rcfile=.pylintrc
- --exit-zero
verbose: true
additional_dependencies: &pylint_deps
- pylint-odoo==3.5.0
- id: pylint
name: pylint with mandatory checks
args:
- --rcfile=.pylintrc-mandatory
additional_dependencies: *pylint_deps
68 changes: 68 additions & 0 deletions version-specific/mqt-compat/.pylintrc-mandatory.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[MASTER]
load-plugins=pylint_odoo
score=n

[ODOOLINT]
readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
manifest_required_authors={{ org_name }}
manifest_required_keys=license
manifest_deprecated_keys=description,active
license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
valid_odoo_versions={{ odoo_version }}

[MESSAGES CONTROL]
disable=all

# Enable message and code:
# anomalous-backslash-in-string - W1401
# assignment-from-none - W1111
# dangerous-default-value - W0102
# duplicate-key - W0109
# missing-import-error - W7935
# missing-manifest-dependency - W7936
# pointless-statement - W0104
# pointless-string-statement - W0105
# print-statement - E1601
# redundant-keyword-arg - E1124
# reimported - W0404
# relative-import - W0403
# return-in-init - E0101
# rst-syntax-error - E7901
# too-few-format-args - E1306
# unreachable - W0101

{% block note %}{% endblock %}

enable=anomalous-backslash-in-string,
assignment-from-none,
dangerous-default-value,
development-status-allowed,
duplicate-key,
duplicate-po-message-definition,
missing-import-error,
missing-manifest-dependency,
po-msgstr-variables,
po-syntax-error,
pointless-statement,
pointless-string-statement,
print-used,
redundant-keyword-arg,
reimported,
relative-import,
return-in-init,
rst-syntax-error,
too-few-format-args,
unreachable,
eval-used,
eval-referenced,
license-allowed,
manifest-author-string,
manifest-required-author,
manifest-required-key,
manifest-version-format
{%- block optional_checks %}{% endblock %}

[REPORTS]
msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
output-format=colorized
reports=no
91 changes: 91 additions & 0 deletions version-specific/mqt-compat/.pylintrc.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{% extends "version-specific/mqt-compat/.pylintrc-mandatory.jinja" %}
{% block note %}
# This .pylintrc contains optional AND mandatory checks and is meant to be
# loaded in an IDE to have it check everything, in the hope this will make
# optional checks more visible to contributors who otherwise never look at a
# green travis to see optional checks that failed.
# .pylintrc-mandatory containing only mandatory checks is used the pre-commit
# config as a blocking check.

# Beta message and code:
# api-one-deprecated - W8104
# api-one-multi-together - W8101
# attribute-deprecated - W8105
# class-camelcase - C8104
# create-user-wo-reset-password - W7905
# consider-merging-classes-inherited - R7980
# copy-wo-api-one - W8102
# dangerous-filter-wo-user - W7901
# dangerous-view-replace-wo-priority - W7940
# deprecated-module - W0402
# duplicate-id-csv - W7906
# duplicate-xml-fields - W7907
# duplicate-xml-record-id - W7902
# file-not-used - W7930
# incoherent-interpreter-exec-perm - W8201
# invalid-commit - E8102
# javascript-lint - W7903
# manifest-deprecated-key - C8103
# method-compute - C8108
# method-inverse - C8110
# method-required-super - W8106
# method-search - C8109
# missing-newline-extrafiles - W7908
# missing-readme - C7902
# no-utf8-coding-comment - C8201
# unnecessary-utf8-coding-comment - C8202
# odoo-addons-relative-import - W7950
# old-api7-method-defined - R8110
# openerp-exception-warning - R8101
# redundant-modulename-xml - W7909
# sql-injection - E8103
# too-complex - C0901
# translation-field - W8103
# translation-required - C8107
# use-vim-comment - W8202
# wrong-tabs-instead-of-spaces - W7910
# xml-syntax-error - E7902
{% endblock %}
{% block optional_checks %},
api-one-deprecated,
api-one-multi-together,
attribute-deprecated,
class-camelcase,
create-user-wo-reset-password,
consider-merging-classes-inherited,
copy-wo-api-one,
dangerous-filter-wo-user,
dangerous-view-replace-wo-priority,
deprecated-module,
duplicate-id-csv,
duplicate-po-message-definition,
duplicate-xml-fields,
duplicate-xml-record-id,
file-not-used,
incoherent-interpreter-exec-perm,
invalid-commit,
javascript-lint,
manifest-deprecated-key,
method-compute,
method-inverse,
method-required-super,
method-search,
missing-newline-extrafiles,
missing-readme,
po-msgstr-variables,
po-syntax-error,
no-utf8-coding-comment,
unnecessary-utf8-coding-comment,
odoo-addons-relative-import,
old-api7-method-defined,
openerp-exception-warning,
redefined-builtin,
redundant-modulename-xml,
sql-injection,
too-complex,
translation-field,
translation-required,
use-vim-comment,
wrong-tabs-instead-of-spaces,
xml-syntax-error,
{% endblock %}