diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..02d3153 --- /dev/null +++ b/.flake8 @@ -0,0 +1,14 @@ +[flake8] +max-line-length = 88 +max-complexity = 16 +# B = bugbear +# B9 = bugbear opinionated (incl line length) +select = E,F,W,B,B9 +# E203: whitespace before ':' (black behaviour) +# E501: flake8 line length (covered by bugbear B950) +# W503: line break before binary operator (black behaviour) +# W504: line break after binary operator (black behaviour) +ignore = E203,E501,W503,W504 +exclude = + ./.git + .eggs/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..3262a13 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,87 @@ +default_language_version: + python: python3 +repos: + - repo: local + hooks: + # These files are most likely copier diff rejection junks; if found, + # review them manually, fix the problem (if needed) and remove them + - id: forbidden-files + name: forbidden files + entry: found forbidden files; remove them + language: fail + files: "\\.rej$" + - repo: https://github.com/myint/autoflake + rev: v2.1.1 + hooks: + - id: autoflake + args: + - --expand-star-imports + - --ignore-init-module-imports + - --in-place + - --remove-all-unused-imports + - --remove-duplicate-keys + - --remove-unused-variables + - repo: https://github.com/psf/black + rev: 23.3.0 + hooks: + - id: black + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v3.1.0 + hooks: + - id: prettier + name: prettier (with plugin-xml) + additional_dependencies: + - "prettier@2.1.2" + - "@prettier/plugin-xml@0.12.0" + args: + - --plugin=@prettier/plugin-xml + files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$ + - repo: https://github.com/pre-commit/mirrors-eslint + rev: v8.40.0 + hooks: + - id: eslint + verbose: true + args: + - --color + - --fix + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + # exclude autogenerated files + exclude: /README\.rst$|\.pot?$ + - id: end-of-file-fixer + # exclude autogenerated files + exclude: /README\.rst$|\.pot?$ + - 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://github.com/asottile/pyupgrade + rev: v3.4.0 + hooks: + - id: pyupgrade + args: ["--keep-percent-format"] + - repo: https://github.com/PyCQA/isort + rev: 5.12.0 + hooks: + - id: isort + name: isort except __init__.py + args: + - --settings=. + exclude: /__init__\.py$ + - repo: https://github.com/PyCQA/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + name: flake8 + additional_dependencies: ["flake8-bugbear==20.1.4"] diff --git a/HISTORY.rst b/HISTORY.rst index 99033d1..ee78052 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -8,6 +8,8 @@ Unreleased **Features** +* mode: demo has been deprecated in favor of sample + **Bugfixes** **Improvements** diff --git a/README.rst b/README.rst index 7508d11..2312182 100644 --- a/README.rst +++ b/README.rst @@ -7,7 +7,7 @@ *Marabunta is a name given to the migration of the legionary ants or to the ants themselves. Restless, they eat and digest everything in their way.* -Marabunta is used to provide an easy way to create Updates for Odoo fast and run easily. It also allows to differentiate between different environment to provide for instance demodata. +Marabunta is used to provide an easy way to create Updates for Odoo fast and run easily. It also allows to differentiate between different environment to provide for instance sample data. Usage @@ -24,7 +24,7 @@ Features * backup: Marabunta allows for a backup command to be executed before the migration. * addon upgrades: Marabunta is able to install or upgrade odoo addons. * operations: Allows to execute commands before or after upgrading modules. -* modes: Modes allow the user to execute commands only on a certain environment. e.g. creation of demodata on a dev system. +* modes: Modes allow the user to execute commands only on a certain environment. e.g. creation of sample data on a dev system. * maintenance page: publish an html page during the migration. Versioning systems @@ -63,7 +63,7 @@ Options +-------------------+----------+---------------------------+-------------------------------------------------------------------+ | --web-custom-html | | MARABUNTA_WEB_CUSTOM_HTML | Path to custom maintenance html page to serve. | +-------------------+----------+---------------------------+-------------------------------------------------------------------+ - + YAML layout & Example ===================== Here is an Example migration file:: @@ -90,19 +90,19 @@ Here is an Example migration file:: - base - document modes: - prod: + full: operations: pre: - - echo 'pre-operation executed only when the mode is prod' + - echo 'pre-operation executed only when the mode is full' post: - anthem songs::load_production_data - demo: + sample: operations: post: - - anthem songs::load_demo_data + - anthem songs::load_sample_data addons: upgrade: - - demo_addon + - sample_addon - version: 0.0.2 backup: false diff --git a/marabunta/config.py b/marabunta/config.py index 615af1f..aa890d6 100644 --- a/marabunta/config.py +++ b/marabunta/config.py @@ -133,7 +133,7 @@ def get_args_parser(): envvar='MARABUNTA_MODE', required=False, help="Specify the mode in which we run the migration," - "such as 'demo' or 'prod'. Additional operations " + "such as 'sample' or 'full'. Additional operations " "of this mode will be executed after the main " "operations and the addons list of this mode " "will be merged with the main addons list.") @@ -168,7 +168,7 @@ def get_args_parser(): required=False, default=os.environ.get( 'MARABUNTA_WEB_RESP_STATUS', 503 - ), + ), help='Response HTTP status code of the web server') group.add_argument('--web-resp-retry-after', type=int, @@ -177,8 +177,8 @@ def get_args_parser(): 'MARABUNTA_WEB_RESP_RETRY_AFTER', 300 ), help=( - '"Retry-After" header value (in seconds) of ' - 'response delivered by the web server') + '"Retry-After" header value (in seconds) of ' + 'response delivered by the web server') ) group.add_argument('--web-custom-html', required=False, diff --git a/marabunta/parser.py b/marabunta/parser.py index f12b2fc..0216ca9 100644 --- a/marabunta/parser.py +++ b/marabunta/parser.py @@ -42,19 +42,19 @@ - document # remove: # uninstalled with a python script modes: - prod: + full: operations: pre: - - echo 'pre-operation executed only when the mode is prod' + - echo 'pre-operation executed only when the mode is full' post: - anthem songs::load_production_data - demo: + sample: operations: post: - - anthem songs::load_demo_data + - anthem songs::load_sample_data addons: upgrade: - - demo_addon + - sample_addon - version: 0.0.2 backup: false diff --git a/tests/examples/migration.yml b/tests/examples/migration.yml index b315367..ae85804 100644 --- a/tests/examples/migration.yml +++ b/tests/examples/migration.yml @@ -11,14 +11,14 @@ migration: post: # executed after 'addons' - echo 'post-operation' modes: - prod: + full: operations: pre: - - echo 'pre-operation executed only when the mode is prod' - demo: + - echo 'pre-operation executed only when the mode is full' + sample: operations: post: - - echo 'post-operation executed only when the mode is demo' + - echo 'post-operation executed only when the mode is sample' - version: 0.0.2 # nothing to do diff --git a/tests/examples/migration_no_backup.yml b/tests/examples/migration_no_backup.yml index b74d90d..615961c 100644 --- a/tests/examples/migration_no_backup.yml +++ b/tests/examples/migration_no_backup.yml @@ -11,14 +11,14 @@ migration: post: # executed after 'addons' - echo 'post-operation' modes: - prod: + full: operations: pre: - - echo 'pre-operation executed only when the mode is prod' - demo: + - echo 'pre-operation executed only when the mode is full' + sample: operations: post: - - echo 'post-operation executed only when the mode is demo' + - echo 'post-operation executed only when the mode is sample' - version: 0.0.2 # nothing to do diff --git a/tests/examples/migration_with_backup.yml b/tests/examples/migration_with_backup.yml index ce59fde..4f16425 100644 --- a/tests/examples/migration_with_backup.yml +++ b/tests/examples/migration_with_backup.yml @@ -15,14 +15,14 @@ migration: post: # executed after 'addons' - echo 'post-operation' modes: - prod: + full: operations: pre: - - echo 'pre-operation executed only when the mode is prod' - demo: + - echo 'pre-operation executed only when the mode is full' + sample: operations: post: - - echo 'post-operation executed only when the mode is demo' + - echo 'post-operation executed only when the mode is sample' - version: 0.0.2 # nothing to do diff --git a/tests/test_migration_file.py b/tests/test_migration_file.py index 20790e0..dce1037 100644 --- a/tests/test_migration_file.py +++ b/tests/test_migration_file.py @@ -72,7 +72,7 @@ def test_example_file_output(runner_gen, request, capfd): def test_example_file_output_mode(runner_gen, request, capfd): - runner = runner_gen('migration.yml', mode='prod') + runner = runner_gen('migration.yml', mode='full') runner.perform() expected = ( u'|> migration: processing version setup\n' @@ -80,15 +80,15 @@ def test_example_file_output_mode(runner_gen, request, capfd): u'|> version setup: execute base pre-operations\n' u'|> version setup: echo \'pre-operation\'\n' u'pre-operation\r\n' - u'|> version setup: execute prod pre-operations\n' + u'|> version setup: execute full pre-operations\n' u'|> version setup: echo \'pre-operation executed only' - u' when the mode is prod\'\n' - u'pre-operation executed only when the mode is prod\r\n' + u' when the mode is full\'\n' + u'pre-operation executed only when the mode is full\r\n' u'|> version setup: installation / upgrade of addons\n' u'|> version setup: execute base post-operations\n' u'|> version setup: echo \'post-operation\'\n' u'post-operation\r\n' - u'|> version setup: execute prod post-operations\n' + u'|> version setup: execute full post-operations\n' u'|> version setup: done\n' u'|> migration: processing version 0.0.2\n' u'|> version 0.0.2: start\n' @@ -101,12 +101,12 @@ def test_example_file_output_mode(runner_gen, request, capfd): u'foobar\r\n' u'|> version 0.0.3: echo \'foobarbaz\'\n' u'foobarbaz\r\n' - u'|> version 0.0.3: execute prod pre-operations\n' + u'|> version 0.0.3: execute full pre-operations\n' u'|> version 0.0.3: installation / upgrade of addons\n' u'|> version 0.0.3: execute base post-operations\n' u'|> version 0.0.3: echo \'post-op with unicode é â\'\n' u'post-op with unicode é â\r\n' - u'|> version 0.0.3: execute prod post-operations\n' + u'|> version 0.0.3: execute full post-operations\n' u'|> version 0.0.3: done\n' u'|> migration: processing version 0.0.4\n' u'|> version 0.0.4: start\n' @@ -161,7 +161,7 @@ def test_example_no_setup_file_output(runner_gen, request, capfd): def test_example_no_setup_file_output_mode(runner_gen, request, capfd): msg = 'First version should be named `setup`' with pytest.warns(FutureWarning, match=msg): - runner = runner_gen('migration_no_backup.yml', mode='prod') + runner = runner_gen('migration_no_backup.yml', mode='full') runner.perform() expected = ( u'|> migration: processing version 0.0.1\n' @@ -169,15 +169,15 @@ def test_example_no_setup_file_output_mode(runner_gen, request, capfd): u'|> version 0.0.1: execute base pre-operations\n' u'|> version 0.0.1: echo \'pre-operation\'\n' u'pre-operation\r\n' - u'|> version 0.0.1: execute prod pre-operations\n' + u'|> version 0.0.1: execute full pre-operations\n' u'|> version 0.0.1: echo \'pre-operation executed only' - u' when the mode is prod\'\n' - u'pre-operation executed only when the mode is prod\r\n' + u' when the mode is full\'\n' + u'pre-operation executed only when the mode is full\r\n' u'|> version 0.0.1: installation / upgrade of addons\n' u'|> version 0.0.1: execute base post-operations\n' u'|> version 0.0.1: echo \'post-operation\'\n' u'post-operation\r\n' - u'|> version 0.0.1: execute prod post-operations\n' + u'|> version 0.0.1: execute full post-operations\n' u'|> version 0.0.1: done\n' u'|> migration: processing version 0.0.2\n' u'|> version 0.0.2: start\n' @@ -190,12 +190,12 @@ def test_example_no_setup_file_output_mode(runner_gen, request, capfd): u'foobar\r\n' u'|> version 0.0.3: echo \'foobarbaz\'\n' u'foobarbaz\r\n' - u'|> version 0.0.3: execute prod pre-operations\n' + u'|> version 0.0.3: execute full pre-operations\n' u'|> version 0.0.3: installation / upgrade of addons\n' u'|> version 0.0.3: execute base post-operations\n' u'|> version 0.0.3: echo \'post-op with unicode é â\'\n' u'post-op with unicode é â\r\n' - u'|> version 0.0.3: execute prod post-operations\n' + u'|> version 0.0.3: execute full post-operations\n' u'|> version 0.0.3: done\n' u'|> migration: processing version 0.0.4\n' u'|> version 0.0.4: start\n' @@ -216,7 +216,7 @@ def test_mixed_digits_output_mode(runner_gen, request, capfd): VersionRecord('11.3.0', '2018-09-05', '2018-09-05', '', ''), ] runner = runner_gen( - 'migration_mixed_digits.yml', mode='prod', db_versions=old_versions) + 'migration_mixed_digits.yml', mode='full', db_versions=old_versions) runner.perform() expected = ( u'|> migration: processing version setup', @@ -261,7 +261,7 @@ def test_mixed_digits_output_mode2(runner_gen, request, capfd): VersionRecord('10.17.0', '2018-09-06', '2018-09-06', '', ''), ] runner = runner_gen( - 'migration_mixed_digits2.yml', mode='prod', db_versions=old_versions) + 'migration_mixed_digits2.yml', mode='full', db_versions=old_versions) runner.perform() expected = ( u'|> migration: processing version setup',