Skip to content

Commit

Permalink
Merge pull request #2 from Cadasta/ci/travis-setup
Browse files Browse the repository at this point in the history
Looks good: I think it's as we said about Ansible -- much better not to bother with it for Travis.
  • Loading branch information
ian-ross committed Dec 6, 2015
2 parents 85fad72 + 312eb6a commit 85a5f88
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[run]
omit =
cadasta/*/tests/*
cadasta/config/*
cadasta/manage.py
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ local/
*.pyc
.cache
__pycache__/

# Coverage
.coverage
htmlcov
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
language: python
python:
- "3.4"
services:
- postgresql
addons:
postgresql: "9.4"
install:
- pip install -r requirements/common.txt
- pip install -r requirements/dev.txt
before_script:
- psql template1 postgres -c 'create extension hstore;'
- psql -c 'create database cadasta;' -U postgres
- psql -U postgres -d cadasta -c "create extension postgis;"
- python cadasta/manage.py migrate --settings=config.settings.travis
script:
- py.test cadasta --cov=cadasta --ds=config.settings.travis
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# cadasta-platform

[![Build Status](https://travis-ci.com/Cadasta/cadasta-platform.svg?token=3Gq6szrnpvs9ousfkQxj)](https://travis-ci.com/Cadasta/cadasta-platform)

## Install for development

Install:
Expand All @@ -26,3 +28,19 @@ python app/manage.py runserver
```

Open `http://localhost:5000/` in your browser, you should see a default Django page.

## Run tests

From the repository's root run:

```
py.test cadasta
```

To get coverage reports run:

```
py.test cadasta --cov=cadasta --cov-report=html
```

This creates a HTML report under `htmlcov`. See [pytest-cov docs](http://pytest-cov.readthedocs.org/en/latest/readme.html#reporting) for other report formats.
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Vagrant.configure(2) do |config|

# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "hashicorp/precise64"
config.vm.box = "ubuntu/trusty64"

# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
Expand Down
16 changes: 16 additions & 0 deletions cadasta/config/settings/travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from .default import *

DEBUG = True

# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'cadasta',
'USER': 'postgres',
'PASSWORD': '',
'HOST': '',
}
}
14 changes: 12 additions & 2 deletions provision/roles/cadasta_app/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
- name: Install packages
sudo: yes
apt: pkg={{ item }} state=installed update_cache=yes
with_items:
- python3-dev
- python-virtualenv

- name: Manually create the initial virtualenv
command: virtualenv {{ virtualenv_path }} --python=python3 creates="{{ virtualenv_path }}"

- name: Install requirements
pip: virtualenv={{ virtualenv_path }} requirements={{ application_path }}/requirements/common.txt
pip: virtualenv={{ virtualenv_path }} requirements={{ application_path }}requirements/common.txt

- name: Django migrate
django_manage: command=migrate app_path={{ application_path }}/cadasta virtualenv={{ virtualenv_path }}
django_manage: command=migrate app_path={{ application_path }}cadasta virtualenv={{ virtualenv_path }}
2 changes: 1 addition & 1 deletion provision/roles/cadasta_dev/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
- name: Install requirements
pip: virtualenv={{ virtualenv_path }} requirements={{ application_path }}/requirements/dev.txt
pip: virtualenv={{ virtualenv_path }} requirements={{ application_path }}requirements/dev.txt
8 changes: 8 additions & 0 deletions provision/roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- name: Install packages
sudo: yes
apt: pkg={{ item }} state=installed update_cache=yes
with_items:
- python3
- python3-dev
- python-setuptools
- python-virtualenv
5 changes: 0 additions & 5 deletions provision/roles/db/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
- libpq-dev # Required for Ansible to interact with postgres
- python-psycopg2 # Required for Ansible to interact with postgres

# Python Dev
- python-dev
- python-setuptools
- python-virtualenv

- name: Allow password authentication for local socket users
sudo: yes
copy: src=pg_hba.conf dest=/etc/postgresql/9.4/main/pg_hba.conf force=yes
Expand Down
7 changes: 0 additions & 7 deletions provision/roles/webserver/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
sudo: yes
apt: pkg={{ item }} state=installed update_cache=yes
with_items:
- python3
- python3-dev
- python-setuptools
- python-virtualenv
- nginx

- name: write precise64 to sites-available
Expand All @@ -17,6 +13,3 @@
sudo: True
notify:
- restart nginx

- name: Manually create the initial virtualenv
command: virtualenv {{ virtualenv_path }} -p python3 creates="{{ virtualenv_path }}"
6 changes: 3 additions & 3 deletions provision/vagrant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
db_name: django_app
db_user: django
db_password: sdjgh34iutwefhfgbqkj3
application_path: /vagrant
virtualenv_path: /vagrant/env
application_path: /vagrant/
virtualenv_path: /vagrant/env/
server_name: precise64
roles:
- db
- webserver
- cadasta_dev
- cadasta_app
- cadasta_dev
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
git+git://github.com/dcramer/django-devserver.git#egg=django-devserver
pytest-django
pytest-cov

0 comments on commit 85a5f88

Please sign in to comment.