Commits

Mikhail Korobov  committed 0fd075e Merge

Merged in schinckel/django-coverage/badges (pull request #5)

Generate image badges

  • Participants
  • Parent commits 12be8b8, b1f6abe

Comments (0)

Files changed (110)

 include django_coverage/utils/module_tools/*.py
 include django_coverage/utils/coverage_report/*.py
 include django_coverage/utils/coverage_report.templates/*.py
+include django_coverage/utils/coverage_report/badges/*/*.png
 
    See ``settings.py`` for more detail.
 3. Run ``manage.py test`` like you normally do.
 
+
+Extras
+======
+Coverage badges
+---------------
+``django_coverage`` will also generate a badge image that represents
+the percentage coverage that your project has.
+
+This will be stored in the same directory as the coverage report data:
+``$PROJECT/.coverage/coverage_status.png``.
+
+Currently, the only badge type that is included is drone.io_. When other
+types are included, you will be able to select which is used by 
+``settings.COVERAGE_BADGE_TYPE``.
+
+To prevent the badge generation, you could set this to ``None``.
+
+Using the coverage badge with drone.io_
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+drone.io_ has no native support for coverage reporting. However, you
+can save build artifacts: just tell it to save one called:
+``.coverage/coverage_status.png``. Then you can reference it in your
+project's README.
+
 And that's it.
 
 
 .. _Ned Batchelder: http://nedbatchelder.com
 .. _coverage.py: http://bitbucket.org/ned/coveragepy/
 .. _Django: http://www.djangoproject.com/
+.. _drone.io: http://drone.io/

File assets/badges/drone.io/coverage_status.png

Added
New image

File assets/badges/drone.io/layered.acorn

Binary file added.

File assets/badges/drone.io/status.png

Added
New image

File django_coverage/settings.py

 # This makes it possible to both generate HTML reports and see coverage
 # information on STDOUT.
 COVERAGE_USE_STDOUT = getattr(settings, 'COVERAGE_USE_STDOUT', COVERAGE_REPORT_HTML_OUTPUT_DIR is None)
+
+# The name of the folder within utils/coverage_report/badges/ that
+# contains the badges we want to use.
+COVERAGE_BADGE_TYPE = getattr(settings, 'COVERAGE_BADGE_TYPE', 'drone.io')

File django_coverage/utils/coverage_report/badges/drone.io/0.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/1.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/10.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/100.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/11.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/12.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/13.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/14.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/15.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/16.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/17.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/18.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/19.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/2.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/20.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/21.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/22.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/23.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/24.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/25.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/26.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/27.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/28.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/29.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/3.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/30.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/31.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/32.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/33.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/34.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/35.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/36.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/37.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/38.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/39.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/4.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/40.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/41.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/42.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/43.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/44.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/45.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/46.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/47.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/48.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/49.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/5.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/50.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/51.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/52.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/53.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/54.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/55.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/56.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/57.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/58.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/59.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/6.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/60.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/61.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/62.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/63.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/64.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/65.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/66.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/67.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/68.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/69.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/7.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/70.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/71.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/72.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/73.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/74.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/75.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/76.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/77.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/78.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/79.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/8.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/80.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/81.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/82.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/83.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/84.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/85.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/86.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/87.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/88.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/89.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/9.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/90.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/91.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/92.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/93.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/94.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/95.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/96.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/97.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/98.png

Added
New image

File django_coverage/utils/coverage_report/badges/drone.io/99.png

Added
New image

File django_coverage/utils/coverage_report/html_report.py

 from html_module_errors import html_module_errors
 from html_module_excludes import html_module_excludes
 from templates import default_module_index as module_index
+from django_coverage import settings
 
 def html_report(outdir, modules, excludes=None, errors=None):
     """
         html_module_errors(os.path.join(outdir, _file), errors)
     print >>fo, module_index.BOTTOM
     fo.close()
+    
+    if settings.COVERAGE_BADGE_TYPE:
+        badge = open(os.path.join(
+            os.path.dirname(__file__),
+            'badges',
+            settings.COVERAGE_BADGE_TYPE,
+            '%s.png' % int(overall_covered)
+        )).read()
+        open(os.path.join(outdir, 'coverage_status.png'), 'wb').write(badge)
 

File django_coverage/utils/coverage_report/templates/default_module_index.py

 <div id="content-header">
   <h1>Test Coverage Report</h1>
   <p>Generated: %(test_timestamp)s</p>
+  <p><img src="coverage_status.png"></p>
 </div>
 """
 
                 'django_coverage.utils.module_tools',
                 'django_coverage.utils.coverage_report',
                 'django_coverage.utils.coverage_report.templates'],
+      package_data={'django_coverage': ['utils/coverage_report/badges/*/*.png']},
 
       requires = ['django (>=1.2)', 'coverage (>= 2.85)'],