Skip to content

Commit

Permalink
Setup travis
Browse files Browse the repository at this point in the history
  • Loading branch information
klen committed Dec 5, 2014
1 parent 6652dfd commit 4f3e94a
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 14 deletions.
6 changes: 6 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[report]
source=peewee_migrate

[run]
source=peewee_migrate

21 changes: 10 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@ language: python
python: 2.7

env:
- TOXENV=py26
- TOXENV=py27
- TOXENV=py33
- TOXENV=cov
- TOXENV=py27
- TOXENV=py34
- TOXENV=cov

branches:
only:
- master
- develop
only:
- master
- develop

install: pip install --quiet --use-mirrors tox

script: tox

after_script:
- if [ $TOXENV == "cov" ]; then
pip install --quiet --use-mirrors coveralls;
coveralls;
fi
- if [ $TOXENV == "cov" ]; then
pip install --quiet --use-mirrors coveralls;
coveralls;
fi
19 changes: 17 additions & 2 deletions peewee_migrate/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,25 @@ def diff(self):

def run(self, name=None):
""" Run migrations. """

LOGGER.info('Start migrations')

migrator = Migrator(self.db)
if name:
return self.run_one(name, migrator)

for name in self.diff:
diff = self.diff
for name in diff:
self.run_one(name, migrator)

if not diff:
LOGGER.info('Nothing to migrate')

def run_one(self, name, migrator):
""" Run a migration. """

LOGGER.info('Run "%s"', name)

try:
with open(op.join(self.migrate_dir, name + '.py')) as f:
with self.db.transaction():
Expand All @@ -108,11 +118,16 @@ def run_one(self, name, migrator):
LOGGER.error(exc)

def create(self, name):
""" Create a migration. """

LOGGER.info('Create a migration "%s"', name)

num = len(self.fs_migrations)
prefix = '{:03}_'.format(num)
name = prefix + name + '.py'
copy(MIGRATE_TEMPLATE, op.join(self.migrate_dir, name))
LOGGER.info('Created: %s', name)

LOGGER.info('Migration has created %s', name)


class MigrateHistory(Model):
Expand Down
3 changes: 3 additions & 0 deletions peewee_migrate/migration.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
""" Migration template. """

from peewee import * # noqa


def migrate(migrator, database):
"""
Write your migrations here.
Expand Down
1 change: 0 additions & 1 deletion pylama.ini

This file was deleted.

21 changes: 21 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[tox]
envlist=py27,py34,cov

[pytest]
addopts = -x tests

[pylama]
ignore=D,C0111,C1001

[testenv]
commands=py.test
deps = -rrequirements-tests.txt

[testenv:cov]
deps =
coverage
{[testenv]deps}

commands =
coverage run -m py.test
coverage report

0 comments on commit 4f3e94a

Please sign in to comment.