Giter Club home page Giter Club logo

pytest-repo-health's Introduction

pytest-repo-health

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: [email protected]: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 [email protected].

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.

pytest-repo-health's People

Contributors

edx-requirements-bot avatar usamasadiq avatar jinder1s avatar aht007 avatar mraarif avatar timmc-edx avatar feanil avatar iamsobanjaved avatar jmbowman avatar sarina avatar jawayria avatar awais786 avatar dependabot[bot] avatar nedbat avatar zubairshakoorarbisoft avatar edx-semantic-release avatar bmtcril avatar xitij2000 avatar mumarkhan999 avatar ericfab179 avatar ziafazal avatar

Stargazers

Mauro Risonho de Paula Assumpção avatar Emad Rad avatar

Watchers

John Nagro avatar Alex avatar Pieter Malan avatar Matthew Carter avatar  avatar Marlon Keating avatar Khanan Grauer avatar Bill DeRusha avatar  avatar Binod Pant avatar Justin Lapierre avatar Cory Lee avatar James Cloos avatar George Schneeloch avatar Naveed avatar Jeff Witt avatar Farhan Umer avatar Andrew Wardwell avatar  avatar Jennifer Anne Akana avatar  avatar  avatar Alex Mbugua Ngugi avatar ihtram avatar Matt Drayer avatar Hassan avatar Rebecca Graber avatar Igor avatar Brandon Bodine avatar jawad khan avatar Ben Warzeski avatar María Guillermina Véscovo avatar Muhammad Ammar avatar Rodrigo Martin avatar Monica Diaz avatar Julia Eskew avatar stv avatar Kashif Chaudhry avatar Chris Pappas avatar Agha Awais avatar Nadeem Shahzad avatar  avatar Hasnain Naveed avatar Julian Palmerio avatar Matt avatar Bianca Severino avatar Zaman Afzal avatar  avatar Blue avatar Arbab Khalil avatar Alan Zarembok avatar Juliana Kang avatar Syed Awais Ali avatar Gabe Weinberg avatar Kellie Selinka avatar Jesper Hodge avatar  avatar Danielle Eriksen avatar

pytest-repo-health's Issues

Issue with `pytest_collect_ignore` implementation

Hi, pytest developer here, coming from here.

This plugin implements the pytest_collect_ignore hook here:

def pytest_ignore_collect(path, config):
"""
pytest hook that determines if pytest looks at specific file to collect tests
if repo_health is set to true:
only tests in test files with "repo_health" in their path will be collected
"""
if config.getoption("repo_health"):
if "/repo_health" not in str(path):
return True
return False

This hook has "firstresult" semantics, which means that if a plugin returns a non-None result, this is the result and further processing is stopped. This plugin does return False in the non-ignored case, but due to firstresult what it should do is return None to allow other plugins (including pytest itself) to perform their ignores.

Drop Python 3.7 testing to fix tests

We are currently running tests against Python 3.7 & 3.8, but quality tests are failing for 3.7. So drop support for Python 3.7. This is affecting the upgrade requirements job, so we can fix that by dropping Python 3.7 testing.

Failing tests here: #172

A/C

  • Major version bump, version is mentioned in pytest_repo_health/init.py
  • Remove python 3.7 from tox.ini
  • Drop Python 3.7 testing from unit tests in GitHub Actions
  • Drop the classifier of Python 3.7 from setup.py or setup.cfg
  • Remove Python 3.7 badge from README
  • Upgrade Python version in upgrade requirements Github action’s workflow
  • Run upgrade requirements job on Python 3.8
  • Add appropriate Changelog entry in CHANGELOG.rst
  • Remove any reference to Python 3.7 (if any)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.