update : setup test environment
This commit is contained in:
parent
b784b63539
commit
86c7788f7e
32
Jenkinsfile
vendored
32
Jenkinsfile
vendored
@ -1,21 +1,17 @@
|
||||
pipeline {
|
||||
agent {label 'Node-Dev-100163'}
|
||||
node('node'){
|
||||
currentBuild.result = "SUCCESS"
|
||||
try {
|
||||
stage('Checkout'){
|
||||
|
||||
stages {
|
||||
stage('Build') {
|
||||
steps {
|
||||
sh 'pwd'
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
steps {
|
||||
echo 'Testing...'
|
||||
}
|
||||
}
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
echo 'Deploying....'
|
||||
}
|
||||
}
|
||||
checkout scm
|
||||
}
|
||||
stage('Test'){
|
||||
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
|
||||
currentBuild.result = "FAILURE"
|
||||
throw err
|
||||
}
|
||||
}
|
7
Makefile
7
Makefile
@ -8,17 +8,20 @@ DOCKER_BUILD=$(DOCKERCMD) build
|
||||
DOCKER_PUSH=$(DOCKERCMD) push
|
||||
DOCKER_IMAGE=$(DOCKERCMD) image
|
||||
DEPLOY_PATH=${PWD}/deployment
|
||||
SETUP_PATH=${PWD}/setup
|
||||
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
||||
HASH := $(shell git rev-parse HEAD)
|
||||
CONFIG=odoo.conf
|
||||
install:
|
||||
sudo apt install python3-pip libldap2-dev libpq-dev libsasl2-dev && \
|
||||
pip install -r requirements.txt
|
||||
run_test:
|
||||
run_test: gen_test_config
|
||||
${PYTHON} odoo-bin -i all_modules --log-level=test --test-enable -d testdb --stop-after-init --config=${CONFIG}
|
||||
gen_test_config:
|
||||
${PWD}/setup/init_conf.sh
|
||||
gen_env:
|
||||
${PWD}/setup/init_env.sh
|
||||
build-image: update_env
|
||||
build-image: gen_env
|
||||
DOCKER_BUILDKIT=1 ${DOCKER_BUILD} . --progress plain --tag ${ODOO_IMAGE}
|
||||
push-image:
|
||||
$(DOCKERPUSH) ${ODOO_IMAGE}
|
||||
|
@ -28,5 +28,5 @@ services:
|
||||
- POSTGRES_DB=${PG_DB:-postgres}
|
||||
restart: always
|
||||
volumes:
|
||||
- ${DB_DATA:-./postgresql}:/var/lib/postgresql/data
|
||||
- ${PG_DATA:-./postgresql}:/var/lib/postgresql/data
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[options]
|
||||
db_host = localhost
|
||||
db_host =
|
||||
db_port = 5432
|
||||
db_user = changeme
|
||||
db_password = password
|
||||
db_user =
|
||||
db_password =
|
||||
|
||||
|
@ -89,3 +89,4 @@ XlsxWriter==3.1.9 ; python_version >= '3.12'
|
||||
xlwt==1.3.0
|
||||
zeep==4.1.0 ; python_version < '3.11' # (jammy)
|
||||
zeep==4.2.1 ; python_version >= '3.11'
|
||||
python-dotenv==1.0.1; python_version > '3.10'
|
24
setup/gen-config.py
Executable file
24
setup/gen-config.py
Executable file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
import configparser
|
||||
import shutil
|
||||
import os
|
||||
from dotenv import set_key
|
||||
from pathlib import Path
|
||||
|
||||
current = os.getcwd()
|
||||
shutil.copyfile('../odoo.conf.sample', '../odoo.conf')
|
||||
shutil.copyfile('../testing_env/env.template', '../testing_env/.env')
|
||||
env_file_path = Path("../testing_env/.env")
|
||||
config = configparser.ConfigParser()
|
||||
config.read('../odoo.conf')
|
||||
config['options']['db_host'] = 'localhost'
|
||||
config['options']['db_user'] = 'nextzen'
|
||||
config['options']['db_password'] = 'Smartyourlife123@*'
|
||||
config['options']['db_port'] = '5432'
|
||||
# Save some values to the file.
|
||||
set_key(dotenv_path=env_file_path, key_to_set="PG_USER", value_to_set="nextzen")
|
||||
set_key(dotenv_path=env_file_path, key_to_set="PG_PASS", value_to_set="Smartyourlife123@*")
|
||||
set_key(dotenv_path=env_file_path, key_to_set="PG_PORT", value_to_set="5432")
|
||||
# Write changes back to '../odoo.conf'
|
||||
with open('../odoo.conf', 'w') as configfile:
|
||||
config.write(configfile)
|
76
setup/init_conf.sh
Executable file
76
setup/init_conf.sh
Executable file
@ -0,0 +1,76 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
export PATH=/usr/sbin:$PATH
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
set -euo pipefail
|
||||
ODOO_IMAGE='hub.nextzenos.com/nexterp/odoo'
|
||||
DEPLOY_PATH=$(pwd)/deployment
|
||||
PG_DB=nexterp
|
||||
PG_USER=nexterp
|
||||
CURRENT_BRANCH=$(git symbolic-ref --short HEAD)
|
||||
ODOO_ADDONS=./addons
|
||||
ODOO_CONFIG=./etc
|
||||
# System
|
||||
DEPENDS_PACKAGE=('wget' 'curl' 'git' 'unzip' 'make' 'build-essential')
|
||||
DEPENDS_COMMAND=('wget' 'curl' 'git' 'unzip' 'make')
|
||||
((EUID)) && sudo_cmd="sudo" || sudo_cmd=""
|
||||
readonly MINIMUM_DOCER_VERSION="20"
|
||||
UNAME_U="$(uname -s)"
|
||||
readonly UNAME_U
|
||||
readonly COLOUR_RESET='\e[0m'
|
||||
readonly aCOLOUR=(
|
||||
'\e[38;5;154m' # green | Lines, bullets and separators
|
||||
'\e[1m' # Bold white | Main descriptions
|
||||
'\e[90m' # Grey | Credits
|
||||
'\e[91m' # Red | Update notifications Alert
|
||||
'\e[33m' # Yellow | Emphasis
|
||||
)
|
||||
trap 'onCtrlC' INT
|
||||
onCtrlC() {
|
||||
echo -e "${COLOUR_RESET}"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Show() {
|
||||
# OK
|
||||
if (($1 == 0)); then
|
||||
echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} OK $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2"
|
||||
# FAILED
|
||||
elif (($1 == 1)); then
|
||||
echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[3]}FAILED$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2"
|
||||
exit 1
|
||||
# INFO
|
||||
elif (($1 == 2)); then
|
||||
echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} INFO $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2"
|
||||
# NOTICE
|
||||
elif (($1 == 3)); then
|
||||
echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[4]}NOTICE$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2"
|
||||
fi
|
||||
}
|
||||
|
||||
Warn() {
|
||||
echo -e "${aCOLOUR[3]}$1$COLOUR_RESET"
|
||||
}
|
||||
|
||||
GreyStart() {
|
||||
echo -e "${aCOLOUR[2]}\c"
|
||||
}
|
||||
|
||||
ColorReset() {
|
||||
echo -e "$COLOUR_RESET\c"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Generate_Config(){
|
||||
python setup/gen-config.py
|
||||
Show 0 'Generate Config Complete'
|
||||
}
|
||||
|
||||
Run_Test_Server(){
|
||||
Show 0 'Test Server is online'
|
||||
}
|
||||
Generate_Config
|
||||
Run_Test_Server
|
@ -12,8 +12,8 @@ CURRENT_BRANCH=$(git symbolic-ref --short HEAD)
|
||||
ODOO_ADDONS=./addons
|
||||
ODOO_CONFIG=./etc
|
||||
# System
|
||||
DEPENDS_PACKAGE=('wget' 'curl' 'git' 'unzip')
|
||||
DEPENDS_COMMAND=('wget' 'curl' 'git' 'unzip')
|
||||
DEPENDS_PACKAGE=('wget' 'curl' 'git' 'unzip' 'make' 'build-essential' 'wkhtmltopdf')
|
||||
DEPENDS_COMMAND=('wget' 'curl' 'git' 'unzip' 'make' 'wkhtmltopdf')
|
||||
((EUID)) && sudo_cmd="sudo" || sudo_cmd=""
|
||||
readonly MINIMUM_DOCER_VERSION="20"
|
||||
UNAME_U="$(uname -s)"
|
||||
|
15
testing_env/docker-compose.yml
Normal file
15
testing_env/docker-compose.yml
Normal file
@ -0,0 +1,15 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
db-test:
|
||||
image: postgres:16
|
||||
user: root
|
||||
environment:
|
||||
- POSTGRES_USER=${PG_USER:-changeme}
|
||||
- POSTGRES_PASSWORD=${PG_PASS:-password}
|
||||
- POSTGRES_DB=${PG_DB:-postgres}
|
||||
restart: always
|
||||
ports:
|
||||
- ${PG_PORT:-5432}:5432
|
||||
volumes:
|
||||
- ${PG_DATA:-./postgresql}:/var/lib/postgresql/data
|
||||
|
5
testing_env/env.template
Normal file
5
testing_env/env.template
Normal file
@ -0,0 +1,5 @@
|
||||
#Database
|
||||
PG_DB=nexterp
|
||||
PG_USER=nexterp
|
||||
PG_PASS=4ewLWdJ0WQ8I77Slqg0Y8kAj
|
||||
PG_PORT=
|
Loading…
Reference in New Issue
Block a user