From cdbda291c5d06d71b97eae11f5071a7eff598eea Mon Sep 17 00:00:00 2001 From: holger krekel Date: Mon, 11 Dec 2023 14:05:07 +0100 Subject: [PATCH] fix cmdeploy test command --- .github/workflows/ci.yaml | 9 +++++--- deploy-chatmail/pyproject.toml | 4 ++++ .../src/deploy_chatmail/cmdeploy.py | 23 ++++++++++--------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 67984fb..03208ed 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,15 +24,18 @@ jobs: - name: initenv run: scripts/initenv.sh + - name: append venv/bin to PATH + run: echo venv/bin >>$GITHUB_PATH + - name: run formatting checks - run: venv/bin/cmdeploy fmt -v + run: cmdeploy fmt -v - name: run deploy-chatmail offline tests working-directory: deploy-chatmail - run: venv/bin/pytest tests + run: pytest tests - name: initialize with chatmail domain - run: venv/bin/cmdeploy init chat.example.org + run: cmdeploy init chat.example.org # all other cmdeploy commands require a staging server # see https://github.com/deltachat/chatmail/issues/100 diff --git a/deploy-chatmail/pyproject.toml b/deploy-chatmail/pyproject.toml index c2e429b..b6eadb4 100644 --- a/deploy-chatmail/pyproject.toml +++ b/deploy-chatmail/pyproject.toml @@ -15,6 +15,10 @@ dependencies = [ "termcolor", "build", "tox", + "ruff", + "black", + "pytest", + "pytest-xdist", ] [project.scripts] diff --git a/deploy-chatmail/src/deploy_chatmail/cmdeploy.py b/deploy-chatmail/src/deploy_chatmail/cmdeploy.py index 25f11ab..7756b7f 100644 --- a/deploy-chatmail/src/deploy_chatmail/cmdeploy.py +++ b/deploy-chatmail/src/deploy_chatmail/cmdeploy.py @@ -111,26 +111,20 @@ def status_cmd(args, out): def test_cmd(args, out): - """Run local and online tests. + """Run local and online tests for chatmail deployment. - This will also pip-install 'deltachat' if it's not available. + This will automatically pip-install 'deltachat' if it's not available. """ - tox = shutil.which("tox") - proc1 = subprocess.run([tox, "-c", "chatmaild"]) - proc2 = subprocess.run([tox, "-c", "deploy-chatmail"]) - x = importlib.util.find_spec("deltachat") if x is None: out.check_call(f"{sys.executable} -m pip install deltachat") pytest_path = shutil.which("pytest") - proc3 = subprocess.run( - [pytest_path, "tests/", "-rs", "-x", "-vrx", "--durations=5"] + ret = out.run_ret( + [pytest_path, "tests/", "-n4", "-rs", "-x", "-vrx", "--durations=5"] ) - if any(x.returncode != 0 for x in (proc1, proc2, proc3)): - return 1 - return 0 + return ret def fmt_cmd_options(parser): @@ -219,6 +213,13 @@ class Out: self(f"[$ {arg}]", file=sys.stderr) return subprocess.check_call(arg, shell=True, env=env) + def run_ret(self, args, env=None, quiet=False): + if not quiet: + cmdstring = " ".join(args) + self(f"[$ {cmdstring}]", file=sys.stderr) + proc = subprocess.run(args, env=env) + return proc.returncode + def add_config_option(parser): parser.add_argument(