Metadata-Version: 2.1
Name: cico
Version: 0.1.7
Summary: deploy CI results to git
Home-page: http://github.com/stefanhoelzl/cico
Author: Stefan Hoelzl
Author-email: stefan.hoelzl@posteo.de
License: MIT
Keywords: ci travis git badge
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.5
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: POSIX :: Linux
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Version Control :: Git
Description-Content-Type: text/markdown
Requires-Dist: anybadge (==1.1.1)
Requires-Dist: GitPython (==2.1.10)
Requires-Dist: CairoSVG (==2.1.3)

# cico

[![Build Status](https://travis-ci.org/stefanhoelzl/cico.svg?branch=master)](https://travis-ci.org/stefanhoelzl/cico)
[![PyPI](https://img.shields.io/pypi/v/cico.svg)](https://pypi.org/project/cico/)
[![License](https://img.shields.io/pypi/l/cico.svg)](LICENSE)

deploy CI results to git

**cico** commits artefacts generated by a CI enviroinment to a Git results branch.

For each tested branch a directory in the results branch gets created.
* _tested branch_: The branch you commited an is checked out by the CI tool
* _results branch_: The branch where your results should be deployed
  * can be in a different repository than the tested branch

## Installation
````bash
$ pip install cico
```

## Usage

`deploy.py`
```python
from cico import TravisCI
from cico.results import Directory, File, Badge

TravisCI(
    repo = GitHub(USERNAME,   # GitHub Username (e.g. 'stefanhoelzl')
                  REPO_NAME,  # GitHub Repository (e.g. 'ci-results')
                  TOKEN),     # GitHub Personal access tokens
                              # ONLY ENCRYPTED (https://docs.travis-ci.com/user/environment-variables/#Defining-encrypted-variables-in-.travis.yml)
    branch = RESULT_BRANCH,   # Git Branch with the results (e.g. 'cico-testing')
    results = [
        # Deploy file 'testresults.tap' into folder 'tap' (destination is optional)
        File("testresults.tap", destination="tap"),

        # Deploy file 'wrong_name.tap' as 'correct_name.tap' (rename is optional)
        File("wrong_name.txt", rename="correct_name.txt"),

        # Deploy directory 'covhtml' into folder 'coverage' (desitnation is optional)
        Directory("covhtml", destination="coverage"),

        # Create a Badge with the label "My Badge" and value "96" as mybadge.svg and mybadge.png
        # (png is optional) in the directory 'badges'
        Badge("badges/mybadge", png=True, label="My Badge", value=96,
              **anybadge_arguments),  # https://github.com/jongracecox/anybadge
    ]
).commit(
    # commit message (optional)
    # {build} gets replaced by build number
    # {branch} gets replaced by name of tested branch
    message="build {build} on branch {branch}",

    # perform 'git push' even if not executed in CI environment (default=False)
    no_ci_push=True
)
```

`.travis.yml` with `after_script` section
```yaml
after_script:
  - python deploy.py
```

`.travis.yml` with `deploy` section
```yaml
deploy:
  provider: script
  skip_cleanup: true  # prevent TravisCI from cleaning up the files you want to deploy
  script: python deploy.py
```

directory structure afterwards in branch `cico-testing` of the repository `ci-results`
```
+-- master
    o-- correct_name.txt
    +-- tap
    |   o-- testresults.tap
    +-- covhtml
    |   +-- <all contents of covhtml in the tested branch>
    +-- badges
        o-- mybadge.svg
        o-- mybadge.png
```


