mirror of
https://github.com/frappe/bench.git
synced 2025-01-06 23:44:03 +00:00
feat: add GHA tests
chore: added reading from env when rerunning script - Makes current site as default
This commit is contained in:
parent
9313777276
commit
e76c7dccf5
27
.github/workflows/easy-install.yml
vendored
Normal file
27
.github/workflows/easy-install.yml
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
name: 'Easy Install Test'
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [ develop ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
easy-install-setup:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
|
||||
name: Easy Install Test
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: |
|
||||
python3 ${GITHUB_WORKSPACE}/easy-install.py -p -n actions_test --email test@frappe.io
|
||||
docker compose -p actions_test exec backend bench version --format json
|
||||
docker compose -p actions_test exec backend bench --site site1.local list-apps --format json
|
||||
result=$(curl -sk https://127.0.0.1/api/method/ping | jq -r ."message")
|
||||
if [[ "$result" == "pong" ]]; then echo "New instance works fine"; else exit 1; fi
|
||||
docker compose -p actions_test down
|
||||
docker volume prune -f
|
@ -59,9 +59,9 @@ def clone_frappe_docker_repo() -> None:
|
||||
logging.error("Download and unzip failed", exc_info=True)
|
||||
cprint("\nCloning frappe_docker Failed\n\n", "[ERROR]: ", e, level=1)
|
||||
|
||||
def get_latest_version(dir) -> Dict:
|
||||
def get_from_env(dir,file) -> Dict:
|
||||
env_vars ={}
|
||||
with open(os.path.join(dir,"example.env")) as f:
|
||||
with open(os.path.join(dir,file)) as f:
|
||||
for line in f:
|
||||
if line.startswith('#') or not line.strip():
|
||||
continue
|
||||
@ -69,9 +69,10 @@ def get_latest_version(dir) -> Dict:
|
||||
env_vars[key] = value
|
||||
return env_vars
|
||||
|
||||
|
||||
def write_to_env(wd: str, site: str, db_pass: str, admin_pass: str, email: str) -> None:
|
||||
site_name = site or ""
|
||||
example_env = get_latest_version(wd)
|
||||
example_env = get_from_env(wd,"example.env")
|
||||
with open(os.path.join(wd, ".env"), "w") as f:
|
||||
f.writelines(
|
||||
[
|
||||
@ -115,11 +116,13 @@ def setup_prod(project: str, sitename: str, email: str) -> None:
|
||||
"\nPlease refer to .example.env file in the frappe_docker folder to know which keys to set\n\n",
|
||||
level=3,
|
||||
)
|
||||
admin_pass = generate_pass()
|
||||
db_pass = generate_pass(9)
|
||||
admin_pass = ""
|
||||
db_pass = ""
|
||||
with open(compose_file_name, "w") as f:
|
||||
# Writing to compose file
|
||||
if not os.path.exists(os.path.join(docker_repo_path, ".env")):
|
||||
admin_pass = generate_pass()
|
||||
db_pass = generate_pass(9)
|
||||
write_to_env(docker_repo_path, sitename, db_pass, admin_pass, email)
|
||||
cprint(
|
||||
"\nA .env file is generated with basic configs. Please edit it to fit to your needs \n",
|
||||
@ -130,6 +133,10 @@ def setup_prod(project: str, sitename: str, email: str) -> None:
|
||||
) as en:
|
||||
en.writelines(f"ADMINISTRATOR_PASSWORD={admin_pass}\n")
|
||||
en.writelines(f"MARIADB_ROOT_PASSWORD={db_pass}\n")
|
||||
else:
|
||||
env = get_from_env(docker_repo_path,".env")
|
||||
admin_pass = env['SITE_ADMIN_PASS']
|
||||
db_pass = env['DB_PASSWORD']
|
||||
try:
|
||||
# TODO: Include flags for non-https and non-erpnext installation
|
||||
subprocess.run(
|
||||
@ -182,6 +189,7 @@ def setup_prod(project: str, sitename: str, email: str) -> None:
|
||||
except Exception as e:
|
||||
logging.error("Prod docker-compose failed", exc_info=True)
|
||||
cprint(" Docker Compose failed, please check the container logs\n", e)
|
||||
sys.exit(1)
|
||||
|
||||
cprint(f"\nCreating site: {sitename} \n", level=3)
|
||||
|
||||
@ -203,6 +211,7 @@ def setup_prod(project: str, sitename: str, email: str) -> None:
|
||||
admin_pass,
|
||||
"--install-app",
|
||||
"erpnext",
|
||||
"--set-default"
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
@ -210,6 +219,7 @@ def setup_prod(project: str, sitename: str, email: str) -> None:
|
||||
except Exception as e:
|
||||
logging.error("Bench site creation failed", exc_info=True)
|
||||
cprint("Bench Site creation failed\n", e)
|
||||
sys.exit(1)
|
||||
else:
|
||||
install_docker()
|
||||
clone_frappe_docker_repo()
|
||||
|
Loading…
Reference in New Issue
Block a user