Skip to content
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
8 changes: 4 additions & 4 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
- ..:/workspace:cached
working_dir: /workspace/src
env_file:
- ../.env
- ../.env_files/.env

command: sleep infinity
depends_on:
Expand All @@ -22,7 +22,7 @@ services:
- ..:/workspace:cached
working_dir: /workspace/src
env_file:
- ../.env
- ../.env_files/.env

command: celery -A backend worker --loglevel=info
depends_on:
Expand All @@ -37,7 +37,7 @@ services:
- ..:/workspace:cached
working_dir: /workspace/src
env_file:
- ../.env
- ../.env_files/.env
command: celery -A backend beat --loglevel=info --scheduler django_celery_beat.schedulers:DatabaseScheduler
depends_on:
- redis
Expand All @@ -57,7 +57,7 @@ services:
ports:
- "5432:5432"
env_file:
- ../.env
- ../.env_files/.env

volumes:
postgres-data:
18 changes: 18 additions & 0 deletions .env_files/.env.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Database
DATABASE_URI=postgresql://postgres:postgres@localhost:5432/web_test
DATABASE_URI_TEST=postgresql://postgres:postgres@localhost:5432/web_test

# Django
SECRET_KEY=ci-secret-key
DEBUG=False
ALLOWED_HOSTS=localhost,127.0.0.1
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000

# Celery / Redis
CELERY_BROKER_URL=redis://localhost:6379/0
CELERY_RESULT_BACKEND=redis://localhost:6379/1

# Postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=postgres
File renamed without changes.
54 changes: 54 additions & 0 deletions .github/workflows/django-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Django CI (Postgres)

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: web_test
ports: ["5432:5432"]
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
redis:
image: redis:7
ports: ["6379:6379"]

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: pip install -r requirements.txt

- name: Run migrations
working-directory: src
run: |
set -o allexport
source ../.env_files/.env.ci
python manage.py migrate
set +o allexport

- name: Run tests
working-directory: src
run: |
set -o allexport
source ../.env_files/.env.ci
pytest
set +o allexport
25 changes: 25 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Lint & Format

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run Black
run: black --check .
- name: Run isort
run: isort --check-only .
- name: Run flake8
run: flake8 .
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"python.testing.pytestEnabled": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "always"
"source.organizeImports": "always",
"source.fixAll": "always"
},
"editor.rulers": [
88
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
volumes:
- ./:/workspace:cached
env_file:
- .env
- .env_files/.env
command: ["/bin/sh", "/workspace/scripts/django/start.sh"]
ports:
- "8000:8000"
Expand All @@ -25,7 +25,7 @@ services:
volumes:
- ./:/workspace:cached
env_file:
- .env
- .env_files/.env
command: ["/bin/sh", "/workspace/scripts/celery/worker.sh"]
depends_on:
db:
Expand All @@ -43,7 +43,7 @@ services:
- ./:/workspace:cached
working_dir: /workspace/src
env_file:
- .env
- .env_files/.env
command: ["/bin/sh", "/workspace/scripts/celery/beat.sh"]
depends_on:
db:
Expand Down Expand Up @@ -74,7 +74,7 @@ services:
ports:
- "5432:5432"
env_file:
- .env
- .env_files/.env
networks:
- backend
healthcheck:
Expand Down
41 changes: 28 additions & 13 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
[black]
line-length = 88 # Set line length to 88
line-length = 88

[pylint]
disable = C0114 # Disable missing module docstring warning
[isort]
profile = black
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
line_length = 88
remove_redundant_aliases = true

[flake8]
max-line-length = 88 # Set line length to 88
extend-ignore = E203, W503 # Ignore specific warnings
max-line-length = 88
extend-ignore = E203, W503
exclude = .git,__pycache__,migrations,venv
per-file-ignores =
src/backend/settings_test.py: F405

[isort]
multi_line_output = 3 # Vertical hanging indent for imports
include_trailing_comma = true # Add trailing comma
force_grid_wrap = 0 # Disable wrapping
use_parentheses = true # Use parentheses for wrapping
ensure_newline_before_comments = true # Newline before comments in imports
line_length = 88 # Set line length to 88
remove_redundant_aliases = true # Remove redundant aliases
[pylint]
disable = C0114

[mypy]
plugins = mypy_django_plugin.main
ignore_missing_imports = True

[mypy-tests.*]
ignore_errors = True

[mypy.plugins.django-stubs]
django_settings_module = "backend.settings"
strict_settings = True
12 changes: 7 additions & 5 deletions src/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"corsheaders.middleware.CorsMiddleware", # CORS middleware should be high in the order
"corsheaders.middleware.CorsMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
Expand Down Expand Up @@ -80,11 +80,13 @@
# Password validation
AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"
"NAME": (
"django.contrib.auth.password_validation.UserAttributeSimilarityValidator"
)
},
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator"},
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"},
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
{"NAME": ("django.contrib.auth.password_validation.MinimumLengthValidator")},
{"NAME": ("django.contrib.auth.password_validation.CommonPasswordValidator")},
{"NAME": ("django.contrib.auth.password_validation.NumericPasswordValidator")},
]

# Internationalization settings
Expand Down
2 changes: 1 addition & 1 deletion src/backend/settings_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from backend.settings import * # noqa: F401,F403
from backend.settings import * # noqa: F401,F403,F405

DATABASES = {"default": env.db("DATABASE_URI")}
2 changes: 1 addition & 1 deletion src/items/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class ItemsConfig(AppConfig):
name = "items"

def ready(self):
import items.signals
pass
1 change: 1 addition & 0 deletions src/items/migrations/0002_item_external_price.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by Django 5.1.7 on 2025-08-01 11:09

from decimal import Decimal

from django.db import migrations, models


Expand Down