# Continuous Integration

Currently, we use two forms of continous integration: **HoundCI** and **TravisCI.** \
\
Both are primarily used as checks that are run when a pull-request is created, and have :white\_check\_mark: or :x:to denote whether the checks have passed or not.&#x20;

![Passed CI Check, CI Error](https://2737206121-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LDzutXt_2v11rvZJ4c7%2F-LRFvZp59vMpfCvKITDz%2F-LRFwcWssEP9jzfZrkvG%2FScreen%20Shot%202018-11-14%20at%201.39.29%20AM.png?alt=media\&token=e4931628-52d0-4519-9d1a-98c779686d5b)

## HoundCI

HoundCI serves as a way for code to be linted when a pull request is created. HoundCI runs on the new code added, leaving comments if code does not follow the styling guidelines.

![Hound Linting Error](https://2737206121-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LDzutXt_2v11rvZJ4c7%2F-LRFvZp59vMpfCvKITDz%2F-LRFw-qtbbSXThegtqRX%2FScreen%20Shot%202018-11-14%20at%201.36.49%20AM.png?alt=media\&token=79997e32-ba54-48fe-a7ba-9c8b85d6f806)

Rules are defined in a `.hound.yml` file at the root of the repository, and a sample one might look like:

{% code title=".hound.yml" %}

```yaml
flake8:
  enabled: true
  config_file: .flake8.ini
```

{% endcode %}

The above one tells HoundCI to lint using `flake8` (a `python` linter) and points to `.flake8.ini` as the configuration file.

{% code title=".flake8.ini" %}

```
[flake8]
ignore = E111,E114,E302
exclude = .git,__pycache__,venv
max-line-length = 100
```

{% endcode %}

To configure HoundCI for a repository, the Backend Lead should enable it [here](http://houndci.com), and once it is enabled, HoundCI will begin running checks as long as a `.hound.yml` file exists.

## TravisCI

TravisCI is primarily used on AppDev as a way of running unit tests in a given repository. Although as developers we write unit tests, it's easy to forget to run them every single time we create a new feature.

TravisCI allows us to automate this by running tests based on a `.travis.yml` file at the root of the repository. A sample one for [pollo-backend](https://github.com/cuappdev/pollo-backend) is below:

{% code title=".travis.yml" %}

```yaml
language: node_js
sudo: required
node_js:
    - '10'
services:
    - postgresql
addons:
    postgresql: '9.6'
before_install:
    - psql --host=localhost -c 'CREATE DATABASE clicker;' -U postgres
env:
  global:
    - CHRONICLE_ACCESS_KEY='' CHRONICLE_SECRET_KEY='' DB_HOST='localhost' DB_USERNAME='postgres' DB_PASSWORD='' DB_NAME='clicker' GOOGLE_CLIENT_ID='?'
        GOOGLE_CLIENT_SECRET='?' GOOGLE_REDIRECT_URI='?'
script:
    - npm run start &
    - sleep 10; npm run test
```

{% endcode %}

TravisCI can also run more complex scripts, and we also use TravisCI to push Docker images for deployment.

To configure HoundCI for a repository, the Backend Lead should enable it [here](http://houndci.com), and once it is enabled, HoundCI will begin running checks as long as a `.travis.yml` file exists.
