mirror of
https://github.com/jazzband/django-celery-monitor.git
synced 2026-03-16 22:00:24 +00:00
Migrate to GitHub Actions. (#137)
* Add initial GitHub test workflow. * Remove unneeded cache key. * Update tox config. * Stop testing Django 1.8 and 1.9. * Use pytest.mark.django_db differently * Reordering decorator? * Remove version restrictions. * Fix flake8 bugs. * Fix sphinx test. * More Sphinx fixes.
This commit is contained in:
parent
6ec13500d0
commit
aec77ca926
5 changed files with 72 additions and 24 deletions
48
.github/workflows/test.yml
vendored
Normal file
48
.github/workflows/test.yml
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
name: Test
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 5
|
||||
matrix:
|
||||
python-version: ['2.7', '3.5', '3.6']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Get pip cache dir
|
||||
id: pip-cache
|
||||
run: |
|
||||
echo "::set-output name=dir::$(pip cache dir)"
|
||||
|
||||
- name: Cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.pip-cache.outputs.dir }}
|
||||
key:
|
||||
${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.py') }}
|
||||
restore-keys: |
|
||||
${{ matrix.python-version }}-v1-
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install --upgrade tox tox-gh-actions
|
||||
|
||||
- name: Tox tests
|
||||
run: |
|
||||
tox -v
|
||||
|
||||
- name: Upload coverage
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
name: Python ${{ matrix.python-version }}
|
||||
|
|
@ -1,2 +1 @@
|
|||
pytest-cov==2.5.1
|
||||
codecov==2.0.11
|
||||
pytest-cov
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
case>=1.3.1
|
||||
pytest>=3.0
|
||||
pytest-django==3.1.2
|
||||
pytest-django
|
||||
pytz>dev
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ def Event(*args, **kwargs):
|
|||
return _Event(*args, **kwargs)
|
||||
|
||||
|
||||
@pytest.mark.django_db()
|
||||
@pytest.mark.usefixtures('depends_on_current_app')
|
||||
@pytest.mark.django_db
|
||||
class test_Camera:
|
||||
Camera = camera.Camera
|
||||
|
||||
|
|
@ -62,8 +62,9 @@ class test_Camera:
|
|||
worker.event('heartbeat', t, t, {})
|
||||
self.state.workers[worker.hostname] = worker
|
||||
assert (
|
||||
self.cam.get_heartbeat(worker) ==
|
||||
make_aware(datetime.fromtimestamp(t3))
|
||||
self.cam.get_heartbeat(worker) == make_aware(
|
||||
datetime.fromtimestamp(t3)
|
||||
)
|
||||
)
|
||||
|
||||
def test_handle_worker(self):
|
||||
|
|
@ -140,24 +141,28 @@ class test_Camera:
|
|||
task.event('received', tstamp, tstamp, {})
|
||||
mt = self.cam.handle_task((task.uuid, task))
|
||||
assert (
|
||||
mt.tstamp ==
|
||||
datetime(2016, 6, 1, 15, 0, 0, tzinfo=timezone.utc)
|
||||
mt.tstamp == datetime(
|
||||
2016, 6, 1, 15, 0, 0, tzinfo=timezone.utc
|
||||
)
|
||||
)
|
||||
assert (
|
||||
mt.eta ==
|
||||
datetime(2016, 6, 1, 15, 16, 17, 654321, tzinfo=timezone.utc)
|
||||
mt.eta == datetime(
|
||||
2016, 6, 1, 15, 16, 17, 654321, tzinfo=timezone.utc
|
||||
)
|
||||
)
|
||||
assert (
|
||||
mt.expires ==
|
||||
datetime(2016, 7, 1, 12, 16, 17, 765432, tzinfo=timezone.utc)
|
||||
mt.expires == datetime(
|
||||
2016, 7, 1, 12, 16, 17, 765432, tzinfo=timezone.utc
|
||||
)
|
||||
)
|
||||
|
||||
task = self.create_task(worker, eta='2016-06-04T15:16:17.654321')
|
||||
task.event('received', tstamp, tstamp, {})
|
||||
mt = self.cam.handle_task((task.uuid, task))
|
||||
assert (
|
||||
mt.eta ==
|
||||
datetime(2016, 6, 4, 15, 16, 17, 654321, tzinfo=timezone.utc)
|
||||
mt.eta == datetime(
|
||||
2016, 6, 4, 15, 16, 17, 654321, tzinfo=timezone.utc
|
||||
)
|
||||
)
|
||||
|
||||
with override_settings(USE_TZ=False, TIME_ZONE='Europe/Helsinki'):
|
||||
|
|
|
|||
16
tox.ini
16
tox.ini
|
|
@ -1,6 +1,6 @@
|
|||
[tox]
|
||||
envlist =
|
||||
tests-py{py,27,34,35}-dj{18,19,110}
|
||||
tests-py{py,27,35}-dj111
|
||||
tests-py36-dj111
|
||||
apicheck
|
||||
builddocs
|
||||
|
|
@ -10,12 +10,11 @@ envlist =
|
|||
pydocstyle
|
||||
readme
|
||||
|
||||
[travis]
|
||||
[gh-actions]
|
||||
python =
|
||||
2.7: py27, apicheck, builddocs, flake8, flakeplus, linkcheck, pydocstyle
|
||||
|
||||
[travis:after]
|
||||
travis = python: 3.5
|
||||
2.7: py27, flake8, flakeplus, pydocstyle
|
||||
3.5: py35
|
||||
3.6: py36, apicheck, builddocs, linkcheck
|
||||
|
||||
[testenv]
|
||||
sitepackages = False
|
||||
|
|
@ -24,16 +23,13 @@ deps=
|
|||
-r{toxinidir}/requirements/test.txt
|
||||
-r{toxinidir}/requirements/test-ci.txt
|
||||
|
||||
dj18: django>=1.8,<1.9
|
||||
dj19: django>=1.9,<1.10
|
||||
dj110: django>=1.10,<1.11
|
||||
dj111: django>=1.11,<2
|
||||
|
||||
apicheck,builddocs,linkcheck: -r{toxinidir}/requirements/docs.txt
|
||||
flake8,flakeplus,manifest,pydocstyle,readme: -r{toxinidir}/requirements/pkgutils.txt
|
||||
|
||||
commands =
|
||||
tests: py.test -xv --cov=django_celery_monitor --cov-report=term --cov-report=xml --no-cov-on-fail []
|
||||
tests: pytest -xv --cov=django_celery_monitor --cov-report=term --cov-report=xml --no-cov-on-fail []
|
||||
apicheck: sphinx-build -W -b apicheck -d {envtmpdir}/doctrees docs docs/_build/apicheck
|
||||
builddocs: sphinx-build -b html -d {envtmpdir}/doctrees docs {envtmpdir}/html
|
||||
flake8: flake8 {toxinidir}/django_celery_monitor {toxinidir}/tests
|
||||
|
|
|
|||
Loading…
Reference in a new issue