From b2377e9551e780eaa6500c40f1cd704e3212a90c Mon Sep 17 00:00:00 2001 From: Jens Diemer Date: Tue, 4 Apr 2023 14:21:04 +0200 Subject: [PATCH 1/2] Update project meta --- .editorconfig | 4 ++-- .flake8 | 2 +- .github/workflows/package_linter.yml | 18 ++++++++++++------ .github/workflows/pytest.yml | 20 +++++++++++++++----- .gitignore | 4 +--- conf/settings.py | 11 +++++++++-- manifest.json | 2 +- pyproject.toml | 14 ++++++++++---- tests/test_project_setup.py | 15 +++++++++++++++ 9 files changed, 66 insertions(+), 24 deletions(-) diff --git a/.editorconfig b/.editorconfig index 919380f..8d23451 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,4 +1,4 @@ -# see http://editorconfig.org +# see https://editorconfig.org root = true [*] @@ -17,4 +17,4 @@ indent_style = tab insert_final_newline = false [*.yml] -indent_style = tab +indent_size = 2 diff --git a/.flake8 b/.flake8 index d6aa99e..5dccc60 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ # -# Move to pyproject.toml after: https://gitlab.com/pycqa/flake8/-/issues/428 +# Move to pyproject.toml after: https://github.com/PyCQA/flake8/issues/234 # [flake8] exclude = .*, dist, htmlcov, local_test diff --git a/.github/workflows/package_linter.yml b/.github/workflows/package_linter.yml index 431ff51..e3b0907 100644 --- a/.github/workflows/package_linter.yml +++ b/.github/workflows/package_linter.yml @@ -1,6 +1,8 @@ name: YunoHost apps package linter on: + # Allow to manually trigger the workflow + workflow_dispatch: push: branches: - main @@ -12,21 +14,25 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + # https://github.com/marketplace/actions/checkout + with: + fetch-depth: 0 - - uses: actions/cache@v2 + - uses: actions/cache@v3 + # https://github.com/marketplace/actions/cache with: path: ~/.cache/ key: dot-cache-files + - name: 'Install dependencies' + run: | + pip install toml + - name: 'Clone YunoHost apps package linter' run: | git clone --depth=1 https://github.com/YunoHost/package_linter ~/package_linter - - name: 'Install requirements' - run: | - pip3 install toml - - name: 'Run linter' run: | ~/package_linter/package_linter.py . diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 1092f82..9d68740 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -1,6 +1,8 @@ name: pytest on: + # Allow to manually trigger the workflow + workflow_dispatch: push: branches: - master @@ -12,22 +14,29 @@ jobs: test: runs-on: ubuntu-latest strategy: - max-parallel: 2 matrix: python-version: ["3.11", "3.10", "3.9"] + env: + PYTHONUNBUFFERED: 1 + PYTHONWARNINGS: always steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + # https://github.com/marketplace/actions/checkout with: fetch-depth: 0 - - name: 'fetch master' + + - name: 'fetch master and testing (for Darker/Black)' run: | git fetch origin master + git fetch origin testing + - name: 'Set up Python ${{ matrix.python-version }}' uses: actions/setup-python@v2 with: python-version: '${{ matrix.python-version }}' - - uses: actions/cache@v2 + - uses: actions/cache@v3 + # https://github.com/marketplace/actions/cache with: path: ~/.cache/ key: dot-cache-files @@ -50,7 +59,8 @@ jobs: make safety - name: 'Upload coverage report' - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v3 + # https://github.com/marketplace/actions/codecov with: fail_ci_if_error: false verbose: true diff --git a/.gitignore b/.gitignore index 7a45778..e6e4e51 100644 --- a/.gitignore +++ b/.gitignore @@ -3,12 +3,10 @@ !.editorconfig !.flake8 !.gitignore -!.safety-policy.yml - !/doc/screenshots/.gitkeep - __pycache__ secret.txt /local_test/ +/coverage.json /coverage.xml /htmlcov/ diff --git a/conf/settings.py b/conf/settings.py index 5dd8ea9..452ec1d 100644 --- a/conf/settings.py +++ b/conf/settings.py @@ -54,15 +54,22 @@ YNH_SETUP_USER = 'setup_user.setup_project_user' SECRET_KEY = __get_or_create_secret(FINALPATH / 'secret.txt') # /opt/yunohost/$app/secret.txt + +if 'axes' not in INSTALLED_APPS: + INSTALLED_APPS.append('axes') # https://github.com/jazzband/django-axes + INSTALLED_APPS.append('django_yunohost_integration.apps.YunohostIntegrationConfig') + MIDDLEWARE.insert( MIDDLEWARE.index('django.contrib.auth.middleware.AuthenticationMiddleware') + 1, # login a user via HTTP_REMOTE_USER header from SSOwat: 'django_yunohost_integration.sso_auth.auth_middleware.SSOwatRemoteUserMiddleware', ) -# AxesMiddleware should be the last middleware: -MIDDLEWARE.append('axes.middleware.AxesMiddleware') +if 'axes.middleware.AxesMiddleware' not in MIDDLEWARE: + # AxesMiddleware should be the last middleware: + MIDDLEWARE.append('axes.middleware.AxesMiddleware') + # Keep ModelBackend around for per-user permissions and superuser AUTHENTICATION_BACKENDS = ( diff --git a/manifest.json b/manifest.json index c7088ea..50bc711 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "Store your GPX tracks of your running (or other sports activity)" }, - "version": "0.17.3~ynh2", + "version": "0.17.3~ynh3", "url": "https://github.com/jedie/django-for-runners", "upstream": { "license": "GPL-3.0", diff --git a/pyproject.toml b/pyproject.toml index 3b89557..a413bd7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "for_runners_ynh" -version = "0.17.3+ynh2" +version = "0.17.3+ynh3" description = "YunoHost app package for https://github.com/jedie/django-for-runners" authors = ["Jens Diemer "] homepage = "https://github.com/YunoHost-Apps/django-for-runners_ynh" @@ -8,7 +8,7 @@ license = "GPL-3.0-or-later" readme = 'README.md' [tool.poetry.urls] -"Bug Tracker" = "https://github.com/YunoHost-Apps/django-for-runners_ynh/issues" +"Bug Tracker" = "https://github.com/jedie/django-for-runners/issues" [tool.poetry.dependencies] python = ">=3.9,<4.0.0" # Stay with 3.9 until YunoHost used >=Debian 11 (Bullseye) @@ -149,6 +149,9 @@ initial_revision = "2281f4b" initial_date = 2023-04-02T17:40:58+02:00 cookiecutter_template = "https://github.com/jedie/cookiecutter_templates/" cookiecutter_directory = "yunohost_django_package" +applied_migrations = [ + "183124a", # 2023-04-04T12:26:15+02:00 +] [manageprojects.cookiecutter_context.cookiecutter] project_name = "django-for-runners" @@ -157,11 +160,14 @@ github_username = "jedie" author_email = "git@jensdiemer.de" upstream_pkg_name = "django_for_runners" upstream_url = "https://github.com/jedie/django-for-runners" +upstream_pkg_app_name = "for_runners" +upstream_pkg_project_name = "for_runners_project" ynh_app_pkg_name = "for_runners_ynh" ynh_app_url = "https://github.com/YunoHost-Apps/django-for-runners_ynh" bug_tracker_url = "https://github.com/jedie/django-for-runners/issues" -upstream_version = "0.0.1" -ynh_version = "1" +upstream_version = "0.17.3" +ynh_version = "+ynh3" package_description = "YunoHost app package for https://github.com/jedie/django-for-runners" license = "GPL-3.0-or-later" _template = "https://github.com/jedie/cookiecutter_templates/" + diff --git a/tests/test_project_setup.py b/tests/test_project_setup.py index f3b852c..a7df246 100644 --- a/tests/test_project_setup.py +++ b/tests/test_project_setup.py @@ -3,6 +3,7 @@ import os import shutil import subprocess from pathlib import Path +from unittest import TestCase try: @@ -140,3 +141,17 @@ def test_check_code_style(): _call_make('lint') except subprocess.CalledProcessError as err: raise AssertionError(f'Linting error:\n{"-"*100}\n{err.stdout}\n{"-"*100}') + + +class ConfigPanelTestCase(TestCase): + def test_config_panel_toml(self): + config_panel_path = PACKAGE_ROOT / 'config_panel.toml' + assert_is_file(config_panel_path) + + cfg = tomllib.loads(config_panel_path.read_text(encoding='UTF-8')) + + self.assertEqual(cfg['version'], '1.0') + self.assertEqual( + set(cfg['main']['config'].keys()), + {'name', 'default_from_email', 'admin_email', 'debug_enabled', 'log_level'}, + ) From 4da87e8fd5cdc65653adb0cd57626c3feb0946bb Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 4 Apr 2023 12:26:41 +0000 Subject: [PATCH 2/2] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2a0ce1b..91c6de2 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ This package for YunoHost used [django-yunohost-integration](https://github.com/ More screenshots are here: [jedie.github.io/tree/master/screenshots/django-for-runners](https://github.com/jedie/jedie.github.io/tree/master/screenshots/django-for-runners/README.creole) -**Shipped version:** 0.17.3~ynh2 +**Shipped version:** 0.17.3~ynh3 ## Screenshots diff --git a/README_fr.md b/README_fr.md index 9b5bc86..34c9ecc 100644 --- a/README_fr.md +++ b/README_fr.md @@ -34,7 +34,7 @@ This package for YunoHost used [django-yunohost-integration](https://github.com/ More screenshots are here: [jedie.github.io/tree/master/screenshots/django-for-runners](https://github.com/jedie/jedie.github.io/tree/master/screenshots/django-for-runners/README.creole) -**Version incluse :** 0.17.3~ynh2 +**Version incluse :** 0.17.3~ynh3 ## Captures d’écran