Skip to content

Commit

Permalink
Merge pull request #74 from leemannd/rm-prod_demo_modes
Browse files Browse the repository at this point in the history
Clean: update references to modes prod and demo
  • Loading branch information
leemannd authored May 8, 2024
2 parents 5c549d0 + bdcc491 commit 12e259a
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 45 deletions.
14 changes: 14 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -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/
87 changes: 87 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Unreleased

**Features**

* mode: demo has been deprecated in favor of sample

**Bugfixes**

**Improvements**
Expand Down
16 changes: 8 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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::
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions marabunta/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions marabunta/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/examples/migration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/examples/migration_no_backup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/examples/migration_with_backup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 16 additions & 16 deletions tests/test_migration_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,23 @@ 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'
u'|> version setup: start\n'
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'
Expand All @@ -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'
Expand Down Expand Up @@ -161,23 +161,23 @@ 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'
u'|> version 0.0.1: start\n'
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'
Expand All @@ -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'
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 12e259a

Please sign in to comment.