Skip to main content

A pytest plugin to report on repository standards conformance

Project description

PyPI version Python versions CI See Build Status on AppVeyor

pytest-repo-health adapts pytest to run repo health checks as described in edx-repo-health. Similar to how pytest runs a number of test functions, pytest-repo-health runs a number of repo check functions.

It inspects a code repository and outputs a report with info on whether the repository follows standards as defined by checks. It’s a good complement for a cookiecutter; the cookiecutter provides a good template for starting a repository with current best practices, and pytest-repo-health helps it keep up with those practices as they evolve over time.

This pytest plugin was generated with Cookiecutter along with @hackebrot’s cookiecutter-pytest-plugin template.

Installation

For now, you need to git clone pytest-repo-health from: git@github.com:edx/pytest-repo-health.git You can install by running make requirements and then pip install -e . in a Python 3.5+ virtualenv.

Usage

Once installed, use this command to run checks:

$ pytest -c <() --noconftest --repo-health --repo-health-path <path to dir with checks> --repo-path <path to repo to check>

The -c and –noconftest options are needed to stop pytest from incorrectly reading configuration files in the repo you are checking:

-c file: load configuration from `file` instead of trying to locate one of the implicit configuration files. Helpful if invocation dir defines "add-opts" in one of its files.

--noconftest: Don't load any conftest.py files. Helpful in case invocation dir/repository has conftest files that change configurations or cause pytest to run unnecessary code.

Other pytest options can be used. For example, -k is helpful for running a subset of checks.

The “all_results” dictionary will be written as YAML to repo_health.yaml.

Adding Custom Checks

Any repo can host repo checks. They must be in a directory named “repo_health”.

If you would like to add custom checks for your own repo, create a dir named “repo_health” and place modules with checks inside of it.

Checks naming convention:

  • python_functions = “check_*”

  • python_files = “check_*.py”

Checks Discovery

Pytest will look for checks in these directories, though it will only successfully run checks in the first place it finds them: - Dir of pytest invocation(so current dir) - Dir where pytest-repo-health is installed - Dir specified by –repo-health-path flag in pytest invocation

Args

Arguments added by plugin:

--repo-health: this arg needs to be present for plugin to do anything

--repo-path <dir path> : the path to dir on which to perform checks. If not preset, checks will be performed on current dir

--repo-health-path <dir path>: path to where checks are located. If not preset, plugin will look for checks in current repo

--output-path <file path> : path to where to save resulting checks report

--repo-health-metadata: if this is present, plugin will collect metadata(docs) from checks. You can give filename after flag(if no filename, it defaults to metadata.yaml)

Future improvements

  • Currently, the checks do not throw any kind of warning or error if check does not pass.

  • Documenting standard reqs/checks in each check better.

  • Create tests for this plugin(currently, you can run these checks on this repo, but no automated method for it)

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

This software is licensed under the terms of the AGPLv3.

Please see LICENSE for details.

How To Contribute

Contributions are very welcome.

Please read How To Contribute for details.

The pull request description template should be automatically applied if you are creating a pull request from GitHub. Otherwise you can find it it at PULL_REQUEST_TEMPLATE.md

Issues

The issue report template should be automatically applied if you are creating an issue on GitHub as well. Otherwise you can find it at ISSUE_TEMPLATE.md

If you encounter any problems, please file an issue along with a detailed description.

Reporting Security Issues

Please do not report security issues in public. Please email security@openedx.org.

Getting Help

Have a question about this repository, or about Open edX in general? Please refer to this list of resources if you need any assistance.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_repo_health-3.2.1.tar.gz (29.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_repo_health-3.2.1-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file pytest_repo_health-3.2.1.tar.gz.

File metadata

  • Download URL: pytest_repo_health-3.2.1.tar.gz
  • Upload date:
  • Size: 29.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytest_repo_health-3.2.1.tar.gz
Algorithm Hash digest
SHA256 e97582a476844f340f76bef3eafaa79f78682259b2928ecac3be16172b75b02d
MD5 c281db91cfb080a0d79d4d88aebca982
BLAKE2b-256 0835715d69c68bad53daadfa7f2ed3835ad7d3e201fc85ee1c4653320f00f72a

See more details on using hashes here.

File details

Details for the file pytest_repo_health-3.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_repo_health-3.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dada914bf68be92cc59428daab854a2716a0fbe391407fd4b9f2c7eb054842a4
MD5 3ebe5972e0fefd712346c439ee201886
BLAKE2b-256 88f4485373f302d71447fa32be449272b4c4693ea5234e5f368aca93c57ec75a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page