Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Commit f15c44e

Browse files
authored
Merge pull request #1056 from getsentry/tox-travis-refactor
Tox travis refactor
2 parents f2a613a + d4cadb0 commit f15c44e

File tree

26 files changed

+450
-172
lines changed

26 files changed

+450
-172
lines changed

.bandit.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tests:
2+
skips:
3+
- B404 # Ignore warnings about importing subprocess
4+
- B603 # Ignore warnings about calling subprocess.Popen without shell=True
5+
- B607 # Ignore warnings about calling subprocess.Popen without a full path to executable

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*.egg
44
*.db
55
*.pid
6+
.python-version
67
.coverage
78
.DS_Store
89
.tox
@@ -24,4 +25,4 @@ lib/
2425
.idea
2526
.eggs
2627
venv
27-
.vscode/tags
28+
.vscode/tags

.python-version-example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2.6.9
2+
2.7.13
3+
3.2.6
4+
3.3.6
5+
3.4.6
6+
3.5.3
7+
3.6.1
8+
pypy2.7-5.8.0

.travis.yml

Lines changed: 110 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,118 @@ addons:
77
cache:
88
directories:
99
- "$HOME/.cache/pip"
10-
#deploy:
11-
# provider: pypi
12-
# user: getsentry
13-
# password:
14-
# secure: NMwOI1H9arp2vbgaidx9OY6y8990hiu0WsHtowEvEdGKXNzAQcy0sW3SoKcB6FN0bk11xhj49+5C++KAwMYwE/SL8Y5OoZ1/iYVI4/XlWNukr+1/pfPKVMgw3v5W+pL5Ba9TBdFfIoFPNYUDPLItSSjg94Bm95034gBkYWC5Hl0=
15-
# on:
16-
# tags: true
10+
11+
12+
jobs:
13+
fast_finish: true
14+
# allow_failures:
15+
# - python: 3.5
16+
# env: TOXENV=py35-django-dev-fix
17+
18+
include:
19+
- stage: core
20+
python: 2.7
21+
env: TOXENV=py27
22+
- stage: core
23+
python: 3.3
24+
env: TOXENV=py33
25+
- stage: core
26+
python: 3.4
27+
env: TOXENV=py34
28+
- stage: core
29+
python: 3.5
30+
env: TOXENV=py35
31+
- stage: core
32+
python: pypy
33+
env: TOXENV=pypy
34+
- stage: core
35+
python: 3.5
36+
env: TOXENV=flake8
37+
38+
39+
- stage: contrib
40+
python: 2.7
41+
env: TOXENV=py27-django-16
42+
- stage: contrib
43+
python: 2.7
44+
env: TOXENV=py27-django-17
45+
- stage: contrib
46+
python: 2.7
47+
env: TOXENV=py27-django-18
48+
- stage: contrib
49+
python: 2.7
50+
env: TOXENV=py27-django-19
51+
- stage: contrib
52+
python: 2.7
53+
env: TOXENV=py27-django-110
54+
55+
56+
- stage: contrib
57+
python: 3.3
58+
env: TOXENV=py33-django-17
59+
- stage: contrib
60+
python: 3.3
61+
env: TOXENV=py33-django-18
62+
63+
- stage: contrib
64+
python: 3.4
65+
env: TOXENV=py34-django-17
66+
- stage: contrib
67+
python: 3.4
68+
env: TOXENV=py34-django-18
69+
- stage: contrib
70+
python: 3.4
71+
env: TOXENV=py34-django-19
72+
- stage: contrib
73+
python: 3.4
74+
env: TOXENV=py34-django-110
75+
76+
- stage: contrib
77+
python: 3.5
78+
env: TOXENV=py35-django-18
79+
- stage: contrib
80+
python: 3.5
81+
env: TOXENV=py35-django-19
82+
- stage: contrib
83+
python: 3.5
84+
env: TOXENV=py35-django-110
85+
- stage: contrib
86+
python: 3.5
87+
env: TOXENV=py35-django-111-fix
88+
# - stage: contrib
89+
# python: 3.5
90+
# env: TOXENV=py35-django-dev-fix
91+
92+
- stage: contrib
93+
python: 2.7
94+
env: TOXENV=py27-flask-10
95+
- stage: contrib
96+
python: 2.7
97+
env: TOXENV=py27-flask-11
98+
- stage: contrib
99+
python: 3.5
100+
env: TOXENV=py35-flask-10
101+
- stage: contrib
102+
python: 3.5
103+
env: TOXENV=py35-flask-11
104+
- stage: contrib
105+
python: 3.5
106+
env: TOXENV=py35-flask-12
107+
108+
- stage: contrib
109+
python: 2.7
110+
env: TOXENV=py27-celery-3
111+
- stage: contrib
112+
python: 2.7
113+
env: TOXENV=py27-celery-4
114+
115+
116+
script: tox
17117
install:
18-
- time ci/setup
19-
- pip install codecov "coverage<4"
118+
- pip install tox wheel codecov "coverage<4"
20119
before_script:
21120
- pip freeze
22-
script:
23-
- if [[ ${TRAVIS_PYTHON_VERSION} != 'pypy' ]]; then make lint; fi
24-
- time ci/test
25121
after_success:
26122
- codecov -e DJANGO
27-
matrix:
28-
fast_finish: true
29-
allow_failures:
30-
- python: 3.5
31-
env: DJANGO=dev TEST_SUITE=django
32-
include:
33-
- python: 2.7
34-
env: FLASK=0.10.1 TEST_SUITE=flask
35-
- python: 2.7
36-
env: FLASK=0.11.1 TEST_SUITE=flask
37-
- python: 2.7
38-
env: DJANGO=1.6.11 TEST_SUITE=django
39-
- python: 2.7
40-
env: DJANGO=1.8.7 TEST_SUITE=django
41-
- python: 2.7
42-
env: DJANGO=1.9 TEST_SUITE=django
43-
- python: 2.7
44-
env: DJANGO=1.10 TEST_SUITE=django
45-
- python: 2.7
46-
env: DJANGO=1.11 TEST_SUITE=django
47-
- python: 3.5
48-
env: DJANGO=1.10 TEST_SUITE=django
49-
- python: 3.5
50-
env: DJANGO=1.11 TEST_SUITE=django
51-
- python: 3.5
52-
env: DJANGO=dev TEST_SUITE=django
53-
- python: 2.7
54-
env: CELERY=3.1 TEST_SUITE=celery
55-
- python: 2.7
56-
env: CELERY=4.0 TEST_SUITE=celery
57-
- python: 3.3
58-
- python: 3.4
59-
- python: 3.5
123+
124+

conftest.py

Lines changed: 13 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -33,74 +33,14 @@
3333
collect_ignore.append('tests/contrib/django/test_tastypie.py')
3434

3535

36-
INSTALLED_APPS = [
37-
'django.contrib.auth',
38-
'django.contrib.contenttypes',
39-
'django.contrib.sessions',
40-
'django.contrib.sites',
41-
42-
'raven.contrib.django',
43-
'tests.contrib.django',
44-
]
45-
46-
4736
use_djcelery = True
4837
try:
4938
import djcelery # NOQA
50-
INSTALLED_APPS.append('djcelery')
39+
#INSTALLED_APPS.append('djcelery')
5140
except ImportError:
5241
use_djcelery = False
5342

5443

55-
def configure_django(project_root):
56-
from django.conf import settings
57-
58-
settings.configure(
59-
DATABASE_ENGINE='sqlite3',
60-
DATABASES={
61-
'default': {
62-
'NAME': ':memory:',
63-
'ENGINE': 'django.db.backends.sqlite3',
64-
'TEST_NAME': ':memory:',
65-
},
66-
},
67-
DATABASE_NAME=':memory:',
68-
TEST_DATABASE_NAME=':memory:',
69-
INSTALLED_APPS=INSTALLED_APPS,
70-
ROOT_URLCONF='tests.contrib.django.urls',
71-
DEBUG=False,
72-
SITE_ID=1,
73-
BROKER_HOST="localhost",
74-
BROKER_PORT=5672,
75-
BROKER_USER="guest",
76-
BROKER_PASSWORD="guest",
77-
BROKER_VHOST="/",
78-
SENTRY_ALLOW_ORIGIN='*',
79-
CELERY_ALWAYS_EAGER=True,
80-
TEMPLATE_DEBUG=True,
81-
LANGUAGE_CODE='en',
82-
LANGUAGES=(('en', 'English'),),
83-
TEMPLATE_DIRS=[
84-
os.path.join(project_root, 'tests', 'contrib', 'django', 'templates'),
85-
],
86-
TEMPLATES=[{
87-
'BACKEND': 'django.template.backends.django.DjangoTemplates',
88-
'APP_DIRS': True,
89-
'DIRS': [
90-
os.path.join(project_root, 'tests', 'contrib', 'django', 'templates'),
91-
],
92-
}],
93-
ALLOWED_HOSTS=['*'],
94-
DISABLE_SENTRY_INSTRUMENTATION=True,
95-
SENTRY_CLIENT='tests.contrib.django.tests.MockClient'
96-
)
97-
98-
99-
def pytest_configure(config):
100-
if django:
101-
configure_django(os.path.dirname(os.path.abspath(__file__)))
102-
103-
10444
def pytest_runtest_teardown(item):
10545
if django:
10646
from raven.contrib.django.models import client
@@ -110,3 +50,15 @@ def pytest_runtest_teardown(item):
11050
@pytest.fixture
11151
def project_root():
11252
return os.path.dirname(os.path.abspath(__file__))
53+
54+
55+
@pytest.fixture
56+
def mytest_model():
57+
58+
from tests.contrib.django.models import MyTestModel
59+
return MyTestModel
60+
61+
62+
@pytest.fixture(scope='function', autouse=False)
63+
def user_instance(request, admin_user):
64+
request.cls.user = admin_user

docs/contributing.rst

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,67 @@ Contributing
44
Want to contribute back to Sentry? This page describes the general development flow,
55
our philosophy, the test suite, and issue tracking.
66

7-
(Though it actually doesn't describe all of that, yet)
7+
There are many ways to you can help, either by submitting bug reports, improving the
8+
documentation, or submitting a patch. This document describes how to get the
9+
test suite running for the Python SDK.
810

911
Setting up an Environment
1012
-------------------------
1113

12-
Sentry is designed to run off of setuptools with minimal work. Because of this
13-
setting up a development environment requires only a few steps.
14+
There are several ways of setting up a development environment. If you want to ensure
15+
your changes work across all environments and integrations that Raven supports,
16+
the easiest way to run one or more jobs from test suite matrix is using a virtualenv
17+
management and test command line tool called `Tox`_,
1418

15-
The first thing you're going to want to do, is build a virtualenv and install
16-
any base dependancies.
19+
It is also recommended to have the Python versions you are targeting installed on your
20+
system. There are several tools that help you manage several Python installations,
21+
like `Pyenv`_ or `Pythonz`_, but you can also install them manually by downloading them
22+
from the Python.org website or installing them from repositories depending on your
23+
operating system.
1724

18-
::
25+
Once you have the Python versions you are going to work with, you have to install `Tox`.
26+
The easiest way of installing `Tox` is by running `pip install tox` into your
27+
default Python installation.
1928

20-
virtualenv ~/.virtualenvs/raven
21-
source ~/.virtualenvs/raven/bin/activate
22-
make
29+
Running the tests
30+
-----------------
2331

24-
That's it :)
32+
Running the tests is easy: just run `tox` from the command line and it will take care of
33+
creating all the necessary virtualenvs and running all the environments defined in the `tox.ini`
34+
file.
2535

26-
Running the Test Suite
27-
----------------------
36+
During development you might want to run only a certain environment, which can be done by
37+
passing the `-e ENV` to tox, for example:
2838

29-
The test suite is also powered off of py.test, and can be run in a number of ways. Usually though,
30-
you'll just want to use our helper method to make things easy:
39+
.. code-block:: bash
3140
32-
::
41+
$ tox -e py35-django19
3342
34-
make test
43+
which would run the Python3.5 environment and the Django integration tests with Django 1.9.
44+
You can list all the defined environments with `tox --listenvs`, or fall into the Python debugger
45+
on any raised exception by using `tox --pdb`. Please refer to the Tox Documentation for additional
46+
information.
3547

3648

3749
Contributing Back Code
3850
----------------------
3951

40-
Ideally all patches should be sent as a pull request on GitHub, and include tests. If you're fixing a bug or making a large change the patch **must** include test coverage.
52+
Ideally all patches should be sent as a pull request on GitHub, and include tests.
53+
If you're fixing a bug or making a large change the patch **must** include test coverage.
54+
55+
You can see a list of open pull requests (pending changes) by visiting our `Github Pull Request` page.
56+
Every pull requests triggers a test build on our Travis CI where you can verify that
57+
all tests pass.
58+
59+
Notes
60+
-----
61+
62+
In order to use Pyenv with Tox, create a `.python-version` file similar to the
63+
`.python-version-example` in the project root.
64+
4165

42-
You can see a list of open pull requests (pending changes) by visiting https://github.com/getsentry/raven-python/pulls
66+
.. _Sentry: https://getsentry.com
67+
.. _Github Pull Request: https://github.com/getsentry/raven-python/pulls
68+
.. _Tox: https://tox.readthedocs.io
69+
.. _Pythonz: https://github.com/saghul/pythonz
70+
.. _Pyenv: https://github.com/pyenv/pyenv

0 commit comments

Comments
 (0)