Marco Ricci
Add quality control scripts
Marco Ricci commited 7ad6f08 at 2025-02-09 20:47:17
#!/usr/bin/python3
# SPDX-FileCopyrightText: 2025 Marco Ricci <software@the13thletter.info>
#
# SPDX-License-Identifier: Zlib
# ruff: noqa: S404,S603,S607
"""Run various quality control checks automatically.
Distinguish between the master branch and other branches: run the full
test suite and build the documentation only on the master branch,
otherwise use only a reduced set of test environments and don't build
the documentation at all. In both cases, run the linter, the formatter,
and the type checker.
If we are currently in a Stacked Git patch queue, do not run any tests,
do not run the type checker and do not build the documentation. These
all slow down patch refreshing to a grinding halt, and will be checked
afterwards anyway when merging the patch queue back into the master
branch. Stick to formatting and linting only.
"""
import os
import subprocess
import sys
envs = ['3.9', '3.11', '3.13', 'pypy3.10']
opts = ['-py', ','.join(envs)]
current_branch = subprocess.run(
['git', 'branch', '--show-current'],
capture_output=True,
text=True,
check=False,
).stdout.strip()
# We use rev-parse to check for Stacked Git's metadata tracking branch,
# instead of checking `stg top` or similar, because we also want the
# first `stg new` or `stg import` to correctly detect that we are
# working on a patch queue.
is_stgit_patch = bool(
subprocess.run(
[
'git',
'rev-parse',
'--verify',
'--end-of-options',
f'refs/stacks/{current_branch}',
],
capture_output=True,
check=False,
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX