Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Commit

Permalink
Merge pull request #337 from RaenonX/dev
Browse files Browse the repository at this point in the history
Implementing #172 #231 #325 #333 (Partial: #200 #294) and minor bug fixes
  • Loading branch information
RaenonX authored Aug 19, 2020
2 parents 89eecbc + 1ce8ec2 commit c3b5b45
Show file tree
Hide file tree
Showing 338 changed files with 5,433 additions and 2,403 deletions.
2 changes: 2 additions & 0 deletions .bat/new-venv.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pip install -r --upgrade requirements.txt
pip install -r --upgrade requirements-env.txt
8 changes: 7 additions & 1 deletion .flake8-style
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
[flake8]
count = True

ignore =
# module imported but not used (actually using but somehow not detected)
F401
# As of PEP 8, W503 is yielded in old-style
W503

exclude =
tests_old/
archive/
sandbox*.py

max-complexity = 10

max-line-length = 119

show-source = True
statistics = True

statistics = True
189 changes: 67 additions & 122 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,103 +2,66 @@ name: Jelly Bot - CI Test

on: [push]

jobs:
prepare:
runs-on: windows-latest
defaults:
run:
shell: cmd

steps:
- name: Print SHA
shell: cmd
run: |
echo %GITHUB_SHA%
env:
SECRET_KEY: ${{ secrets.DjangoSecretKey }}

- name: Print REF
shell: cmd
run: |
echo %GITHUB_REF%
DJANGO_SETTINGS_MODULE: JellyBot.settings

flake8-checks:
runs-on: windows-latest
PRODUCTION: 0
DEBUG: 1
TEST: 1

needs: [prepare]
LOGGER: DISCORD_INTERNAL|40,MODEL_CHECK|30,PING_SPAM|10
NO_FIELD_CHECK: 1

timeout-minutes: 10

env:
SECRET_KEY: ${{ secrets.DjangoSecretKey }}
DJANGO_SETTINGS_MODULE: JellyBot.settings
MONGO_URL: ${{ secrets.MongoDBURL }}
MONGO_DB: 'GitHubActionTest#${{ github.run_number }}'
LINE_SECRET: ${{ secrets.LINESecret }}
LINE_TOKEN: ${{ secrets.LINEToken }}
DISCORD_TOKEN: ${{ secrets.DiscordToken }}
PRODUCTION: 0
DEBUG: 1
TEST: 1
LOGGER: DISCORD_INTERNAL|40,MODEL_CHECK|30,PING_SPAM|10
NO_FIELD_CHECK: 1
GI_CLIENT_ID: ${{ secrets.GoogleIdentityClientID }}
EMAIL_ACCOUNT: ${{ secrets.EmailAccount }}
EMAIL_PASSWORD: ${{ secrets.EmailPassword }}
SERVICE_SHORT_URL: http://rnnx.cc
DDNS_PASSWORD: ${{ secrets.DDNSPassword }}
IMGUR_CLIENT_ID: ${{ secrets.ImgurClientID }}
DDNS_HOST: bot
DDNS_DOMAIN: raenonx.cc
MONGO_URL: ${{ secrets.MongoDBURL }}
MONGO_DB: 'GitHubActionTest#${{ github.run_number }}'

steps:
- uses: actions/checkout@v2
LINE_SECRET: ${{ secrets.LINESecret }}
LINE_TOKEN: ${{ secrets.LINEToken }}
DISCORD_TOKEN: ${{ secrets.DiscordToken }}

- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
GI_CLIENT_ID: ${{ secrets.GoogleIdentityClientID }}
IMGUR_CLIENT_ID: ${{ secrets.ImgurClientID }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
EMAIL_ACCOUNT: ${{ secrets.EmailAccount }}
EMAIL_PASSWORD: ${{ secrets.EmailPassword }}

- name: Install flake8
run: |
pip install flake8
SERVICE_SHORT_URL: http://rnnx.cc

DDNS_HOST: bot
DDNS_DOMAIN: raenonx.cc
DDNS_PASSWORD: ${{ secrets.DDNSPassword }}

LINTED: bot doc extdiscord extline extutils flags

- name: flake8 - error check
jobs:
prepare:
runs-on: windows-latest

continue-on-error: true

steps:
- name: Print SHA
run: |
flake8 . --config .flake8-error
echo %GITHUB_SHA%
- name: flake8 - style check
- name: Print REF
run: |
flake8 . --config .flake8-style
echo %GITHUB_REF%
pylint-checks:
checks:
runs-on: windows-latest

needs: [prepare]

timeout-minutes: 10

env:
SECRET_KEY: ${{ secrets.DjangoSecretKey }}
DJANGO_SETTINGS_MODULE: JellyBot.settings
MONGO_URL: ${{ secrets.MongoDBURL }}
MONGO_DB: 'GitHubActionTest#${{ github.run_number }}'
LINE_SECRET: ${{ secrets.LINESecret }}
LINE_TOKEN: ${{ secrets.LINEToken }}
DISCORD_TOKEN: ${{ secrets.DiscordToken }}
PRODUCTION: 0
DEBUG: 1
TEST: 1
LOGGER: DISCORD_INTERNAL|40,MODEL_CHECK|30,PING_SPAM|10
NO_FIELD_CHECK: 1
GI_CLIENT_ID: ${{ secrets.GoogleIdentityClientID }}
EMAIL_ACCOUNT: ${{ secrets.EmailAccount }}
EMAIL_PASSWORD: ${{ secrets.EmailPassword }}
SERVICE_SHORT_URL: http://rnnx.cc
DDNS_PASSWORD: ${{ secrets.DDNSPassword }}
IMGUR_CLIENT_ID: ${{ secrets.ImgurClientID }}
DDNS_HOST: bot
DDNS_DOMAIN: raenonx.cc
timeout-minutes: 20

continue-on-error: true

steps:
- uses: actions/checkout@v2
Expand All @@ -112,56 +75,35 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-env.txt
- name: Install pylint
- name: '`flake8` - error check'
run: |
pip install pylint
flake8 . --config .flake8-error --benchmark
- name: Lint on `bot`
- name: '`flake8` - style check'
run: |
pylint bot
flake8 . --config .flake8-style --benchmark
- name: Lint on `doc`
- name: Print out linted modules
run: |
pylint doc
echo %LINTED%
- name: Lint on `extdiscord`
- name: '`pydocstyle`'
run: |
pylint extdiscord
pydocstyle %LINTED% --count
- name: Lint on `extline`
- name: '`pylint`'
run: |
pylint extline
pylint %LINTED%
django-tests:
runs-on: windows-latest

needs: [prepare]
needs: [prepare, checks]

timeout-minutes: 60

env:
SECRET_KEY: ${{ secrets.DjangoSecretKey }}
DJANGO_SETTINGS_MODULE: JellyBot.settings
MONGO_URL: ${{ secrets.MongoDBURL }}
MONGO_DB: 'GitHubActionTest#${{ github.run_number }}'
LINE_SECRET: ${{ secrets.LINESecret }}
LINE_TOKEN: ${{ secrets.LINEToken }}
DISCORD_TOKEN: ${{ secrets.DiscordToken }}
PRODUCTION: 0
DEBUG: 1
TEST: 1
LOGGER: DISCORD_INTERNAL|40,MODEL_CHECK|30,PING_SPAM|10
NO_FIELD_CHECK: 1
GI_CLIENT_ID: ${{ secrets.GoogleIdentityClientID }}
EMAIL_ACCOUNT: ${{ secrets.EmailAccount }}
EMAIL_PASSWORD: ${{ secrets.EmailPassword }}
SERVICE_SHORT_URL: http://rnnx.cc
DDNS_PASSWORD: ${{ secrets.DDNSPassword }}
IMGUR_CLIENT_ID: ${{ secrets.ImgurClientID }}
DDNS_HOST: bot
DDNS_DOMAIN: raenonx.cc

steps:
- uses: actions/checkout@v2

Expand All @@ -174,20 +116,24 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest-django
pip install -r requirements-env.txt
- name: Run pytest
- name: Unit tests
run: |
pytest
py manage.py test tests.unit
- name: Integration tests
run: |
py manage.py test tests.integration
- name: System tests
run: |
py manage.py test tests.system
cleanup:
runs-on: windows-latest

needs: [prepare, django-tests]

env:
MONGO_URL: ${{ secrets.MongoDBURL }}
DB_DROP: 'GitHubActionTest#${{ github.run_number }}'
needs: [django-tests]

steps:
- uses: actions/checkout@v2
Expand All @@ -197,6 +143,5 @@ jobs:
pip install pymongo dnspython
- name: Drop MongoDB database
shell: cmd
run: |
python mongodb/cli/drop_db.py %DB_DROP%
python mongodb/cli/drop_db.py %MONGO_DB%
30 changes: 30 additions & 0 deletions .pydocstyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[pydocstyle]
ignore =
# Public method missing docstring - `pylint` will check if there's really missing the docstring
D102,
# Magic method missing docstring - no need for it
D105,
# __init__ missing docstring - optional. add details to class docstring
D107,
# Blank line required before docstring - mutually exclusive to D204
D203,
# Multi-line docstring summary should start at the first line - mutually exclusive to D213
D212,
# Section underline is over-indented
D215,
# First line should be in imperative mood
D401,
# First word of the docstring should not be This
D404,
# Section name should end with a newline
D406,
# Missing dashed underline after section
D407,
# Section underline should be in the line following the section’s name
D408,
# Section underline should match the length of its name
D409,
# No blank lines allowed between a section header and its content
D412,
# Missing blank line after last section
D413
39 changes: 37 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,42 @@
# Template .pylintrc file https://raw.githubusercontent.com/datawire/quark/master/.pylintrc

[MASTER]

load-plugins=pylint_django

[BASIC]

# Reason of the good names:
# - i, j, k
# often used in for loops
# - f
# often used as a file stream name
# - ex
# often used as the var name of exception caught by try..except
# - fn
# often used to represent a function address
# - _
# often used as dummy variable during unpacking
# - dt, tz
# often used in datetime handling (dt for datetime, tz for timezone)

good-names=f,i,j,k,ex,fn,_,dt,tz

include-naming-hint=yes

[DESIGN]

max-parents=15

max-args=5

max-returns=7

[FORMAT]

max-line-length=119

[DESIGN]
max-parents=15
[MESSAGES CONTROL]

disable=broad-except,
consider-using-enumerate
4 changes: 2 additions & 2 deletions JellyBot/components/middleware/tz.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.utils import timezone
from django.utils.deprecation import MiddlewareMixin

from extutils.locales import default_locale
from extutils.locales import DEFAULT_LOCALE
from JellyBot.utils import get_root_oid

from mongodb.factory import RootUserManager
Expand All @@ -13,6 +13,6 @@ def process_request(self, request):
root_oid = get_root_oid(request)

if root_oid is None:
timezone.activate(default_locale.to_tzinfo())
timezone.activate(DEFAULT_LOCALE.to_tzinfo())
else:
timezone.activate(RootUserManager.get_tzinfo_root_oid(root_oid))
Loading

0 comments on commit c3b5b45

Please sign in to comment.