.. image:: https://img.shields.io/codeship/7ce18320-21cb-0134-bdd9-5a97be3a7e25/default.svg
   :target: https://bitbucket.org/hellwig/BBCS-Tools
.. image:: https://coveralls.io/repos/bitbucket/hellwig/bbcs-tools/badge.svg?branch=default 
   :target: https://coveralls.io/bitbucket/hellwig/bbcs-tools?branch=default
.. image:: https://img.shields.io/pypi/v/BBCS-Tools.svg
   :target: https://pypi.python.org/pypi/BBCS-Tools/
.. image:: https://img.shields.io/badge/Donate-PayPal-blue.svg
   :target: https://paypal.me/MartinHellwig
.. image:: https://img.shields.io/badge/Donate-Patreon-orange.svg
   :target: https://www.patreon.com/hellwig
      
##########
BBCS Tools
##########

Python3 / Bitbucket / Codeship / Mercurial / Coveralls / PyPI Integration.

What is it?
===========
- Tools for integrating several services together.

What problem does it solve?
===========================
- Uploading build status to the hg commit in Bitbucket
- Uploading coverage status to coveralls
- Uploading packages to pypi

How do I install it?
====================
::

  $ pip install bbcs-tools


How do I use it?
================
This package is meant to be used within codeship itself, here is a guide how I
configured it:

Environment
-----------
Make sure you have the following keys defined:

* BB_USERNAME # This is your bitbucket username, used for updating the build status update.
* BB_PASSWORD # This is your bitbucket password, again for the build status update.
* COVERALLS_REPO_TOKEN # This is the token as generated by coveralls.
* PP_USERNAME # The username you use for uploading pypi packages.
* PP_PASSWORD # And the corresponding password.
* RUN_SOURCE # This tells coverage only to cover the source in this directory.
* RUN_MODULE # This is the module that contains/runs your tests, for example 'test.py'

Test
----
Test comes in two parts, 'Setup Commands' and 'Configure Test Pipelines', you 
want to chose 'I want to create my own custom commands'.

Setup Commands
++++++++++++++
This is what I have in there:

.. sourcecode:: shell

  ################################################################################
  # Switch to python 3
  virtualenv -p $(which python3) "${HOME}/cache/python3_env"
  source "${HOME}/cache/python3_env/bin/activate"
  ################################################################################
  # First install bitbucket/codeship integration tools
  pip install bbcs-tools
  # Notify bitbucket that build has started
  bbcs_build_started
  ################################################################################
  #  Now install application specific requirements
  pip install -r requirements.txt
  ################################################################################


Configure Test Pipelines
++++++++++++++++++++++++
And here is what is in mine:

.. sourcecode:: shell

  ################################################################################
  # Run the unit test with coverage, if there is a fail we notify bitbucket
  coverage run --source=$RUN_SOURCE $RUN_MODULE || bbcs_build_failure
  # Notify bitbucket the build has run successfully.
  bbcs_build_stopped
  ################################################################################
  # Upload coverage data to coveralls
  bbcs_upload_coverage_to_coveralls
  ################################################################################
  

Deployment
---------
Again choose custom script, I have mine configure to do a build and upload on
every commit on the default branch. Here is what is in my deploy script:


.. sourcecode:: shell

  ################################################################################
  # Build an sdist package and upload it to pypi.
  bbcs_upload_package_to_pypi
  ################################################################################

 
What license is this?
=====================
Two-clause BSD

How can I get support?
======================
The tools I publish have already taken me considerable effort which I have given
away free of charge, if you require guaranteed support please contact me via
e-mail so we can discuss my fee.

How can I give you support?
===========================
Feedback, suggestions and comments via the repo's bug tracker are always
appreciated. Time permitting I will have a serious look at any pull requests. 

Signing Off
===========
Is my work helpful or valuable to you? You can repay me by donating via:

https://paypal.me/MartinHellwig

.. image:: https://img.shields.io/badge/PayPal-MartinHellwig-blue.svg
  :target: https://paypal.me/MartinHellwig
  :alt: Donate via PayPal.Me
  :scale: 120 %

-or-

https://www.patreon.com/hellwig

.. image:: https://img.shields.io/badge/Patreon-hellwig-orange.svg
  :target: https://www.patreon.com/hellwig
  :alt: Donate via Patreon
  :scale: 120 %


Thank you!

   
