mirror of
https://github.com/frappe/bench.git
synced 2025-01-06 23:44:03 +00:00
Merge remote-tracking branch 'upstream/develop' into staging
* upstream/develop: feat: add more flexibility to procfile render fix: apps init; apps might be an empty folder still chore(ci): drop py3.8, add 11, 12, 13 refactor: change some exceptions to simple echo + exits fix: use `with` to read pyproject.toml Avoid continue loop Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
commit
796b813bbd
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ['3.8', '3.9', '3.10' ]
|
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
|
||||||
|
|
||||||
name: Base (${{ matrix.python-version }})
|
name: Base (${{ matrix.python-version }})
|
||||||
|
|
||||||
|
13
bench/app.py
13
bench/app.py
@ -23,7 +23,6 @@ import semantic_version as sv
|
|||||||
|
|
||||||
# imports - module imports
|
# imports - module imports
|
||||||
import bench
|
import bench
|
||||||
from bench.exceptions import NotInBenchDirectoryError
|
|
||||||
from bench.utils import (
|
from bench.utils import (
|
||||||
UNSET_ARG,
|
UNSET_ARG,
|
||||||
fetch_details_from_tag,
|
fetch_details_from_tag,
|
||||||
@ -706,10 +705,12 @@ def get_app(
|
|||||||
|
|
||||||
if not is_bench_directory(bench_path):
|
if not is_bench_directory(bench_path):
|
||||||
if not init_bench:
|
if not init_bench:
|
||||||
raise NotInBenchDirectoryError(
|
click.secho(
|
||||||
f"{os.path.realpath(bench_path)} is not a valid bench directory. "
|
f"{os.path.realpath(bench_path)} is not a valid bench directory. "
|
||||||
"Run with --init-bench if you'd like to create a Bench too."
|
"Run with --init-bench if you'd like to create a Bench too.",
|
||||||
|
fg="red",
|
||||||
)
|
)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
from bench.utils.system import init
|
from bench.utils.system import init
|
||||||
|
|
||||||
@ -851,9 +852,11 @@ def install_resolved_deps(
|
|||||||
|
|
||||||
def new_app(app, no_git=None, bench_path="."):
|
def new_app(app, no_git=None, bench_path="."):
|
||||||
if bench.FRAPPE_VERSION in (0, None):
|
if bench.FRAPPE_VERSION in (0, None):
|
||||||
raise NotInBenchDirectoryError(
|
click.secho(
|
||||||
f"{os.path.realpath(bench_path)} is not a valid bench directory."
|
f"{os.path.realpath(bench_path)} is not a valid bench directory.",
|
||||||
|
fg="red",
|
||||||
)
|
)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
# For backwards compatibility
|
# For backwards compatibility
|
||||||
app = app.lower().replace(" ", "_").replace("-", "_")
|
app = app.lower().replace(" ", "_").replace("-", "_")
|
||||||
|
@ -283,7 +283,7 @@ class BenchApps(MutableSequence):
|
|||||||
]
|
]
|
||||||
self.apps.remove("frappe")
|
self.apps.remove("frappe")
|
||||||
self.apps.insert(0, "frappe")
|
self.apps.insert(0, "frappe")
|
||||||
except FileNotFoundError:
|
except (FileNotFoundError, ValueError):
|
||||||
self.apps = []
|
self.apps = []
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
|
@ -4,12 +4,14 @@ import platform
|
|||||||
import click
|
import click
|
||||||
|
|
||||||
import bench
|
import bench
|
||||||
from bench.app import use_rq
|
|
||||||
from bench.bench import Bench
|
from bench.bench import Bench
|
||||||
from bench.utils import which
|
from bench.utils import which
|
||||||
|
|
||||||
|
|
||||||
def setup_procfile(bench_path, yes=False, skip_redis=False):
|
def setup_procfile(bench_path, yes=False, skip_redis=False, skip_web=False, skip_watch=None, skip_socketio=False, skip_schedule=False, with_coverage=False):
|
||||||
|
if skip_watch is None:
|
||||||
|
# backwards compatibilty; may be eventually removed
|
||||||
|
skip_watch = os.environ.get("CI")
|
||||||
config = Bench(bench_path).conf
|
config = Bench(bench_path).conf
|
||||||
procfile_path = os.path.join(bench_path, "Procfile")
|
procfile_path = os.path.join(bench_path, "Procfile")
|
||||||
|
|
||||||
@ -25,10 +27,13 @@ def setup_procfile(bench_path, yes=False, skip_redis=False):
|
|||||||
.get_template("Procfile")
|
.get_template("Procfile")
|
||||||
.render(
|
.render(
|
||||||
node=which("node") or which("nodejs"),
|
node=which("node") or which("nodejs"),
|
||||||
use_rq=use_rq(bench_path),
|
|
||||||
webserver_port=config.get("webserver_port"),
|
webserver_port=config.get("webserver_port"),
|
||||||
CI=os.environ.get("CI"),
|
|
||||||
skip_redis=skip_redis,
|
skip_redis=skip_redis,
|
||||||
|
skip_web=skip_web,
|
||||||
|
skip_watch=skip_watch,
|
||||||
|
skip_socketio=skip_socketio,
|
||||||
|
skip_schedule=skip_schedule,
|
||||||
|
with_coverage=with_coverage,
|
||||||
workers=config.get("workers", {}),
|
workers=config.get("workers", {}),
|
||||||
is_mac=is_mac,
|
is_mac=is_mac,
|
||||||
)
|
)
|
||||||
|
@ -2,15 +2,18 @@
|
|||||||
redis_cache: redis-server config/redis_cache.conf
|
redis_cache: redis-server config/redis_cache.conf
|
||||||
redis_queue: redis-server config/redis_queue.conf
|
redis_queue: redis-server config/redis_queue.conf
|
||||||
{% endif %}
|
{% endif %}
|
||||||
web: bench serve {% if webserver_port -%} --port {{ webserver_port }} {%- endif %}
|
{% if not skip_web %}
|
||||||
|
web: bench serve {% if with_coverage -%} --with-coverage {%- endif %} {% if webserver_port -%} --port {{ webserver_port }} {%- endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% if not skip_socketio %}
|
||||||
socketio: {{ node }} apps/frappe/socketio.js
|
socketio: {{ node }} apps/frappe/socketio.js
|
||||||
|
{% endif %}
|
||||||
{% if not CI %}
|
{% if not skip_watch %}
|
||||||
watch: bench watch
|
watch: bench watch
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if not skip_schedule %}
|
||||||
schedule: bench schedule
|
schedule: bench schedule
|
||||||
|
{% endif %}
|
||||||
worker: {{ 'OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES NO_PROXY=*' if is_mac else '' }} bench worker 1>> logs/worker.log 2>> logs/worker.error.log
|
worker: {{ 'OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES NO_PROXY=*' if is_mac else '' }} bench worker 1>> logs/worker.log 2>> logs/worker.error.log
|
||||||
{% for worker_name, worker_details in workers.items() %}
|
{% for worker_name, worker_details in workers.items() %}
|
||||||
worker_{{ worker_name }}: {{ 'OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES NO_PROXY=*' if is_mac else '' }} bench worker --queue {{ worker_name }} 1>> logs/worker.log 2>> logs/worker.error.log
|
worker_{{ worker_name }}: {{ 'OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES NO_PROXY=*' if is_mac else '' }} bench worker --queue {{ worker_name }} 1>> logs/worker.log 2>> logs/worker.error.log
|
||||||
|
@ -33,10 +33,5 @@ class CannotUpdateReleaseBench(ValidationError):
|
|||||||
class FeatureDoesNotExistError(CommandFailedError):
|
class FeatureDoesNotExistError(CommandFailedError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class NotInBenchDirectoryError(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class VersionNotFound(Exception):
|
class VersionNotFound(Exception):
|
||||||
pass
|
pass
|
||||||
|
@ -43,6 +43,9 @@ def is_bench_directory(directory=os.path.curdir):
|
|||||||
for folder in paths_in_bench:
|
for folder in paths_in_bench:
|
||||||
path = os.path.abspath(os.path.join(directory, folder))
|
path = os.path.abspath(os.path.join(directory, folder))
|
||||||
is_bench = is_bench and os.path.exists(path)
|
is_bench = is_bench and os.path.exists(path)
|
||||||
|
# Once is_bench becomes false, it will always be false, even if other path exists.
|
||||||
|
if not is_bench:
|
||||||
|
break
|
||||||
|
|
||||||
return is_bench
|
return is_bench
|
||||||
|
|
||||||
|
@ -114,10 +114,11 @@ def _generate_dev_deps_pattern(pyproject_path):
|
|||||||
from tomllib import loads
|
from tomllib import loads
|
||||||
|
|
||||||
requirements_pattern = ""
|
requirements_pattern = ""
|
||||||
pyroject_config = loads(open(pyproject_path).read())
|
with open(pyproject_path) as f:
|
||||||
|
pyproject_config = loads(f.read())
|
||||||
|
|
||||||
with contextlib.suppress(KeyError):
|
with contextlib.suppress(KeyError):
|
||||||
for pkg, version in pyroject_config["tool"]["bench"]["dev-dependencies"].items():
|
for pkg, version in pyproject_config["tool"]["bench"]["dev-dependencies"].items():
|
||||||
op = "==" if "=" not in version else ""
|
op = "==" if "=" not in version else ""
|
||||||
requirements_pattern += f"{pkg}{op}{version} "
|
requirements_pattern += f"{pkg}{op}{version} "
|
||||||
return requirements_pattern
|
return requirements_pattern
|
||||||
|
Loading…
Reference in New Issue
Block a user