Skip to content

Commit

Permalink
ci: 馃懛 Separate linting and test environments
Browse files Browse the repository at this point in the history
  • Loading branch information
abhiabhi94 committed May 22, 2021
1 parent a1b7124 commit 7b09401
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 25 deletions.
68 changes: 60 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,55 @@ on:
- main

jobs:
build:

flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Ensure latest setuptools
run: |
python -m pip install --upgrade pip setuptools wheel
- name: Install dependencies
run: |
python -m pip install tox
- name: Run linting
run: |
python -m pip --version
python -m tox --version
python -m tox -e lint
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Ensure latest setuptools
run: |
python -m pip install --upgrade pip setuptools wheel
- name: Install dependencies
run: |
python -m pip install tox
- name: Build docs
run: |
python -m pip --version
python -m tox --version
python -m tox -e docs
tests:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
max-parallel: 5
Expand All @@ -26,12 +73,17 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade tox tox-py codecov
- name: Run tox targets for ${{ matrix.python-version }}
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox tox-gh-actions
- name: Tox tests
tox --py current
- name: Coverage reporting
run: |
tox
- name: Upload coverage
uses: codecov/codecov-action@v1
coverage combine
codecov
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dist
docs/_build

.tox
.coverage
.coverage*
coverage*

# editor files
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ To start development on this project, fork this repository and follow the follow
# activate the virtual environment(window users)
$ venv\Scripts\activate
# install dependencies
(venv) $ pip install -e . -r testapp/requirements.txt
(venv) $ pip install -e . Django -r testapp/requirements.txt
# migrate the migrations to the database
(venv) $ python manage.py migrate
# create data
Expand Down
8 changes: 6 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,18 @@ known_third_party = django, rest_framework

[coverage:run]
branch = true
source =
flag

[coverage:report]
show_missing = true
skip_covered = true

[tool:pytest]
django_find_project = false
addopts = -p no:doctest
--ds=testapp.settings
--reuse-db
--cov=flag
--cov-report term-missing:skip-covered

[build_sphinx]
source-dir = docs
Expand Down
4 changes: 1 addition & 3 deletions testapp/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
django
djangorestframework
flake8
tox
Pillow
pytest-django
pytest-cov
coverage
19 changes: 9 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ envlist =
py37-dj{21, 22, 30, 31, 32}
py38-dj{21, 22, 30, 31, 32, main}
py39-dj{21, 22, 30, 31, 32, main}
lint, docs

[gh-actions]
python =
Expand All @@ -19,13 +20,15 @@ deps =
commands =
python setup.py build_sphinx

[testenv]
[testenv:lint]
deps =
flake8
Pillow
djangorestframework
pytest-django
pytest-cov
commands =
flake8 flag tests testapp {posargs}

[testenv]
deps =
-rtestapp/requirements.txt
dj21: Django>=2.1,<2.2
dj22: Django>=2.2,<2.3
dj30: Django>=3.0,<3.1
Expand All @@ -36,10 +39,6 @@ deps =
usedevelop = True

commands =
python -m pip install --upgrade pip
flake8
python manage.py migrate
pytest --cov-report=xml

python -m coverage run --parallel-mode -m pytest {posargs}
setenv =
PYTHONDONTWRITEBYTECODE=1

0 comments on commit 7b09401

Please sign in to comment.