aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-06-18 15:21:12 +0200
committerEgor Tensin <egor@tensin.name>2026-06-18 15:21:12 +0200
commit0eab2fb9fd2006356c12830145fac067f64f7f8a (patch)
tree0af5847aee651c27bfa9f9aa924f5cf1600ed790
parentMerge pull request #9 from egor-tensin/dependabot/docker/alpine-3.24 (diff)
downloadcimple-0eab2fb9fd2006356c12830145fac067f64f7f8a.tar.gz
cimple-0eab2fb9fd2006356c12830145fac067f64f7f8a.zip
workflows/ci: add Python linting
-rw-r--r--.github/workflows/ci.yml10
-rwxr-xr-xsrc/generate-sql-header.py11
-rw-r--r--test/src/conftest.py3
-rw-r--r--test/src/lib/test_repo.py16
-rw-r--r--test/src/lib/tests.py6
-rw-r--r--test/src/test_repo.py19
6 files changed, 46 insertions, 19 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7dfa818..bbd66de 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -24,6 +24,16 @@ jobs:
uses: egor-tensin/clang-format@v1
with:
version: 22
+ - name: Set up Python
+ uses: actions/setup-python@v6
+ with:
+ python-version: '3.x'
+ - name: Run black
+ uses: psf/black@stable
+ with:
+ # > Please note that the --check flag is required so that the
+ # > workflow fails if Black finds files that need to be formatted.
+ options: --check --verbose --skip-string-normalization
build:
strategy:
diff --git a/src/generate-sql-header.py b/src/generate-sql-header.py
index eb5e9fe..591baf2 100755
--- a/src/generate-sql-header.py
+++ b/src/generate-sql-header.py
@@ -38,7 +38,10 @@ class Generator:
self.write(f'#endif')
def enum_sql_files(self):
- return [os.path.join(self.dir, path) for path in sorted(glob('*.sql', root_dir=self.dir))]
+ return [
+ os.path.join(self.dir, path)
+ for path in sorted(glob('*.sql', root_dir=self.dir))
+ ]
@property
def var_name_prefix(self):
@@ -85,10 +88,8 @@ def parse_args(argv=None):
if argv is None:
argv = sys.argv[1:]
parser = argparse.ArgumentParser()
- parser.add_argument('-o', '--output', metavar='PATH',
- help='set output file path')
- parser.add_argument('dir', metavar='INPUT_DIR',
- help='input directory')
+ parser.add_argument('-o', '--output', metavar='PATH', help='set output file path')
+ parser.add_argument('dir', metavar='INPUT_DIR', help='input directory')
return parser.parse_args()
diff --git a/test/src/conftest.py b/test/src/conftest.py
index 6c34f4d..029eeb7 100644
--- a/test/src/conftest.py
+++ b/test/src/conftest.py
@@ -157,8 +157,7 @@ def server(server_cmd):
@fixture
def workers(worker_cmd):
- with worker_cmd.run_async() as worker1, \
- worker_cmd.run_async() as worker2:
+ with worker_cmd.run_async() as worker1, worker_cmd.run_async() as worker2:
yield [worker1, worker2]
assert worker1.returncode == 0
assert worker2.returncode == 0
diff --git a/test/src/lib/test_repo.py b/test/src/lib/test_repo.py
index 0356ad8..f295e91 100644
--- a/test/src/lib/test_repo.py
+++ b/test/src/lib/test_repo.py
@@ -76,7 +76,13 @@ class TestRepo(Repo):
return CI_SCRIPT.format(runs_dir=runs_dir)
def _count_run_files(self):
- return len([name for name in os.listdir(self.runs_dir) if os.path.isfile(os.path.join(self.runs_dir, name))])
+ return len(
+ [
+ name
+ for name in os.listdir(self.runs_dir)
+ if os.path.isfile(os.path.join(self.runs_dir, name))
+ ]
+ )
def run_files_are_present(self, expected):
assert expected == self._count_run_files()
@@ -98,7 +104,8 @@ class TestRepoOutput(TestRepo, abc.ABC):
def format_ci_script(self):
script = super().format_ci_script()
added = r'{output_script} | tee -a "$run_output_path"'.format(
- output_script=shlex.quote(self.output_script_path))
+ output_script=shlex.quote(self.output_script_path)
+ )
return f'{script}\n{added}\n'
def write_output_script(self):
@@ -226,7 +233,10 @@ class TestRepoSegfault(TestRepo):
def run_output_matches(self, output):
output = output.decode()
- return output.startswith("Started the test program.\n") and "You shouldn't see this." not in output
+ return (
+ output.startswith("Started the test program.\n")
+ and "You shouldn't see this." not in output
+ )
def run_files_are_present(self, *args):
return True
diff --git a/test/src/lib/tests.py b/test/src/lib/tests.py
index 7ccedef..b20ecc5 100644
--- a/test/src/lib/tests.py
+++ b/test/src/lib/tests.py
@@ -14,8 +14,10 @@ def my_parametrize(names, values, ids=None, **kwargs):
if len(_names) == 1:
ids = [f'{names}={v}' for v in values]
else:
- _values = [combination.values if hasattr(combination, 'values') else combination
- for combination in values]
+ _values = [
+ combination.values if hasattr(combination, 'values') else combination
+ for combination in values
+ ]
ids = [
'-'.join(f'{k}={v}' for k, v in zip(_names, combination))
for combination in _values
diff --git a/test/src/test_repo.py b/test/src/test_repo.py
index eb717cb..ef45103 100644
--- a/test/src/test_repo.py
+++ b/test/src/test_repo.py
@@ -55,7 +55,10 @@ def _test_repo_internal(env, repo, numof_processes, runs_per_process):
with child_logging_thread() as log_queue:
ctx = mp.get_context('spawn')
args = (log_queue, env.client, runs_per_process, repo)
- processes = [ctx.Process(target=client_runner_process, args=args) for i in range(numof_processes)]
+ processes = [
+ ctx.Process(target=client_runner_process, args=args)
+ for i in range(numof_processes)
+ ]
for proc in processes:
proc.start()
@@ -94,12 +97,14 @@ def test_repo(env, test_repo, numof_clients, runs_per_client):
@pytest.mark.stress
-@my_parametrize('numof_clients,runs_per_client',
- [
- (10, 50),
- (1, 2000),
- (4, 500),
- ])
+@my_parametrize(
+ 'numof_clients,runs_per_client',
+ [
+ (10, 50),
+ (1, 2000),
+ (4, 500),
+ ],
+)
def test_repo_stress(env, stress_test_repo, numof_clients, runs_per_client):
_test_repo_internal(env, stress_test_repo, numof_clients, runs_per_client)