diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7fe0b00..21b4cc9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,10 +22,9 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9", "3.10", "3.11"] - # python-version: ['3.9'] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: shogo82148/actions-setup-redis@v1 with: @@ -33,11 +32,11 @@ jobs: - run: redis-cli ping - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: "16" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 28f7927..5303092 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,11 +10,11 @@ jobs: release: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v4 with: - python-version: "3.9" + python-version: "3.11" - uses: actions/setup-node@v2 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2917337..bcf9cd8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,23 +1,122 @@ +# Apply to all files without committing: +# pre-commit run --all-files +# Update this file: +# pre-commit autoupdate + repos: + # Code Upgrades + # - repo: https://github.com/asottile/pyupgrade + # rev: v3.17.0 + # hooks: + # - id: pyupgrade + # args: [--py38-plus] + - repo: https://github.com/adamchainz/django-upgrade + rev: 1.20.0 + hooks: + - id: django-upgrade + args: [--target-version=4.0] + # Code Logic + - repo: https://github.com/pycqa/isort + rev: 5.13.2 + hooks: + - id: isort + name: isort (python) + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.10.0 + hooks: + - id: python-check-mock-methods + - id: python-no-log-warn + - id: python-use-type-annotations + - id: text-unicode-replacement-char + # Formatting - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.6.0 hooks: + # Identify invalid files + - id: check-ast + - id: check-yaml + - id: check-json + - id: check-toml + - id: check-xml + # git checks + - id: check-merge-conflict + - id: check-added-large-files + args: [--maxkb=10000] + - id: detect-private-key + - id: check-case-conflict + # Python checks + # - id: check-docstring-first + - id: debug-statements + # - id: requirements-txt-fixer + - id: fix-encoding-pragma + args: [--remove] + - id: fix-byte-order-marker + # General quality checks + - id: mixed-line-ending + args: [--fix=lf] - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + exclude: | + (?x)( + \.min\.css| + \.min\.js| + \.po| + \.mo| + swagger\.json + ) + - id: check-executables-have-shebangs - id: end-of-file-fixer - exclude: \.min\.css$ - - repo: https://github.com/pre-commit/mirrors-autopep8 - rev: "v2.0.2" + exclude: | + (?x)( + \.min\.css| + \.min\.js| + \.po| + \.mo| + swagger\.json + ) + - repo: https://github.com/editorconfig-checker/editorconfig-checker.python + rev: 3.0.3 + hooks: + - id: editorconfig-checker + exclude: | + (?x)( + LICENSE| + allianceauth\/static\/allianceauth\/css\/themes\/bootstrap-locals.less| + \.po| + \.mo| + swagger\.json + ) + - repo: https://github.com/pycqa/flake8 + rev: 7.1.1 hooks: - - id: autopep8 + - id: flake8 + additional_dependencies: [Flake8-pyproject] + - repo: https://github.com/asottile/yesqa + rev: v1.5.0 + hooks: + - id: yesqa - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.0-alpha.9-for-vscode" + rev: "v4.0.0-alpha.8" hooks: - id: prettier additional_dependencies: - "prettier@2.7.1" - "@trivago/prettier-plugin-sort-imports@3.3.0" - - repo: https://github.com/pycqa/isort - rev: 5.12.0 + # Infrastructure + - repo: https://github.com/tox-dev/pyproject-fmt + rev: 2.2.1 hooks: - - id: isort - name: isort (python) + - id: pyproject-fmt + name: pyproject.toml formatter + description: "Format the pyproject.toml file." + args: + - --indent=4 + additional_dependencies: + - tox==4.18.0 # https://github.com/tox-dev/tox/releases/latest + + - repo: https://github.com/abravalheri/validate-pyproject + rev: v0.19 + hooks: + - id: validate-pyproject + name: Validate pyproject.toml + description: "Validate the pyproject.toml file." diff --git a/LICENCE b/LICENSE similarity index 100% rename from LICENCE rename to LICENSE diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 89530ee..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,7 +0,0 @@ -include LICENSE -include README.md -recursive-include authstats/templates * -recursive-include authstats/static *.* -recursive-include authstats/ *.py - -recursive-include frontend/build * diff --git a/Makefile b/Makefile index 49daa6f..fde8da3 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,8 @@ buildjs: package: cd frontend;yarn install;yarn build;find 'build/' -name '*.js' -exec sed -i -e 's/\/\/# sourceMappingURL=/\/\/# sourceMappingURL=\/static\/reports\/static\/js\//g' {} \; - python setup.py sdist + pip install flit + flit build devui: cd frontend;yarn install;yarn start diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..2a01d98 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,76 @@ +[build-system] +build-backend = "flit_core.buildapi" + +requires = [ "flit-core>=3.2,<4" ] + +[project] +name = "allianceauth-auth-stats" +readme = "README.md" +keywords = [ + "allianceauth", + "eveonline", +] +license = { file = "LICENSE" } +authors = [ + { name = "AaronKable", email = "aaronkable@gmail.com" }, +] +requires-python = ">=3.8" +classifiers = [ + "Environment :: Web Environment", + "Framework :: Celery", + "Framework :: Django", + "Framework :: Django :: 4.0", + "Framework :: Django :: 4.2", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Internet :: WWW/HTTP", + "Topic :: Internet :: WWW/HTTP :: Dynamic Content", +] +dynamic = [ "description", "version" ] +dependencies = [ + "allianceauth<5,>=3", + "django-ninja>=1.0.1,<2.0.0", + "django-solo>=2.1.0" +] + +urls.Homepage = "https://github.com/Solar-Helix-Independent-Transport/allianceauth-auth-stats" +urls.Source = "https://github.com/Solar-Helix-Independent-Transport/allianceauth-auth-stats" +urls.Tracker = "https://github.com/Solar-Helix-Independent-Transport/allianceauth-auth-stats/issues" + +[tool.flit.module] +name = "authstats" + +[tool.isort] +profile = "django" +sections = [ + "FUTURE", + "STDLIB", + "THIRDPARTY", + "DJANGO", + "ALLIANCEAUTH", + "FIRSTPARTY", + "LOCALFOLDER", +] +known_allianceauth = [ "allianceauth", "esi" ] +known_django = [ "django" ] +skip_gitignore = true + +[tool.flake8] +exclude = [ ".git", "*migrations*", ".tox", "dist", "htmlcov" ] +max-line-length = 119 +select = [ "C", "E", "F", "W", "B", "B950" ] +ignore = [ 'E203', 'E231', 'E501', 'W503', 'W291', 'W293' ] + +[tool.djlint] +max_attribute_length = 119 +max_line_length = 119 +max_blank_lines = 1 diff --git a/setup.py b/setup.py deleted file mode 100644 index 6469827..0000000 --- a/setup.py +++ /dev/null @@ -1,39 +0,0 @@ -import os - -from setuptools import find_packages, setup - -from authstats import __version__ - -install_requires = [ - 'django-ninja>=1.0.1,<2.0.0', - 'django-solo>=2.1.0' -] -with open(os.path.join(os.path.dirname(__file__), 'README.md')) as readme: - README = readme.read() -os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) - -setup( - name='allianceauth-auth-stats', - version=__version__, - packages=find_packages(), - include_package_data=True, - install_requires=install_requires, - license='MIT', - description='Alliance Auth Plugin', - long_description=README, - long_description_content_type="text/markdown", - url='https://github.com/pvyParts/allianceauth-corp-tools', - author='AaronKable', - author_email='aaronkable@gmail.com', - classifiers=[ - 'Development Status :: 4 - Beta', - 'Environment :: Web Environment', - 'Framework :: Django', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.6', - 'Topic :: Internet :: WWW/HTTP', - 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', - ], -) diff --git a/tests/test_settings.py b/tests/test_settingsAA3.py similarity index 98% rename from tests/test_settings.py rename to tests/test_settingsAA3.py index dd3f160..681efd9 100644 --- a/tests/test_settings.py +++ b/tests/test_settingsAA3.py @@ -2,7 +2,7 @@ Alliance Auth Test Suite Django settings. """ -from allianceauth.project_template.project_name.settings.base import * +from allianceauth.project_template.project_name.settings.base import * # noqa # Celery configuration CELERY_ALWAYS_EAGER = True # Forces celery to run locally for testing diff --git a/tests/test_settingsAA4.py b/tests/test_settingsAA4.py new file mode 100644 index 0000000..d5a8ede --- /dev/null +++ b/tests/test_settingsAA4.py @@ -0,0 +1,54 @@ +""" +Alliance Auth Test Suite Django settings. +""" + +from allianceauth.project_template.project_name.settings.base import * # noqa + +SITE_URL = "https://example.com" +CSRF_TRUSTED_ORIGINS = [SITE_URL] + +# Celery configuration +CELERY_ALWAYS_EAGER = True # Forces celery to run locally for testing + +INSTALLED_APPS += [ + 'authstats' +] + +ROOT_URLCONF = 'tests.urls' + +NOSE_ARGS = [ + # '--with-coverage', + # '--cover-package=', + # '--exe', # If your tests need this to be found/run, check they py files are not chmodded +x +] + + +PASSWORD_HASHERS = [ + 'django.contrib.auth.hashers.MD5PasswordHasher', +] + +# LOGGING = None # Comment out to enable logging for debugging + +# Register an application at https://developers.eveonline.com for Authentication +# & API Access and fill out these settings. Be sure to set the callback URL +# to https://example.com/sso/callback substituting your domain for example.com +# Logging in to auth requires the publicData scope (can be overridden through the +# LOGIN_TOKEN_SCOPES setting). Other apps may require more (see their docs). +ESI_SSO_CLIENT_ID = '123' +ESI_SSO_CLIENT_SECRET = '123' +ESI_SSO_CALLBACK_URL = '123' + +CACHES = { + "default": { + # "BACKEND": "redis_cache.RedisCache", + # "LOCATION": "localhost:6379", + # "OPTIONS": { + # "DB": 1, + # } + "BACKEND": "django_redis.cache.RedisCache", + "LOCATION": "redis://localhost:6379/1", + "OPTIONS": { + "COMPRESSOR": "django_redis.compressors.lzma.LzmaCompressor", + } + } +} diff --git a/tox.ini b/tox.ini index e4329e3..e2993e9 100644 --- a/tox.ini +++ b/tox.ini @@ -1,22 +1,23 @@ [tox] -skipsdist = False -usedevelop = True -envlist = py3 +isolated_build = true +skipsdist = true +usedevelop = true +envlist = django40, django42 [testenv] setenv = - DJANGO_SETTINGS_MODULE = tests.test_settings - -basepython = - py3: python3 - + django40: DJANGO_SETTINGS_MODULE = tests.test_settingsAA3 + django42: DJANGO_SETTINGS_MODULE = tests.test_settingsAA4 deps= + django40: allianceauth<4 + django42: allianceauth>=4.0.0 coverage - allianceauth -commands = - pip freeze - coverage run runtests.py - coverage report -m - coverage html +install_command = pip install -e ".[test]" -U {opts} {packages} + +commands= + coverage run runtests.py authstats -v 2 --debug-mode + pip list coverage xml + coverage html + coverage report -m