Skip to content

Tecnativa/doodba-qa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Doodba Quality Assurance

Build Status Docker Pulls Layers Commit License

BEWARE!, this project is in beta stage. Things are changing quickly.

What?

Tools for checking that your Doodba-based project is cool.

Why?

Because OCA's maintainer quality tools are too addons-repo-focused.

We needed a too Doodba-focused version instead. 😆

How?

  1. Mount your project structure, usually based on the provided scaffolding, on /project in the container. Docker CLI example: -v $(pwd):/project.
  2. Give him access to a Docker socket (beware of the security implications!) with --privileged -v /var/run/docker.sock or with -e DOCKER_HOST=tcp://dockerhost:2375.
  3. Configure through environment variables.
  4. Run any of the bundled scripts.

Example command for test environment, good for CI:

docker container run --rm -it --privileged -e COMPOSE_FILE=test.yaml -v "$PWD:/project:z" -v /var/run/docker.sock:/var/run/docker.sock:z tecnativa/doodba-qa pylint

Example command for devel environment, linting only private addons:

docker container run --rm -it --privileged -v "$PWD:$PWD:z" -v /var/run/docker.sock:/var/run/docker.sock:z -w "$PWD" -e ADDON_CATEGORIES=-p tecnativa/doodba-qa pylint

You most likely want to run this into a CI environment, so just check out the examples directory and you'll get a hint on how to do it.

Environment variables

You can use any of the upstream Docker Compose environment variables.

Besides, you have these too:

ADDON_CATEGORIES

Defaults to --private for all jobs.

You can change it per job, using any of --private --extra --core (or -pec).

These flags are used for the addons script available in all Doodba projects. Use this command in your project's folder to understand its usage:

docker-compose run --rm odoo addons --help

ADMIN_PASSWORD

Defaults to admin. If set, is used as the DB manager password.

ARTIFACTS_DIR

Directory where all the artifacts produced by insider scripts will be extracted.

ARTIFACTS_UID and ARTIFACTS_GID

UID/GID to be set as owner for artifacts produced by insider scripts.

BUILD_FLAGS

Flags to append to docker-compose build. Defaults to --pull --no-cache.

DESTROY_FLAGS

Flags to append to docker-compose down. Defaults to -v --rmi local --remove-orphans.

LINT_DISABLE

Disables specific linter messages. Its format depends on the underlying linter.

Defaults to manifest-required-author, since it's expected that you will only want to lint private addons, and those are not OCA's.

TODO: Make it work with flake8.

LINT_ENABLE

Enables specific linter messages. Its format depends on the underlying linter.

Empty by default.

TODO: Make it work with flake8.

LINT_MODE

Right now, only useful for pylint. Valid values:

  • loose (default) uses MQT standard cfg.
  • strict uses pull request cfg.
  • beta uses beta cfg.

PGPASSWORD

Used in secrets-setup when you need a specific DB password.

Defaults to odoopassword.

PYTHONOPTIMIZE

By default it is "" (disabled) to allow assert statements, which can be OK for tests, although not for production or demos.

More details in Python documentation.

REPOS_FILE

Path for the repos.yaml file in current scaffolding (not inside the container).

Scripts

You can use sh, docker and docker-compose commands with all of their features.

Besides, there are other scripts bundled, useful to do a CI pipeline:

addons-install

Install requested addons.

build

Build your project with docker-compose and check odoo works.

Uses BUILD_FLAGS.

closed-prs

Know if your repos.yaml definition includes merged or closed pull requests.

Uses the REPOS_FILE and GITHUB_TOKEN environment variables.

coverage

Run addons' unit tests and report coverage.

Usually you should run addons-install before.

You will find the HTML report files in ./$ARTIFACTS_DIR/coverage.

destroy

Destroy all containers, volumes, local images and networks.

Uses DESTROY_FLAGS.

flake8

Lint code with flake8 using MQT.

networks-autocreate

Create missing external networks, which are not autocreated by docker compose because it expects them to be present at the time of booting an environment.

Common examples of such networks are inverseproxy_shared or globalwhitelist_shared.

It extracts the required networks from the chosen docker-compose.yaml file.

pylint

Lint code with pylint-odoo using MQT.

Some environment variables modify this script's behavior; check them out.

secrets-setup

Creates all needed environment files for the official test.yaml environment to work.

Uses ADMIN_PASSWORD and PGPASSWORD.

shutdown

Like destroy, but keeping volumes and images.

Other utilities

These tools are not strictly related to Doodba, but they are helpful and are included: