From a69fc2ac4bb9f0c931d2778168240813418468f7 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 10 Aug 2023 16:01:40 -0400 Subject: [PATCH] fix precommit yaml --- .github/workflows/codeql-analysis.yml | 6 +-- .pre-commit-config.yaml | 41 ++++++++++++------ Dockerfile | 14 +++--- catalog/templates/game.html | 2 +- common/static/img/fediverse.svg | 2 +- doc/catalog.md | 1 - doc/install.md | 8 ++-- docker/entrypoint.sh | 8 ++-- docker/start.sh | 55 ++++++++++++------------ requirements-dev.txt | 6 +-- requirements.txt | 62 +++++++++++++-------------- 11 files changed, 109 insertions(+), 96 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 429d462e..c95ba1fe 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -48,11 +48,11 @@ jobs: # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. - + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs # queries: security-extended,security-and-quality - + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild @@ -61,7 +61,7 @@ jobs: # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # If the Autobuild fails above, remove it and uncomment the following three lines. + # If the Autobuild fails above, remove it and uncomment the following three lines. # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. # - run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7f5a1d36..aa88b952 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,24 +1,39 @@ +exclude: ^test_data/ repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.3.0 + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 hooks: - id: check-yaml + - id: check-json + - id: check-xml + - id: check-toml + - id: check-symlinks + - id: check-added-large-files + args: [--maxkb=1024] + - id: detect-private-key + - id: end-of-file-fixer + - id: fix-byte-order-marker + - id: debug-statements + - id: check-merge-conflict - id: end-of-file-fixer - id: trailing-whitespace -- repo: https://github.com/psf/black - rev: 22.12.0 - hooks: - - id: black - language_version: python3.11 -repos: - - repo: https://github.com/Riverside-Healthcare/djLint - rev: v1.32.1 - hooks: - - id: djlint-reformat-django - - id: djlint-django + - id: requirements-txt-fixer + - id: mixed-line-ending - repo: https://github.com/pycqa/isort rev: 5.12.0 hooks: - id: isort args: ["--profile=black"] + + - repo: https://github.com/psf/black + rev: 22.12.0 + hooks: + - id: black + language_version: python3.11 + + - repo: https://github.com/Riverside-Healthcare/djLint + rev: v1.32.1 + hooks: + - id: djlint-reformat-django + - id: djlint-django diff --git a/Dockerfile b/Dockerfile index 5115d87f..96162a1c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,13 +2,13 @@ FROM python:3.8-slim ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 -RUN apt-get update \ - && apt-get install -y --no-install-recommends build-essential libpq-dev git \ +RUN apt-get update \ + && apt-get install -y --no-install-recommends build-essential libpq-dev git \ && rm -rf /var/lib/apt/lists/* COPY requirements.txt /tmp/requirements.txt -RUN pip install --no-cache-dir -r /tmp/requirements.txt \ - && rm -rf /tmp/requirements.txt \ - && useradd -U app_user \ +RUN pip install --no-cache-dir -r /tmp/requirements.txt \ + && rm -rf /tmp/requirements.txt \ + && useradd -U app_user \ && install -d -m 0755 -o app_user -g app_user /app/static ENV DJANGO_SETTINGS_MODULE=yoursettings.dev @@ -17,7 +17,7 @@ USER app_user:app_user COPY --chown=app_user:app_user . . RUN chmod +x docker/*.sh -# Section 6- Docker Run Checks and Configurations +# Section 6- Docker Run Checks and Configurations ENTRYPOINT [ "docker/entrypoint.sh" ] -CMD [ "docker/start.sh", "server" ] \ No newline at end of file +CMD [ "docker/start.sh", "server" ] diff --git a/catalog/templates/game.html b/catalog/templates/game.html index 2f97ad61..039730c0 100644 --- a/catalog/templates/game.html +++ b/catalog/templates/game.html @@ -29,7 +29,7 @@ }); $(this).remove(); }) - + {% endif %} {% endif %} diff --git a/common/static/img/fediverse.svg b/common/static/img/fediverse.svg index c3ab108c..707d6fda 100644 --- a/common/static/img/fediverse.svg +++ b/common/static/img/fediverse.svg @@ -2,4 +2,4 @@ - \ No newline at end of file + diff --git a/doc/catalog.md b/doc/catalog.md index e8996226..83cc7e41 100644 --- a/doc/catalog.md +++ b/doc/catalog.md @@ -112,4 +112,3 @@ Add a new site - Command: `python3 manage.py test [--keepdb]`. More detailed for `test`, please check [this doc](https://github.com/neodb-social/neodb/blob/main/doc/development.md#run-test) - See [this issue](https://github.com/neodb-social/neodb/issues/5) if `lxml.etree.ParserError` occurs on macOS. - add a site UI label to `common/static/scss/_sitelabel.scss` - diff --git a/doc/install.md b/doc/install.md index 0243f1c6..917cbf03 100644 --- a/doc/install.md +++ b/doc/install.md @@ -42,7 +42,7 @@ SECRET_KEY = "my_key" The most important configurations to setup are: -- `MASTODON_ALLOW_ANY_SITE` set to `True` so that user can login via any Mastodon API compatible sites (e.g. Mastodon/Pleroma) +- `MASTODON_ALLOW_ANY_SITE` set to `True` so that user can login via any Mastodon API compatible sites (e.g. Mastodon/Pleroma) - `REDIRECT_URIS` should be `SITE_INFO["site_url"] + "/account/login/oauth"`. If you want to run **on local**, `SITE_INFO["site_url"]` should be set to `"http://localhost/"` More details on `settings.py` in [configuration.md](configuration.md) @@ -89,7 +89,7 @@ python3 manage.py runserver It should be ready to serve from here, to run web server for production, consider `gunicorn -w 8 boofilsic.wsgi` in systemd or sth similar -3 Migrate from an earlier version +3 Migrate from an earlier version ------------------------------- Update database ``` @@ -145,9 +145,9 @@ python3 manage.py createapplication --client-id NEODB_DEVELOPER_CONSOLE --skip-a ### I got Error: “无效įš„į™ģåŊ•å›žč°ƒåœ°å€â€. -Check `REDIRECT_URIS` in `settings.py`, the final value should be `"http://localhost/account/login/oauth"` or sth similar. If you are specifying a port, add the port to the localhost address. +Check `REDIRECT_URIS` in `settings.py`, the final value should be `"http://localhost/account/login/oauth"` or sth similar. If you are specifying a port, add the port to the localhost address. -If any change was made to `REDIRECT_URIS`, existing apps registered in Mastodon are no longer valid, so delete the app record in the database: +If any change was made to `REDIRECT_URIS`, existing apps registered in Mastodon are no longer valid, so delete the app record in the database: ``` delete from mastodon_mastodonapplication; ``` diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 5feb0354..a6bcc670 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,12 +1,12 @@ #!/bin/bash -set -o errexit -set -o pipefail +set -o errexit +set -o pipefail set -o nounset -python manage.py collectstatic --noinput +python manage.py collectstatic --noinput python manage.py makemigrations users books movies games music sync mastodon management collection -python manage.py makemigrations +python manage.py makemigrations python manage.py migrate users python manage.py migrate diff --git a/docker/start.sh b/docker/start.sh index a54a76c7..1f30402e 100755 --- a/docker/start.sh +++ b/docker/start.sh @@ -1,36 +1,35 @@ -#!/bin/bash +#!/bin/bash -cd /app +cd /app -if [ $# -eq 0 ]; then - echo "Usage: start.sh " - exit 1 -fi +if [ $# -eq 0 ]; then + echo "Usage: start.sh " + exit 1 +fi -PROCESS_TYPE=$1 +PROCESS_TYPE=$1 -if [ "$PROCESS_TYPE" = "server" ]; then - if [ "$DJANGO_DEBUG" = "true" ]; then - gunicorn \ - --reload \ - --bind 0.0.0.0:8000 \ - --workers 2 \ - --worker-class eventlet \ - --log-level DEBUG \ - --access-logfile "-" \ - --error-logfile "-" \ - boofilsic.wsgi - else - gunicorn \ - --bind 0.0.0.0:8000 \ - --workers 2 \ - --worker-class eventlet \ - --log-level DEBUG \ - --access-logfile "-" \ - --error-logfile "-" \ +if [ "$PROCESS_TYPE" = "server" ]; then + if [ "$DJANGO_DEBUG" = "true" ]; then + gunicorn \ + --reload \ + --bind 0.0.0.0:8000 \ + --workers 2 \ + --worker-class eventlet \ + --log-level DEBUG \ + --access-logfile "-" \ + --error-logfile "-" \ boofilsic.wsgi - fi + else + gunicorn \ + --bind 0.0.0.0:8000 \ + --workers 2 \ + --worker-class eventlet \ + --log-level DEBUG \ + --access-logfile "-" \ + --error-logfile "-" \ + boofilsic.wsgi + fi elif [ "$PROCESS_TYPE" = "rq" ]; then rqworker --with-scheduler doufen export mastodon fi - diff --git a/requirements-dev.txt b/requirements-dev.txt index d8a6dce4..13ea78cc 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,8 +1,8 @@ -pre-commit~=3.3.3 -isort~=5.12.0 black~=22.12.0 -django-debug-toolbar coverage +django-debug-toolbar djlint~=1.32.1 +isort~=5.12.0 +pre-commit~=3.3.3 types-dateparser types-tqdm diff --git a/requirements.txt b/requirements.txt index 27070c2d..c24b2e6a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,42 +1,42 @@ dateparser -mistune -rq>=1.12.0 +discord.py django~=4.2.4 -django-auditlog -django-markdownx @ git+https://github.com/alphatownsman/django-markdownx.git@e69480c64ad9c5d0499f4a8625da78cf2bb7691b -django-jsonform -libsass -django-compressor -django-sass-processor -django-rq -django-simple-history # no longer used but kept for migration code which is used by tests -django-auditlog @ git+https://github.com/jazzband/django-auditlog.git@45591463e8192b4ac0095e259cc4dcea0ac2fd6c -django-hijack -django-user-messages -django-slack -django-ninja -django-polymorphic -django-maintenance-mode -django-tz-detect -django-bleach -django-redis -django-oauth-toolkit django-anymail +django-auditlog +django-auditlog @ git+https://github.com/jazzband/django-auditlog.git@45591463e8192b4ac0095e259cc4dcea0ac2fd6c +django-bleach +django-compressor +django-hijack +django-jsonform +django-maintenance-mode +django-markdownx @ git+https://github.com/alphatownsman/django-markdownx.git@e69480c64ad9c5d0499f4a8625da78cf2bb7691b +django-ninja +django-oauth-toolkit +django-polymorphic +django-redis +django-rq +django-sass-processor +django-simple-history # no longer used but kept for migration code which is used by tests +django-slack +django-tz-detect +django-user-messages +dnspython easy-thumbnails +filetype +fontawesomefree +igdb-api-v4 +libsass +listparser +loguru lxml +markdownify +mistune +opencc openpyxl +podcastparser psycopg2-binary requests -filetype +rq>=1.12.0 setproctitle tqdm -opencc -dnspython typesense -markdownify -igdb-api-v4 -podcastparser -listparser -fontawesomefree -discord.py -loguru