[ADD] support make docker test and gen config
- fix running test in docker - use odoo user in docker - Makefile add repo_show_status - docker repo show status - Support older git version 2.20
This commit is contained in:
parent
85ba1fc664
commit
511c722bbc
7 changed files with 108 additions and 16 deletions
17
Makefile
17
Makefile
|
|
@ -307,6 +307,18 @@ docker_show_process:
|
|||
docker_exec_erplibre:
|
||||
./script/docker/docker_exec.sh
|
||||
|
||||
.PHONY: docker_exec_erplibre_gen_config
|
||||
docker_exec_erplibre_gen_config:
|
||||
./script/docker/docker_gen_config.sh
|
||||
|
||||
.PHONY: docker_exec_erplibre_make_test
|
||||
docker_exec_erplibre_make_test:
|
||||
./script/docker/docker_make_test.sh
|
||||
|
||||
.PHONY: docker_exec_erplibre_repo_show_status
|
||||
docker_exec_erplibre_repo_show_status:
|
||||
./script/docker/docker_repo_show_status.sh
|
||||
|
||||
# build docker
|
||||
.PHONY: docker_build
|
||||
docker_build:
|
||||
|
|
@ -340,6 +352,11 @@ repo_configure_all:
|
|||
repo_configure_group_code_generator:
|
||||
./script/update_manifest_local_dev_code_generator.sh
|
||||
|
||||
# configure only group code_generator
|
||||
.PHONY: repo_show_status
|
||||
repo_show_status:
|
||||
./.venv/repo forall -pc "git status -s"
|
||||
|
||||
# change all repo to ssh on all remote
|
||||
.PHONY: repo_use_all_ssh
|
||||
repo_use_all_ssh:
|
||||
|
|
|
|||
17
run.sh
17
run.sh
|
|
@ -1,8 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
source ./.venv/bin/activate
|
||||
python3 ./odoo/odoo-bin -c ./config.conf --limit-time-real 99999 --limit-time-cpu 99999 $@
|
||||
|
||||
CONFIG_PATH="./config.conf"
|
||||
ORIGIN_CONFIG_PATH=CONFIG_PATH
|
||||
if [ ! -f "${CONFIG_PATH}" ]; then
|
||||
CONFIG_PATH="/etc/odoo/odoo.conf"
|
||||
if [ ! -f "${CONFIG_PATH}" ]; then
|
||||
echo "Cannot find ERPLibre configuration ${ORIGIN_CONFIG_PATH}, did you install ERPLibre? > make install"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
python3 ./odoo/odoo-bin -c ${CONFIG_PATH} --limit-time-real 99999 --limit-time-cpu 99999 $@
|
||||
retVal=$?
|
||||
if [[ $retVal -ne 0 ]]; then
|
||||
echo "Error run.sh"
|
||||
exit 1
|
||||
echo "Error run.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -12,8 +12,14 @@ fi
|
|||
./script/repo_revert_git_diff_date_from_code_generator.py
|
||||
# Remove pot and po diff
|
||||
cd $3
|
||||
BRANCH=$(git branch --show-current)
|
||||
git restore --source="${BRANCH}" "*.po*"
|
||||
# git 2.22 and more, else use next command
|
||||
#BRANCH=$(git branch --show-current)
|
||||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
|
||||
# Support old version git < 2.23.0
|
||||
# git restore --source="${BRANCH}" "*.po*"
|
||||
git checkout -- "*.po*"
|
||||
|
||||
cd -
|
||||
./script/maintenance/black.sh $3
|
||||
echo "TEST ${2}"
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import os
|
|||
import sys
|
||||
import argparse
|
||||
import logging
|
||||
import configparser
|
||||
import getpass
|
||||
from subprocess import check_output
|
||||
|
||||
new_path = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
|
|
@ -49,11 +51,46 @@ def get_config():
|
|||
return args
|
||||
|
||||
|
||||
def get_master_password():
|
||||
try:
|
||||
# _logger.info("You have 5 secondes to add master password...")
|
||||
pa = getpass.getpass(
|
||||
prompt="\nEnter master password... "
|
||||
)
|
||||
return pa
|
||||
except getpass.GetPassWarning:
|
||||
_logger.error("Password echoed, danger!")
|
||||
|
||||
|
||||
def main():
|
||||
config = get_config()
|
||||
|
||||
arg_base = "./.venv/bin/python3 ./odoo/odoo-bin db"
|
||||
|
||||
# check if need master password from config file
|
||||
has_config_file = True
|
||||
config_path = "./config.py"
|
||||
if not os.path.isfile(config_path):
|
||||
config_path = "/etc/odoo/odoo.conf"
|
||||
if not os.path.isfile(config_path):
|
||||
has_config_file = False
|
||||
if has_config_file:
|
||||
config_parser = configparser.ConfigParser()
|
||||
config_parser.read(config_path)
|
||||
|
||||
has_admin_password = config_parser.get("options", "admin_passwd")
|
||||
if has_admin_password:
|
||||
master_password = get_master_password()
|
||||
if not master_password:
|
||||
_logger.error("Missing master password, cancel transaction.")
|
||||
sys.exit(1)
|
||||
else:
|
||||
arg_base += f" --master_password={master_password}"
|
||||
else:
|
||||
_logger.info("No master password needed... Continue")
|
||||
|
||||
# Get list of database
|
||||
arg = "./.venv/bin/python3 ./odoo/odoo-bin db --list"
|
||||
arg = f"{arg_base} --list"
|
||||
out = check_output(arg.split(" ")).decode()
|
||||
lst_db = out.strip().split("\n")
|
||||
lst_db_cache = [a for a in lst_db if a.startswith("_cache_")]
|
||||
|
|
@ -61,10 +98,7 @@ def main():
|
|||
if config.clean_cache:
|
||||
for db in lst_db_cache:
|
||||
_logger.info(f"## Delete {db} ##")
|
||||
arg = (
|
||||
"./.venv/bin/python3 ./odoo/odoo-bin db --drop --database"
|
||||
f" {db}"
|
||||
)
|
||||
arg = f"{arg_base} --drop --database {db}"
|
||||
out = check_output(arg.split(" ")).decode()
|
||||
print(out)
|
||||
|
||||
|
|
@ -73,10 +107,7 @@ def main():
|
|||
# Drop db
|
||||
if config.database in lst_db:
|
||||
_logger.info(f"## Drop {config.database} ##")
|
||||
arg = (
|
||||
"./.venv/bin/python3 ./odoo/odoo-bin db --drop --database"
|
||||
f" {config.database}"
|
||||
)
|
||||
arg = f"{arg_base} --drop --database {config.database}"
|
||||
out = check_output(arg.split(" ")).decode()
|
||||
print(out)
|
||||
# Check cache exist
|
||||
|
|
@ -86,7 +117,7 @@ def main():
|
|||
f" {config.image} ##"
|
||||
)
|
||||
arg = (
|
||||
"./.venv/bin/python3 ./odoo/odoo-bin db --restore"
|
||||
f"{arg_base} --restore"
|
||||
f" --restore_image {config.image} --database {cache_database}"
|
||||
)
|
||||
out = check_output(arg.split(" ")).decode()
|
||||
|
|
@ -96,7 +127,7 @@ def main():
|
|||
f"## Clone cache {cache_database} to database {config.database} ##"
|
||||
)
|
||||
arg = (
|
||||
"./.venv/bin/python3 ./odoo/odoo-bin db --clone --from_database"
|
||||
f"{arg_base} --clone --from_database"
|
||||
f" {cache_database} --database {config.database}"
|
||||
)
|
||||
out = check_output(arg.split(" ")).decode()
|
||||
|
|
|
|||
9
script/docker/docker_gen_config.sh
Executable file
9
script/docker/docker_gen_config.sh
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT=$(pwd)
|
||||
BASENAME=$(basename "${CURRENT}")
|
||||
|
||||
docker exec -u root -ti ${BASENAME}_ERPLibre_1 /bin/bash -c "\
|
||||
cd /ERPLibre; \
|
||||
./docker/repo_manifest_gen_org_prefix_path.py /ERPLibre/addons /etc/odoo/odoo.conf /etc/odoo/odoo.conf; \
|
||||
"
|
||||
9
script/docker/docker_make_test.sh
Executable file
9
script/docker/docker_make_test.sh
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT=$(pwd)
|
||||
BASENAME=$(basename "${CURRENT}")
|
||||
|
||||
docker exec -u root -ti ${BASENAME}_ERPLibre_1 /bin/bash -c "\
|
||||
cd /ERPLibre; \
|
||||
time make test; \
|
||||
"
|
||||
9
script/docker/docker_repo_show_status.sh
Executable file
9
script/docker/docker_repo_show_status.sh
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT=$(pwd)
|
||||
BASENAME=$(basename "${CURRENT}")
|
||||
|
||||
docker exec -u root -ti ${BASENAME}_ERPLibre_1 /bin/bash -c "\
|
||||
cd /ERPLibre; \
|
||||
./.venv/repo forall -pc 'git status -s'; \
|
||||
"
|
||||
Loading…
Reference in a new issue