Merge branch 'develop'

- pip security update gitpython and future
- add nginx template
- add code_count.sh for statistic code
- addons script to migrate database prod to dev
- addons script to update all module
- update OSX installation
- test color in red the output file name when got error
This commit is contained in:
Mathieu Benoit 2023-02-14 16:50:21 -05:00
commit 31aa1c3fe3
11 changed files with 135 additions and 17 deletions

View file

@ -54,5 +54,5 @@ To change repository like addons, see [GIT_REPO.md](doc/GIT_REPO.md)
# Test
Execute ERPLibre test with his code generator.
```bash
time make test
time make test_full_fast
```

View file

@ -109,3 +109,18 @@ git branch -av
git reset --hard REF_OF_REMOTES/m
> git reset --hard remotes/origin/rel/8953/zd552kl/7.1.1-11.40.208
```
## OSX installation
### Docker installation
This guide works in the past, but it's now broken
```bash
echo "\n--- Installing docker --"
brew install minikube docker docker-compose docker-machine
brew cask install virtualbox
docker-machine create --driver virtualbox default
docker-machine env default
eval "$(docker-machine env default)"
```

12
poetry.lock generated
View file

@ -1234,13 +1234,13 @@ python-dateutil = ">=2.7"
[[package]]
name = "future"
version = "0.18.2"
version = "0.18.3"
description = "Clean single-source support for Python 3 and 2"
category = "main"
optional = false
python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
files = [
{file = "future-0.18.2.tar.gz", hash = "sha256:b1bead90b70cf6ec3f0710ae53a525360fa360d306a86583adc6bf83a4db537d"},
{file = "future-0.18.3.tar.gz", hash = "sha256:34a17436ed1e96697a86f9de3d15a3b0be01d8bc8de9c1dffd59fb8234ed5307"},
]
[[package]]
@ -1336,14 +1336,14 @@ smmap = ">=3.0.1,<6"
[[package]]
name = "gitpython"
version = "3.1.29"
version = "3.1.30"
description = "GitPython is a python library used to interact with Git repositories"
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "GitPython-3.1.29-py3-none-any.whl", hash = "sha256:41eea0deec2deea139b459ac03656f0dd28fc4a3387240ec1d3c259a2c47850f"},
{file = "GitPython-3.1.29.tar.gz", hash = "sha256:cc36bfc4a3f913e66805a28e84703e419d9c264c1077e537b54f0e1af85dbefd"},
{file = "GitPython-3.1.30-py3-none-any.whl", hash = "sha256:cd455b0000615c60e286208ba540271af9fe531fa6a87cc590a7298785ab2882"},
{file = "GitPython-3.1.30.tar.gz", hash = "sha256:769c2d83e13f5d938b7688479da374c4e3d49f71549aaf462b646db9602ea6f8"},
]
[package.dependencies]
@ -5876,4 +5876,4 @@ files = [
[metadata]
lock-version = "2.0"
python-versions = "^3.7.16"
content-hash = "dd54f6a3d606782a2768478cdfde0fd5f90b2e625e13b8d3ac946b25637e4f0c"
content-hash = "3ea90fffaf8140b6d905c474af3228499514491d98f24191d521bab1ea6a1862"

View file

@ -57,9 +57,10 @@ feedparser = "6.0.10"
flake8 = "<6.0.0"
formio-data = "^0.4.10"
freezegun = "1.2.2"
future = "0.18.3"
geojson = "<3.0.0"
gevent = "1.5.0"
gitpython = "3.1.29"
gitpython = "3.1.30"
giturlparse = "^0.10.0"
greenlet = "0.4.14"
html2text = "2016.9.19"

View file

@ -1,7 +1,7 @@
# For script
giturlparse
agithub
GitPython==3.1.29
GitPython==3.1.30
retrying
xmltodict
openupgradelib
@ -107,3 +107,4 @@ pyjwt==2.5.0
pygments==2.7.4
setuptools==65.5.1
Werkzeug==0.16.1
future==0.18.3

View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
echo "Update all on BD '$1'"
./run.sh --no-http --stop-after-init -d "$1" -u all
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "Error run.sh into update_addons_all.sh"
exit 1
fi

View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
# This script will remove mail configuration, remove backup configuration, and force admin user to test/test
echo "Update prod to dev on BD '$1'"
./script/addons/install_addons.sh "$1" user_test,disable_mail_server,disable_auto_backup
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "Error install_addons.sh into update_prod_to_dev.sh"
exit 1
fi

View file

@ -28,12 +28,6 @@ echo "\n--- Installing Python 3 + pip3 --"
brew install git python3 wget pyenv
brew link git
brew link wget
echo "\n--- Installing docker --"
brew install minikube docker docker-compose docker-machine
brew cask install virtualbox
docker-machine create --driver virtualbox default
docker-machine env default
eval "$(docker-machine env default)"
echo "\n---- Installing nodeJS NPM and rtlcss for LTR support ----"
brew install nodejs npm openssl
sudo npm install -g rtlcss

View file

@ -0,0 +1,71 @@
# TODO replace test1 by your hostname and fix server_name and run certbot
upstream erplibretest1 {
server 127.0.0.1:10000;
}
upstream erplibretest1chat {
server 127.0.0.1:10002;
}
server {
listen 80;
server_name test1.ca;
# Add Headers for erplibre proxy mode
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
# erplibre request log files
access_log /var/log/nginx/test1-access.log;
error_log /var/log/nginx/test1-error.log;
# Increase proxy buffer size
proxy_buffers 16 64k;
proxy_buffer_size 128k;
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
# Force timeouts if the backend dies
proxy_next_upstream error timeout invalid_header http_500 http_502
http_503;
types {
text/less less;
text/scss scss;
}
# Enable data compression
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript application/pdf image/jpeg image/png;
gzip_vary on;
client_header_buffer_size 4k;
large_client_header_buffers 4 64k;
client_max_body_size 1024M;
location / {
proxy_pass http://erplibretest1;
# by default, do not forward anything
proxy_redirect off;
}
location /longpolling {
proxy_pass http://erplibretest1chat;
}
# cache some static data in memory for 60mins.
location ~ /[a-zA-Z0-9_-]*/static/ {
proxy_cache_valid 200 302 60m;
proxy_cache_valid 404 1m;
proxy_buffering on;
expires 864000;
proxy_pass http://erplibretest1;
}
}

4
script/statistic/code_count.sh Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
# all argument is directory/file separate by space
./.venv/bin/pygount --duplicates --folders-to-skip="[...],*/libs/*,*/lib/*,lib" --names-to-skip="[...],*.min.*" --suffix=py,xml,html,js,css,scss --format=summary "$@"

View file

@ -117,6 +117,7 @@ def extract_result(result, test_name, lst_error, lst_warning):
def check_result(task_list, tpl_result):
status = True
lst_error = []
lst_warning = []
@ -125,6 +126,9 @@ def check_result(task_list, tpl_result):
result, task_list[i].cr_code.co_name, lst_error, lst_warning
)
if lst_error:
status = False
if lst_warning:
print(f"{Fore.YELLOW}{len(lst_warning)} WARNING{Fore.RESET}")
i = 0
@ -148,6 +152,7 @@ def check_result(task_list, tpl_result):
str_result = f"{Fore.GREEN}SUCCESS 🍰"
print(f"{Fore.BLUE}Summary TEST {str_result}{Fore.RESET}")
return status
def print_log(lst_task, tpl_result):
@ -165,7 +170,6 @@ def print_log(lst_task, tpl_result):
if result[0]:
f.write(result[0])
f.write("\n")
print(f"Log file {LOG_FILE}")
async def run_command_get_output(*args, cwd=None):
@ -1290,7 +1294,13 @@ def run_all_test(config) -> None:
finally:
loop.close()
print_log(task_list, tpl_result)
check_result(task_list, tpl_result)
status = check_result(task_list, tpl_result)
if status:
log_file_print = LOG_FILE
else:
log_file_print = f"{Fore.RED}{LOG_FILE}{Fore.RESET}"
print(f"Log file {log_file_print}")
def main():