2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-11-09 23:00:56 +00:00

Setup and remove .env on tests

This commit is contained in:
Lev Vereshchagin 2021-12-13 20:03:40 +03:00
parent 163942bd1a
commit 3e7adbf361

View File

@ -1,4 +1,5 @@
import os
import shutil
import ssl
import subprocess
from enum import Enum
@ -81,7 +82,7 @@ def docker_compose(*cmd: str):
"-p",
"test",
"--env-file",
"example.env",
"tests/.env",
"-f",
"compose.yml",
]
@ -90,6 +91,19 @@ def docker_compose(*cmd: str):
return run(*args, *cmd)
@log("Setup .env")
def setup_env():
shutil.copy("example.env", "tests/.env")
if CI:
with open("tests/.env", "a") as f:
f.write(
f"""
FRAPPE_VERSION={os.getenv("FRAPPE_VERSION")}
ERPNEXT_VERSION={os.getenv("ERPNEXT_VERSION")}
"""
)
@log("Create containers")
def create_containers():
docker_compose("up", "-d")
@ -286,6 +300,11 @@ def create_postgres_site():
docker_compose("restart", "backend")
@log("Delete .env")
def delete_env():
os.remove("tests/.env")
@log("Show docker compose logs")
def show_docker_compose_logs():
docker_compose("logs")
@ -295,6 +314,7 @@ def main() -> int:
try:
patch_print()
setup_env()
create_containers()
ping_links_in_backends()
create_site()
@ -319,6 +339,7 @@ def main() -> int:
ping_links_in_backends()
finally:
delete_env()
show_docker_compose_logs()
stop_containers()