Skip to content

camptocamp/marabunta

Repository files navigation

🐜🐜🐜 Marabunta 🐜🐜🐜

PyPI CI Ruff ty

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 sample data.

Installation

In Odoo environments, psycopg2 is already provided by Odoo itself, so a plain pip install marabunta is enough. For standalone installs, pick the appropriate extra:

pip install 'marabunta[psycopg2]'         # production (requires libpq)
pip install 'marabunta[psycopg2-binary]'  # development / CI

Usage

After installing marabunta, it will be available as a console command. To run properly it requires a migration file (which defines what has to updated/executed) and odoos connection parameters (view options in the options section.

At each run marabunta verifies the versions from the migration file and and processes new ones. It is very much recommended to configure it, so that marabunta is ran automatically if odoo is started. For instance adding it to your docker entrypoint.

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 sample data on a dev system.
  • maintenance page: publish an html page during the migration.

Versioning systems

Currently Marabunta allows for two different Versioning systems: The classic Major.Minor.Bugfix and the Five digits long versions for OdooMajor.OdooMinor.Major.Minor.Bugfix. Although the first marabunta version must be setup for the initial setup of your instance. (Find out more about the rationale here <https://github.com/camptocamp/marabunta/commit/9b96acaff8e7eecbf82ff592b7bb927b4cd82f02>)

Options

Option Shortcut Env var Purpose
--migration-file -f MARABUNTA_MIGRATION_FILE Definition file for the migration.
--database -d MARABUNTA_DATABASE Database we want to run the migration on.
--db-user -u MARABUNTA_DB_USER, PGUSER Database user.
--db-password -w MARABUNTA_DB_PASSWORD, PGPASSWORD Database password.
--db-port -p MARABUNTA_DB_PORT, PGPORT Database port (defaults to 5432).
--db-host -H MARABUNTA_DB_HOST, PGHOST Database port (defaults to None).
--mode   MARABUNTA_MODE Mode marabunta runs in for different envs.
--allow-serie   MARABUNTA_ALLOW_SERIE Allow multiple versions to be upgraded at once.
--force-version   MARABUNTA_FORCE_VERSION Force the upgrade to a version no matter what.
--override-translations   MARABUNTA_OVERRIDE_TRANSLATIONS Force translations override.
--web-host   MARABUNTA_WEB_HOST Interface to bind for the maintenance page (defaults to 0.0.0.0).
--web-port   MARABUNTA_WEB_PORT Port for the maintenance page (defaults to 8069).
--web-custom-html   MARABUNTA_WEB_CUSTOM_HTML Path to custom maintenance html page to serve.

YAML layout & Example

Here is an Example migration file:

migration:
  options:
    # This includes general options which are used everytime marabunta is called.
    # --workers=0 --stop-after-init are automatically added
    install_command: odoo #Command which starts odoo
    install_args: --log-level=debug # additional Arguments
    backup: # Defines how the backup should be done before the migration.
      command: echo "backup command on ${DB_NAME}"
      stop_on_failure: true
      ignore_if: test "${RUNNING_ENV}" != "prod"
  versions:
    - version: setup # Setup is always the initia. version<
      operations:
        pre:  # executed before 'addons'
          - echo 'pre-operation'
        post:  # executed after 'addons'
          - anthem songs::install
      addons:
        upgrade:  # executed as odoo --stop-after-init -i/-u ...
          - base
          - document
      modes:
        full:
          operations:
            pre:
              - echo 'pre-operation executed only when the mode is full'
            post:
              - anthem songs::load_production_data
        sample:
          operations:
            post:
              - anthem songs::load_sample_data
          addons:
            upgrade:
              - sample_addon

    - version: 0.0.2
      backup: false
      # nothing to do this can be used to keep marabunta and gittag in sync

    - version: 0.0.3
      operations:
        pre: # we also can execute os commands
          - echo 'foobar'
          - ls
          - bin/script_test.sh
        post:
          - echo 'post-op'

    - version: 0.0.4
      backup: false
      override_translations: true
      addons:
        upgrade:
          - popeye

Development

Run the tests

Tests use uv to manage the development environment:

git clone https://github.com/camptocamp/marabunta.git
cd marabunta
uv sync
uv run pytest

Pre-commit hooks

This project uses pre-commit to run ruff and other checks before each commit. We recommend prek, a faster drop-in replacement written in Rust:

uv tool install prek
prek install

From then on the hooks run automatically on git commit. To run them on demand:

prek run --all-files

About

🐜🐜🐜 Migrating ants for Odoo 🐜🐜🐜

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors