git.schokokeks.org
Repositories
Help
Report an Issue
derivepassphrase.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
7ad6f08
Branches
Tags
documentation-tree
master
unstable/modularize-and-refactor-test-machinery
unstable/ssh-agent-socket-providers
wishlist
0.1.0
0.1.1
0.1.2
0.1.3
0.2.0
0.3.0
0.3.1
0.3.2
0.3.3
0.4.0
0.5.1
0.5.2
derivepassphrase.git
scripts
qc_auto.py
Add quality control scripts
Marco Ricci
commited
7ad6f08
at 2025-02-09 20:47:17
qc_auto.py
Blame
History
Raw
#!/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, ).stdout ) try: subprocess.run(['hatch', 'fmt', '-l'], check=True) subprocess.run(['hatch', 'fmt', '-f'], check=True) if current_branch == 'master': subprocess.run( ['hatch', 'env', 'run', '-e', 'types', '--', 'check'], check=True ) subprocess.run( ['hatch', 'test', '-acpqr', '--', '--maxfail', '1'], check=True, ) # fmt: off subprocess.run( [ 'hatch', 'env', 'run', '-e', 'docs', '--', 'build', '-f', 'mkdocs_devsetup.yaml', ], check=True, ) # fmt: on elif not is_stgit_patch: subprocess.run( ['hatch', 'env', 'run', '-e', 'types', '--', 'check'], check=True ) subprocess.run( ['hatch', 'test', '-cpqr', *opts, '--', '--maxfail', '1'], env={**os.environ} | {'HYPOTHESIS_PROFILE': 'dev'}, check=True, ) except subprocess.CalledProcessError as exc: sys.exit(getattr(exc, 'returncode', 1)) except KeyboardInterrupt: sys.exit(1)