From 41767c4af67a451ef3eeb78252ebbd3f5d295dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Cort=C3=AAs?= Date: Sun, 6 Sep 2015 14:42:20 +0100 Subject: [PATCH 01/12] refactor to pip package --- .gitignore | 102 ++++++++++++++++++++++++++++++++++++++++++++- DESCRIPTION.rst | 13 ++++++ README.md | 39 +++++++++++++++-- __init__.py | 106 +++++++++++++++++++++++++++++++++++++++++++++++ codacycov.py | 55 ------------------------ requirements.txt | 1 - setup.cfg | 5 +++ setup.py | 57 +++++++++++++++++++++++++ 8 files changed, 317 insertions(+), 61 deletions(-) create mode 100644 DESCRIPTION.rst create mode 100755 __init__.py delete mode 100644 codacycov.py delete mode 100644 requirements.txt create mode 100644 setup.cfg create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index ecb2893..527f6bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,105 @@ -*.py[cdo] +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ build/ +develop-eggs/ dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ *.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ .coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio + +*.iml + +## Directory-based project format: +.idea/ +# if you remove the above rule, at least ignore the following: + +# User-specific stuff: +# .idea/workspace.xml +# .idea/tasks.xml +# .idea/dictionaries + +# Sensitive or high-churn files: +# .idea/dataSources.ids +# .idea/dataSources.xml +# .idea/sqlDataSources.xml +# .idea/dynamic.xml +# .idea/uiDesigner.xml + +# Gradle: +# .idea/gradle.xml +# .idea/libraries + +# Mongo Explorer plugin: +# .idea/mongoSettings.xml + +## File-based project format: +*.ipr +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties diff --git a/DESCRIPTION.rst b/DESCRIPTION.rst new file mode 100644 index 0000000..68b3a57 --- /dev/null +++ b/DESCRIPTION.rst @@ -0,0 +1,13 @@ +A sample Python project +======================= + +This is the description file for the project. + +The file should use UTF-8 encoding and be written using ReStructured Text. It +will be used to generate the project webpage on PyPI, and should be written for +that purpose. + +Typical contents for this file would include an overview of the project, basic +usage examples, etc. Generally, including the project changelog in here is not +a good idea, although a simple "What's New" section for the most recent version +may be appropriate. diff --git a/README.md b/README.md index ccead75..c329098 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,37 @@ -# python-codacycov +# python-coverage-coverage +[![Build Status](https://circleci.com/gh/codacy/python-codacy-coverage.png?style=shield&circle-token=:circle-token)](https://circleci.com/gh/codacy/python-codacy-coverage) +[![Codacy Badge](https://www.codacy.com/project/badge/1c524e61cd8640e79b80d406eda8754b)](https://www.codacy.com/app/Codacy/python-codacy-coverage-) -Submit Python `coverage` report to [Codacy](https://www.codacy.com/). +Python coverage reporter for Codacy https://www.codacy.com -DISCLAIMER: This is an unofficial project, and is not endorsed by or -associated with Codacy in any way. +## Setup + +Codacy assumes that coverage is previously configured for your project. + +You can install the coverage reporter by running: + +### [Install jpm](https://www.jpm4j.org/#!/md/install) +``` +curl http://www.jpm4j.org/install/script | sh +``` + +### Install codacy-coverage-reporter +``` +jpm install com.codacy:codacy-coverage-reporter +``` + +## Updating Codacy + +To update Codacy, you will need your project API token. You can find the token in Project -> Settings -> Integrations -> Project API. + +Then set it in your terminal, replacing %Project_Token% with your own token: + +``` +export CODACY_PROJECT_TOKEN=%Project_Token% +``` + +Next, simply run the Codacy reporter. It will find the current commit and send all details to your project dashboard: + +``` +python-codacy-coverage -f coverage.xml +``` diff --git a/__init__.py b/__init__.py new file mode 100755 index 0000000..3867d8e --- /dev/null +++ b/__init__.py @@ -0,0 +1,106 @@ +"""Codacy coverage reporter for Python""" + +import argparse +import json +import logging +import os +from xml.dom import minidom + +import requests + +logging.basicConfig(level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s') + +CODACY_PROJECT_TOKEN = os.getenv('CODACY_PROJECT_TOKEN') +CODACY_BASE_API_URL = os.getenv('CODACY_BASE_API_URL', 'https://api.codacy.com') +URL = CODACY_BASE_API_URL + '/2.0/coverage/{commit}/python' +DEFAULT_REPORT_FILE = 'coverage.xml' + + +def get_git_revision_hash(): + import subprocess + + return subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip() + + +def parse_report_file(report_file): + # Convert decimal string to floored int percent value + percent = lambda s: int(float(s) * 100) + + # Parse the XML into the format expected by the API + report_xml = minidom.parse(report_file) + + report = { + 'language': "python", + 'total': percent(report_xml.getElementsByTagName('coverage')[0].attributes['line-rate'].value), + 'fileReports': [], + } + + classes = report_xml.getElementsByTagName('class') + for cls in classes: + file_report = { + 'filename': cls.attributes['filename'].value, + 'total': percent(cls.attributes['line-rate'].value), + 'coverage': {}, + } + lines = cls.getElementsByTagName('line') + for line in lines: + hits = int(line.attributes['hits'].value) + if hits >= 1: + # The API assumes 0 if a line is missing + file_report['coverage'][line.attributes['number'].value] = hits + report['fileReports'] += [file_report] + + return report + + +def upload_report(report, token, commit): + # Try to send the data, raise an exception if we fail + url = URL.format(commit=commit) + data = json.dumps(report) + headers = { + "project_token": token, + "Content-Type": "application/json" + } + + logging.debug(data) + + r = requests.post(url, data=data, headers=headers, allow_redirects=True) + + logging.debug(r.content) + logging.debug(r.status_code) + r.raise_for_status() + + message = json.loads(r.content)['success'] + logging.info(message) + + +def main(report_file, token, commit): + """Parse XML file and POST it to the Codacy API""" + + logging.info("Parsing report file...") + report = parse_report_file(report_file) + + logging.info("Uploading report...") + upload_report(report, token, commit) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Codacy coverage reporter for Python.') + parser.add_argument("-r", "--report", type=str, help="coverage report file", default=DEFAULT_REPORT_FILE) + parser.add_argument("-c", "--commit", type=str, help="coverage report file") + parser.add_argument("-v", "--verbose", help="coverage report file", action="store_true") + + args = parser.parse_args() + + if args.verbose: + logging.setLevel(logging.DEBUG) + + if not CODACY_PROJECT_TOKEN: + logging.error("environment variable CODACY_PROJECT_TOKEN is not defined.") + exit(1) + + if not args.commit: + args.commit = get_git_revision_hash() + + main(args.report, CODACY_PROJECT_TOKEN, args.commit) diff --git a/codacycov.py b/codacycov.py deleted file mode 100644 index f10facf..0000000 --- a/codacycov.py +++ /dev/null @@ -1,55 +0,0 @@ -"""Submit Python coverage report to Codacy.""" - -import sys -from xml.dom import minidom - -import requests - - -XML_DOC = 'coverage.xml' -URL = 'https://www.codacy.com/api/coverage/{token}/{commit}' - - -def main(token, commit, xml_file=XML_DOC): - """Parse XML file and POST it to the Codacy API""" - - # Convert decimal string to floored int percent value - percent = lambda s: int(float(s)*100) - - # Parse the XML into the format expected by the API - xmldoc = minidom.parse(xml_file) - - data = { - 'total': percent(xmldoc.getElementsByTagName('coverage')[0].attributes['line-rate'].value), - 'fileReports': [], - } - - classes = xmldoc.getElementsByTagName('class') - for cls in classes: - file_report = { - 'filename': cls.attributes['filename'].value, - 'total': percent(cls.attributes['line-rate'].value), - 'coverage': {}, - } - lines = cls.getElementsByTagName('line') - for line in lines: - hits = int(line.attributes['hits'].value) - if hits >= 1: - # The API assumes 0 if a line is missing - file_report['coverage'][line.attributes['number'].value] = hits - data['fileReports'] += [file_report] - - # Try to send the data, raise an exception if we fail - r = requests.post(URL.format(token=token, commit=commit), data=data) - r.raise_for_status() - - -if __name__ == '__main__': - argc = len(sys.argv) - if argc < 3: - print("usage: codacycov.py TOKEN COMMIT [COVERAGE_XML]") - print("if COVERAGE_XML is not specified, default is coverage.xml") - elif argc < 4: - main(sys.argv[1], sys.argv[2]) - else: - main(sys.argv[1], sys.argv[2], sys.argv[3]) diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index f229360..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -requests diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..c34b498 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,5 @@ +[bdist_wheel] +# This flag says that the code is written to work on both Python 2 and Python +# 3. If at all possible, it is good practice to do this. If you cannot, you +# will need to generate wheels for each Python version that you support. +universal=1 \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..9dd3393 --- /dev/null +++ b/setup.py @@ -0,0 +1,57 @@ +# Always prefer setuptools over distutils +from setuptools import setup, find_packages +# To use a consistent encoding +from codecs import open +from os import path + +here = path.abspath(path.dirname(__file__)) + +# Get the long description from the relevant file +with open(path.join(here, 'DESCRIPTION.rst'), encoding='utf-8') as f: + long_description = f.read() + +setup( + name='python-codacy-coverage', + + version='1.0.0', + + description='Codacy coverage reporter for Python', + long_description=long_description, + + url='https://github.com/codacy/python-codacy-coverage', + + author='Codacy', + author_email='team@codacy.com', + + license='MIT', + + # See https://pypi.python.org/pypi?%3Aaction=list_classifiers + classifiers=[ + 'Development Status :: 5 - Production/Stable', + + 'Intended Audience :: Developers', + 'Topic :: Software Development :: Build Tools', + + 'License :: OSI Approved :: MIT License', + + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 3', + ], + + keywords='development coverage', + + packages=find_packages(exclude=['contrib', 'docs', 'tests*']), + + install_requires=['requests'], + + extras_require={ + 'dev': ['check-manifest'], + 'test': ['coverage'], + }, + + entry_points={ + 'console_scripts': [ + 'sample=main', + ], + }, +) From a4844e6fe12faeb4eeb84d3ad0e2c1cb8d8d8332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Cort=C3=AAs?= Date: Sun, 6 Sep 2015 14:47:00 +0100 Subject: [PATCH 02/12] update README --- README.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c329098..30edc3d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # python-coverage-coverage [![Build Status](https://circleci.com/gh/codacy/python-codacy-coverage.png?style=shield&circle-token=:circle-token)](https://circleci.com/gh/codacy/python-codacy-coverage) -[![Codacy Badge](https://www.codacy.com/project/badge/1c524e61cd8640e79b80d406eda8754b)](https://www.codacy.com/app/Codacy/python-codacy-coverage-) +[![Codacy Badge](https://www.codacy.com/project/badge/3a8cf06a9db94d0ab3d55e0357bc8f9d)](https://www.codacy.com/app/Codacy/python-codacy-coverage) Python coverage reporter for Codacy https://www.codacy.com @@ -10,14 +10,9 @@ Codacy assumes that coverage is previously configured for your project. You can install the coverage reporter by running: -### [Install jpm](https://www.jpm4j.org/#!/md/install) +### Install python-codacy-coverage ``` -curl http://www.jpm4j.org/install/script | sh -``` - -### Install codacy-coverage-reporter -``` -jpm install com.codacy:codacy-coverage-reporter +pip install python-codacy-coverage ``` ## Updating Codacy From a3c09f8ce1cd96ba96a522e8707b7f35579eaa8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Cort=C3=AAs?= Date: Sun, 6 Sep 2015 15:11:14 +0100 Subject: [PATCH 03/12] fix entrypoint --- DESCRIPTION.rst | 13 ------------- README.md | 5 +++-- setup.py | 7 ++++--- src/codacy/__init__.py | 5 +++++ __init__.py => src/codacy/reporter.py | 5 ++--- 5 files changed, 14 insertions(+), 21 deletions(-) delete mode 100644 DESCRIPTION.rst create mode 100644 src/codacy/__init__.py rename __init__.py => src/codacy/reporter.py (96%) diff --git a/DESCRIPTION.rst b/DESCRIPTION.rst deleted file mode 100644 index 68b3a57..0000000 --- a/DESCRIPTION.rst +++ /dev/null @@ -1,13 +0,0 @@ -A sample Python project -======================= - -This is the description file for the project. - -The file should use UTF-8 encoding and be written using ReStructured Text. It -will be used to generate the project webpage on PyPI, and should be written for -that purpose. - -Typical contents for this file would include an overview of the project, basic -usage examples, etc. Generally, including the project changelog in here is not -a good idea, although a simple "What's New" section for the most recent version -may be appropriate. diff --git a/README.md b/README.md index 30edc3d..e09486f 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ # python-coverage-coverage + +Credits to Ryan for creating this! Python coverage reporter for Codacy https://www.codacy.com + [![Build Status](https://circleci.com/gh/codacy/python-codacy-coverage.png?style=shield&circle-token=:circle-token)](https://circleci.com/gh/codacy/python-codacy-coverage) [![Codacy Badge](https://www.codacy.com/project/badge/3a8cf06a9db94d0ab3d55e0357bc8f9d)](https://www.codacy.com/app/Codacy/python-codacy-coverage) -Python coverage reporter for Codacy https://www.codacy.com - ## Setup Codacy assumes that coverage is previously configured for your project. diff --git a/setup.py b/setup.py index 9dd3393..98e2f1a 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ here = path.abspath(path.dirname(__file__)) # Get the long description from the relevant file -with open(path.join(here, 'DESCRIPTION.rst'), encoding='utf-8') as f: +with open(path.join(here, 'README.md'), encoding='utf-8') as f: long_description = f.read() setup( @@ -40,7 +40,8 @@ keywords='development coverage', - packages=find_packages(exclude=['contrib', 'docs', 'tests*']), + packages=find_packages('src'), + package_dir={'': 'src'}, include_package_data=True, install_requires=['requests'], @@ -51,7 +52,7 @@ entry_points={ 'console_scripts': [ - 'sample=main', + 'python-codacy-coverage=codacy:main', ], }, ) diff --git a/src/codacy/__init__.py b/src/codacy/__init__.py new file mode 100644 index 0000000..acf3dc3 --- /dev/null +++ b/src/codacy/__init__.py @@ -0,0 +1,5 @@ +import reporter + + +def main(): + return reporter.run() diff --git a/__init__.py b/src/codacy/reporter.py similarity index 96% rename from __init__.py rename to src/codacy/reporter.py index 3867d8e..a3741af 100755 --- a/__init__.py +++ b/src/codacy/reporter.py @@ -68,7 +68,6 @@ def upload_report(report, token, commit): r = requests.post(url, data=data, headers=headers, allow_redirects=True) logging.debug(r.content) - logging.debug(r.status_code) r.raise_for_status() message = json.loads(r.content)['success'] @@ -85,7 +84,7 @@ def main(report_file, token, commit): upload_report(report, token, commit) -if __name__ == '__main__': +def run(): parser = argparse.ArgumentParser(description='Codacy coverage reporter for Python.') parser.add_argument("-r", "--report", type=str, help="coverage report file", default=DEFAULT_REPORT_FILE) parser.add_argument("-c", "--commit", type=str, help="coverage report file") @@ -94,7 +93,7 @@ def main(report_file, token, commit): args = parser.parse_args() if args.verbose: - logging.setLevel(logging.DEBUG) + logging.Logger.setLevel(logging.getLogger(), logging.DEBUG) if not CODACY_PROJECT_TOKEN: logging.error("environment variable CODACY_PROJECT_TOKEN is not defined.") From b8fbf7715c2c6eff4d3278a6c556fdf91cc785a0 Mon Sep 17 00:00:00 2001 From: rshipp Date: Sun, 6 Sep 2015 10:43:49 -0600 Subject: [PATCH 04/12] Rename package to codacy-coverage --- README.md | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e09486f..96fc223 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ You can install the coverage reporter by running: ### Install python-codacy-coverage ``` -pip install python-codacy-coverage +pip install codacy-coverage ``` ## Updating Codacy diff --git a/setup.py b/setup.py index 98e2f1a..7412de0 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ long_description = f.read() setup( - name='python-codacy-coverage', + name='codacy-coverage', version='1.0.0', From efec83d25003418db6dab4bc161511398b06d0af Mon Sep 17 00:00:00 2001 From: rshipp Date: Tue, 8 Sep 2015 17:22:58 -0600 Subject: [PATCH 05/12] Correct README usage example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 96fc223..36439f2 100644 --- a/README.md +++ b/README.md @@ -29,5 +29,5 @@ export CODACY_PROJECT_TOKEN=%Project_Token% Next, simply run the Codacy reporter. It will find the current commit and send all details to your project dashboard: ``` -python-codacy-coverage -f coverage.xml +python-codacy-coverage -r coverage.xml ``` From 3e36bbc6455718d418e927b2405cab44fc556836 Mon Sep 17 00:00:00 2001 From: rshipp Date: Tue, 8 Sep 2015 17:24:27 -0600 Subject: [PATCH 06/12] Use docstrings where appropriate --- src/codacy/reporter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/codacy/reporter.py b/src/codacy/reporter.py index a3741af..75b3dc6 100755 --- a/src/codacy/reporter.py +++ b/src/codacy/reporter.py @@ -24,6 +24,8 @@ def get_git_revision_hash(): def parse_report_file(report_file): + """Parse XML file and POST it to the Codacy API""" + # Convert decimal string to floored int percent value percent = lambda s: int(float(s) * 100) @@ -55,7 +57,7 @@ def parse_report_file(report_file): def upload_report(report, token, commit): - # Try to send the data, raise an exception if we fail + """Try to send the data, raise an exception if we fail""" url = URL.format(commit=commit) data = json.dumps(report) headers = { From 9007a5f7c29a1108c7930e0e32d188eb28bcd7ac Mon Sep 17 00:00:00 2001 From: rshipp Date: Tue, 8 Sep 2015 17:24:56 -0600 Subject: [PATCH 07/12] Correct argparse help strings --- src/codacy/reporter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/codacy/reporter.py b/src/codacy/reporter.py index 75b3dc6..5280e34 100755 --- a/src/codacy/reporter.py +++ b/src/codacy/reporter.py @@ -89,8 +89,8 @@ def main(report_file, token, commit): def run(): parser = argparse.ArgumentParser(description='Codacy coverage reporter for Python.') parser.add_argument("-r", "--report", type=str, help="coverage report file", default=DEFAULT_REPORT_FILE) - parser.add_argument("-c", "--commit", type=str, help="coverage report file") - parser.add_argument("-v", "--verbose", help="coverage report file", action="store_true") + parser.add_argument("-c", "--commit", type=str, help="git commit hash") + parser.add_argument("-v", "--verbose", help="show debug information", action="store_true") args = parser.parse_args() From 97f572f111898a1e23aa38dca3215379a8310885 Mon Sep 17 00:00:00 2001 From: rshipp Date: Tue, 8 Sep 2015 17:25:20 -0600 Subject: [PATCH 08/12] Refactor out reporter.main function --- src/codacy/reporter.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/codacy/reporter.py b/src/codacy/reporter.py index 5280e34..5ca8469 100755 --- a/src/codacy/reporter.py +++ b/src/codacy/reporter.py @@ -76,16 +76,6 @@ def upload_report(report, token, commit): logging.info(message) -def main(report_file, token, commit): - """Parse XML file and POST it to the Codacy API""" - - logging.info("Parsing report file...") - report = parse_report_file(report_file) - - logging.info("Uploading report...") - upload_report(report, token, commit) - - def run(): parser = argparse.ArgumentParser(description='Codacy coverage reporter for Python.') parser.add_argument("-r", "--report", type=str, help="coverage report file", default=DEFAULT_REPORT_FILE) @@ -104,4 +94,8 @@ def run(): if not args.commit: args.commit = get_git_revision_hash() - main(args.report, CODACY_PROJECT_TOKEN, args.commit) + logging.info("Parsing report file...") + report = parse_report_file(args.report) + + logging.info("Uploading report...") + upload_report(report, CODACY_PROJECT_TOKEN, args.commit) From 6069cec91db665c78eb170470f8672efd2bb0a79 Mon Sep 17 00:00:00 2001 From: rshipp Date: Tue, 8 Sep 2015 17:28:34 -0600 Subject: [PATCH 09/12] Add instructions for generating coverage.xml to README --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 36439f2..6aebcad 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,12 @@ Credits to Ryan for creating this! Python coverage reporter for Codacy https://w Codacy assumes that coverage is previously configured for your project. +To generate the required coverage XML file, calculate coverage for your project as normal, then run + +``` +coverage xml +``` + You can install the coverage reporter by running: ### Install python-codacy-coverage From 085df54093dd6db32aa5869cdc431b6e79a044c3 Mon Sep 17 00:00:00 2001 From: rshipp Date: Tue, 8 Sep 2015 17:44:54 -0600 Subject: [PATCH 10/12] Modify README, convert to RST RST renders properly on PyPi. --- README.md => README.rst | 37 +++++++++++++++++++------------------ setup.py | 2 +- 2 files changed, 20 insertions(+), 19 deletions(-) rename README.md => README.rst (50%) diff --git a/README.md b/README.rst similarity index 50% rename from README.md rename to README.rst index 6aebcad..a925ae5 100644 --- a/README.md +++ b/README.rst @@ -1,39 +1,40 @@ -# python-coverage-coverage +python-coverage-coverage +======================== Credits to Ryan for creating this! Python coverage reporter for Codacy https://www.codacy.com -[![Build Status](https://circleci.com/gh/codacy/python-codacy-coverage.png?style=shield&circle-token=:circle-token)](https://circleci.com/gh/codacy/python-codacy-coverage) -[![Codacy Badge](https://www.codacy.com/project/badge/3a8cf06a9db94d0ab3d55e0357bc8f9d)](https://www.codacy.com/app/Codacy/python-codacy-coverage) +.. image:: https://circleci.com/gh/codacy/python-codacy-coverage.png?style=shield&circle-token=:circle-token + :target: https://circleci.com/gh/codacy/python-codacy-coverage + :alt: Build Status +.. image:: https://www.codacy.com/project/badge/3a8cf06a9db94d0ab3d55e0357bc8f9d + :target: https://www.codacy.com/app/Codacy/python-codacy-coverage + :alt: Codacy Badge -## Setup +Setup +----- Codacy assumes that coverage is previously configured for your project. To generate the required coverage XML file, calculate coverage for your project as normal, then run -``` -coverage xml -``` +``coverage xml``` + +Install codacy-coverage +~~~~~~~~~~~~~~~~~~~~~~~ You can install the coverage reporter by running: -### Install python-codacy-coverage -``` -pip install codacy-coverage -``` +``pip install codacy-coverage`` -## Updating Codacy +Updating Codacy +--------------- To update Codacy, you will need your project API token. You can find the token in Project -> Settings -> Integrations -> Project API. Then set it in your terminal, replacing %Project_Token% with your own token: -``` -export CODACY_PROJECT_TOKEN=%Project_Token% -``` +``export CODACY_PROJECT_TOKEN=%Project_Token%`` Next, simply run the Codacy reporter. It will find the current commit and send all details to your project dashboard: -``` -python-codacy-coverage -r coverage.xml -``` +``python-codacy-coverage -r coverage.xml`` diff --git a/setup.py b/setup.py index 7412de0..1e4f22f 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ here = path.abspath(path.dirname(__file__)) # Get the long description from the relevant file -with open(path.join(here, 'README.md'), encoding='utf-8') as f: +with open(path.join(here, 'README.rst'), encoding='utf-8') as f: long_description = f.read() setup( From 0e479e04c729cc36a41b0574e1aabe8beab05c4d Mon Sep 17 00:00:00 2001 From: rshipp Date: Tue, 8 Sep 2015 17:46:06 -0600 Subject: [PATCH 11/12] Fix typo in README --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index a925ae5..36c0932 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,5 @@ -python-coverage-coverage -======================== +python-codacy-coverage +====================== Credits to Ryan for creating this! Python coverage reporter for Codacy https://www.codacy.com From 9b2b2d5e75eecd8d05bee393b40a6884a5b05eb9 Mon Sep 17 00:00:00 2001 From: rshipp Date: Tue, 8 Sep 2015 18:03:41 -0600 Subject: [PATCH 12/12] Fix small typo in README --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 36c0932..b499b51 100644 --- a/README.rst +++ b/README.rst @@ -17,7 +17,7 @@ Codacy assumes that coverage is previously configured for your project. To generate the required coverage XML file, calculate coverage for your project as normal, then run -``coverage xml``` +``coverage xml`` Install codacy-coverage ~~~~~~~~~~~~~~~~~~~~~~~