Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add github action for code style checks #31

Merged
merged 18 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/coding-style-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Coding Style Checks

on:
- push
- pull_request

jobs:
tox:
name: Coding Style Checks
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Test with tox
run: tox run-parallel -e flake,isort,black --parallel-no-spinner

25 changes: 25 additions & 0 deletions .github/workflows/unittests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Unittests

on:
- push
- pull_request

jobs:
tox:
name: Unittests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Test with tox
run: tox run-parallel --skip-env='^(flake|black|isort)$' --parallel-no-spinner
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ __pycache__/

# Unit test / coverage reports
.tox/
.flakeheaven_cache/
4 changes: 2 additions & 2 deletions anfema_django_testutils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Collection of various django related test utilities."""

__version__ = '0.6.0'
__version__ = "0.6.0"


def load_tests(loader, tests, pattern):
# Only consider tests within the tests folder. Otherwise the testcases module
# produces conflicts with the standard pattern.
return loader.discover(f'{__path__[0]}/tests', top_level_dir=__path__[0])
return loader.discover(f"{__path__[0]}/tests", top_level_dir=__path__[0])
4 changes: 2 additions & 2 deletions anfema_django_testutils/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ def _resolve_subtests_results(
{len(header)*"-"}
"""
)
+ self._exc_info_to_string(err, test)
+ 2 * '\n'
+ self._exc_info_to_string(err, test) # noqa: W503
+ 2 * '\n' # noqa: W503
)
result_priority = min(result_priority_map[result], result_priority)
result = reverse_result_priority_map[result_priority]
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ known_django = "django"
sections = ["FUTURE", "STDLIB", "DJANGO", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
lines_after_imports = 2

[tool.flake8]
max-line-length = 120
[tool.flakeheaven]
max_line_length = 120
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from setuptools import setup


setup()
14 changes: 10 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ minversion = 3.18
envlist =
py{39,310}-django32
py{39,310,311}-django{41,42}
flake8
flake
isort
black

Expand All @@ -18,12 +18,12 @@ setenv =
commands =
python -m unittest discover -s "{toxinidir}/tests"

[testenv:flake8]
[testenv:flake]
description = Checks the code for compliance with Flake8 coding standards.
basepython = python3.11
changedir = {toxinidir}
deps = flake8-pyproject
commands = flake8 anfema_django_testutils tests
deps = flakeheaven
commands = flakeheaven lint anfema_django_testutils tests

[testenv:isort]
description = Checks if imports are in the correct order and correctly formatted.
Expand All @@ -46,3 +46,9 @@ changedir = {toxinidir}
skip_install = true
deps = .[docs]
commands = sphinx-build -n -a -E docs/source {posargs:docs/build}

[gh-actions]
python =
3.9: py39
3.10: py310
3.11: py311, flake, black, isort