etianen / django-watson

Full-text multi-table search application for Django. Easy to install and use, with good performance.
BSD 3-Clause "New" or "Revised" License
1.2k stars 130 forks source link

Added tox support #186

Closed amureki closed 7 years ago

amureki commented 7 years ago

Hello @etianen !

During sprints at https://www.djangounderthehood.com/ decided to work a bit on django-watson's test structure. So, as a first step, I've added support for tox (with flake8 checks) and fixed appeared flake8 warnings.

I think, somewhen next we can switch to pytest runner, it would be more handy.

amureki commented 7 years ago

I am also open for ideas and suggestions about travis+tox matrix, if you have any.

Please, don't hesitate to point me to the things, where I am wrong. :)

luzfcb commented 7 years ago

@amureki sample:

travis.yml

sudo: false
language:
  - python

matrix:
  include:
    - python: 2.7
      env:
        - TOX_ENV=py27-django110-postgres
    - python: 3.5
      env:
        - TOX_ENV=py35-django110-postgres

before_install:
    - mysql -e 'create database test_project'
    - psql -c 'create database test_project;' -U postgres

install:
    - pip install tox -U

script:
    - tox -e $TOX_ENV
luzfcb commented 7 years ago

perhaps to parse tox -l output, and generate the include section of .travis.yml. maybe there's some library that already do this.

amureki commented 7 years ago

@luzfcb thanks for suggestions, I've tried your variant with matrix with 3 python versions and different env variables each, but didn't work (https://travis-ci.org/etianen/django-watson/pull_requests).

So, I've switched back to my variant with splitting everything - I don't know, if it is possible to optimize this more, result time will be the same, I guess.

luzfcb commented 7 years ago

@amureki

travis-ci build example on: https://travis-ci.org/luzfcb/django-watson/builds/173884326

language: python
sudo: false
cache:
  directories:
    - $HOME/.cache/pip
matrix:
  include:
  - python: '2.7'
    env:
    - TOX_ENV=py27-django18-sqlite
  - python: '2.7'
    env:
    - TOX_ENV=py27-django18-postgres
  - python: '2.7'
    env:
    - TOX_ENV=py27-django18-mysql
  - python: '2.7'
    env:
    - TOX_ENV=py27-django19-sqlite
  - python: '2.7'
    env:
    - TOX_ENV=py27-django19-postgres
  - python: '2.7'
    env:
    - TOX_ENV=py27-django19-mysql
  - python: '2.7'
    env:
    - TOX_ENV=py27-django110-sqlite
  - python: '2.7'
    env:
    - TOX_ENV=py27-django110-postgres
  - python: '2.7'
    env:
    - TOX_ENV=py27-django110-mysql
  - python: '3.4'
    env:
    - TOX_ENV=py34-django18-sqlite
  - python: '3.4'
    env:
    - TOX_ENV=py34-django18-postgres
  - python: '3.4'
    env:
    - TOX_ENV=py34-django18-mysql
  - python: '3.4'
    env:
    - TOX_ENV=py34-django19-sqlite
  - python: '3.4'
    env:
    - TOX_ENV=py34-django19-postgres
  - python: '3.4'
    env:
    - TOX_ENV=py34-django19-mysql
  - python: '3.4'
    env:
    - TOX_ENV=py34-django110-sqlite
  - python: '3.4'
    env:
    - TOX_ENV=py34-django110-postgres
  - python: '3.4'
    env:
    - TOX_ENV=py34-django110-mysql
  - python: '3.5'
    env:
    - TOX_ENV=py35-django18-sqlite
  - python: '3.5'
    env:
    - TOX_ENV=py35-django18-postgres
  - python: '3.5'
    env:
    - TOX_ENV=py35-django18-mysql
  - python: '3.5'
    env:
    - TOX_ENV=py35-django19-sqlite
  - python: '3.5'
    env:
    - TOX_ENV=py35-django19-postgres
  - python: '3.5'
    env:
    - TOX_ENV=py35-django19-mysql
  - python: '3.5'
    env:
    - TOX_ENV=py35-django110-sqlite
  - python: '3.5'
    env:
    - TOX_ENV=py35-django110-postgres
  - python: '3.5'
    env:
    - TOX_ENV=py35-django110-mysql
  - python: '3.5'
    env:
    - TOX_ENV=flake8

services:
  - postgresql
  - mysql
install:
  - pip install tox
before_script:
  - mysql -e 'create database test_project'
  - psql -c 'create database test_project;' -U postgres
script: tox -e $TOX_ENV
notifications:
  email: false
luzfcb commented 7 years ago

I'm doing some experiments to create a helper tool to automatically generate test matrix (from tox to travis).

etianen commented 7 years ago

This is cool! Thanks! :)

Rather than generating a massive, unwieldy list of travis envs, how about we just lose the matrix entirely, and make the test command simply tox.

I know the theory of having Travis run all the tox envs in parallel is great, but this actually makes the build run slower, due to having to wait for so many build servers to start. When I switched from running tox in parallel to tox in serial for django-reversion, build time went from 17 minutes to 4 minutes!

https://travis-ci.org/etianen/django-reversion/builds

Plus, the travis file gets much simpler, and matches what the developer is running on their local machine.

amureki commented 7 years ago

@etianen @luzfcb thanks for comments and review! 👍 I'll update PR soon and ping you back.

amureki commented 7 years ago

@etianen @luzfcb so, I've moved part of changes from this PR to a separate one: https://github.com/etianen/django-watson/pull/187

Would be easier to check, since we are changing two different things.

etianen commented 7 years ago

This has now been merged in. Thanks for all the hard work.

@luzfcb - Thanks for your work reviewing this. Another pair of eyes is always good. :)