mirror of
https://github.com/chatmail/relay.git
synced 2026-05-11 16:34:39 +00:00
remove tox run from deploy-chatmail and use 'cmdeploy fmt' and 'pytest' directly
This commit is contained in:
21
.github/workflows/ci.yaml
vendored
21
.github/workflows/ci.yaml
vendored
@@ -6,7 +6,7 @@ on:
|
||||
|
||||
jobs:
|
||||
tox:
|
||||
name: chatmail tests
|
||||
name: isolated chatmaild tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -15,15 +15,8 @@ jobs:
|
||||
working-directory: chatmaild
|
||||
run: pipx run tox
|
||||
|
||||
- name: run deploy-chatmail offline tests
|
||||
working-directory: deploy-chatmail
|
||||
run: pipx run tox
|
||||
- name: run deploy-chatmail offline tests
|
||||
working-directory: deploy-chatmail
|
||||
run: pipx run tox
|
||||
|
||||
scripts:
|
||||
name: cmdeploy invocations
|
||||
name: deploy-chatmail tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -31,5 +24,15 @@ jobs:
|
||||
- name: initenv
|
||||
run: scripts/initenv.sh
|
||||
|
||||
- name: run formatting checks
|
||||
run: venv/bin/cmdeploy fmt -v
|
||||
|
||||
- name: run deploy-chatmail offline tests
|
||||
working-directory: deploy-chatmail
|
||||
run: venv/bin/pytest tests
|
||||
|
||||
- name: initialize with chatmail domain
|
||||
run: venv/bin/cmdeploy init chat.example.org
|
||||
|
||||
# all other cmdeploy commands require a staging server
|
||||
# see https://github.com/deltachat/chatmail/issues/100
|
||||
|
||||
@@ -25,20 +25,3 @@ cmdeploy = "deploy_chatmail.cmdeploy:main"
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
addopts = "-v -ra --strict-markers"
|
||||
|
||||
[tool.tox]
|
||||
legacy_tox_ini = """
|
||||
[tox]
|
||||
isolated_build = true
|
||||
envlist = lint
|
||||
|
||||
[testenv:lint]
|
||||
skipdist = True
|
||||
skip_install = True
|
||||
deps =
|
||||
ruff
|
||||
black
|
||||
commands =
|
||||
black --quiet --check --diff src/
|
||||
ruff src/
|
||||
"""
|
||||
|
||||
@@ -6,6 +6,7 @@ import argparse
|
||||
import datetime
|
||||
import shutil
|
||||
import subprocess
|
||||
import importlib.resources
|
||||
import importlib.util
|
||||
import os
|
||||
import sys
|
||||
@@ -132,6 +133,51 @@ def test_cmd(args, out):
|
||||
return 0
|
||||
|
||||
|
||||
def fmt_cmd_options(parser):
|
||||
parser.add_argument(
|
||||
"--verbose",
|
||||
"-v",
|
||||
dest="verbose",
|
||||
action="store_true",
|
||||
help="provide information on invocations",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--check",
|
||||
"-c",
|
||||
action="store_true",
|
||||
help="only check but don't fix problems",
|
||||
)
|
||||
|
||||
|
||||
def fmt_cmd(args, out):
|
||||
"""Run formattting fixes (fuff and black) on all chatmail source code."""
|
||||
|
||||
chatmaild = importlib.resources.files("chatmaild")
|
||||
deploy_chatmail = importlib.resources.files("deploy_chatmail")
|
||||
tests = deploy_chatmail.joinpath("../../../tests")
|
||||
sources = list(str(x) for x in [chatmaild, deploy_chatmail, tests])
|
||||
|
||||
black_args = [shutil.which("black")]
|
||||
ruff_args = [shutil.which("ruff")]
|
||||
|
||||
if args.check:
|
||||
black_args.append("--check")
|
||||
else:
|
||||
ruff_args.append("--fix")
|
||||
|
||||
if not args.verbose:
|
||||
black_args.append("-q")
|
||||
ruff_args.append("-q")
|
||||
|
||||
black_args.extend(sources)
|
||||
ruff_args.extend(sources)
|
||||
|
||||
out.check_call(" ".join(black_args), quiet=not args.verbose)
|
||||
out.check_call(" ".join(ruff_args), quiet=not args.verbose)
|
||||
return 0
|
||||
|
||||
|
||||
def bench_cmd(args, out):
|
||||
"""Run benchmarks against an online chatmail instance."""
|
||||
pytest_path = shutil.which("pytest")
|
||||
@@ -168,8 +214,9 @@ class Out:
|
||||
self(f"[$ {arg}]", file=sys.stderr)
|
||||
return subprocess.check_output(arg, shell=True).decode()
|
||||
|
||||
def check_call(self, arg, env=None):
|
||||
self(f"[$ {arg}]", file=sys.stderr)
|
||||
def check_call(self, arg, env=None, quiet=False):
|
||||
if not quiet:
|
||||
self(f"[$ {arg}]", file=sys.stderr)
|
||||
return subprocess.check_call(arg, shell=True, env=env)
|
||||
|
||||
|
||||
@@ -228,7 +275,7 @@ def main(args=None):
|
||||
return parser.parse_args(["-h"])
|
||||
out = Out()
|
||||
kwargs = {}
|
||||
if args.func.__name__ != "init_cmd":
|
||||
if args.func.__name__ not in ("init_cmd", "fmt_cmd"):
|
||||
if not args.inipath.exists():
|
||||
out.red(f"expecting {args.inipath} to exist, run init first?")
|
||||
raise SystemExit(1)
|
||||
|
||||
@@ -6,8 +6,6 @@ import subprocess
|
||||
import imaplib
|
||||
import smtplib
|
||||
import itertools
|
||||
from email.parser import BytesParser
|
||||
from email import policy
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
|
||||
|
||||
Reference in New Issue
Block a user