feat: implement CI/CD pipeline with Gitea Actions

- Add Gitea Actions workflow with 4 stages: lint, test, build, push
- Configure ruff linting and formatting checks
- Set up Django tests with PostgreSQL and Redis services
- Implement Docker image building for web and celery services
- Add requirements.txt and requirements-dev.txt generation
- Fix ipdb compatibility issues in test runner
- Update ruff configuration for Django compatibility
- Add comprehensive CI/CD documentation
This commit is contained in:
2026-01-19 14:24:48 +01:00
parent cbfbd8652d
commit 06b30fca02
26 changed files with 1769 additions and 726 deletions

View File

@@ -4,8 +4,8 @@ Base settings for Django project.
Generated by 'django-admin startproject' using Django 3.2.25.
"""
import os
from pathlib import Path
from decouple import Config, RepositoryEnv
# Build paths inside the project like this: BASE_DIR / 'subdir'.
@@ -17,19 +17,24 @@ if ENV_FILE.exists():
config = Config(RepositoryEnv(str(ENV_FILE)))
else:
from decouple import AutoConfig
config = AutoConfig(search_path=BASE_DIR)
# Helper function for getting config values
def get_env(key, default=None):
return config(key, default=default)
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = get_env("SECRET_KEY", "django-insecure-development-key-change-in-production")
SECRET_KEY = get_env(
"SECRET_KEY", "django-insecure-development-key-change-in-production"
)
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = get_env("DEBUG", True)
if isinstance(DEBUG, str):
DEBUG = DEBUG.lower() in ('true', '1', 'yes')
DEBUG = DEBUG.lower() in ("true", "1", "yes")
ALLOWED_HOSTS = get_env("ALLOWED_HOSTS", "localhost,127.0.0.1")
if isinstance(ALLOWED_HOSTS, str):
@@ -43,17 +48,14 @@ INSTALLED_APPS = [
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
# Third-party apps
"rest_framework",
"corsheaders",
"django_celery_beat",
"django_celery_results",
"drf_yasg",
# Local apps
"apps.user",
]
MIDDLEWARE = [
@@ -99,11 +101,10 @@ DATABASES = {
"OPTIONS": {
"charset": "utf8mb4",
},
},
},
}
# Password validation
AUTH_PASSWORD_VALIDATORS = [
{
@@ -175,26 +176,24 @@ SIMPLE_JWT = {
"ISSUER": None,
"JWK_URL": None,
"LEEWAY": 0,
"AUTH_HEADER_TYPES": ("Bearer",),
"AUTH_HEADER_NAME": "HTTP_AUTHORIZATION",
"USER_ID_FIELD": "id",
"USER_ID_CLAIM": "user_id",
"USER_AUTHENTICATION_RULE": "rest_framework_simplejwt.authentication.default_user_authentication_rule",
"AUTH_TOKEN_CLASSES": ("rest_framework_simplejwt.tokens.AccessToken",),
"TOKEN_TYPE_CLAIM": "token_type",
"TOKEN_USER_CLASS": "rest_framework_simplejwt.models.TokenUser",
"JTI_CLAIM": "jti",
"SLIDING_TOKEN_REFRESH_EXP_CLAIM": "refresh_exp",
"SLIDING_TOKEN_LIFETIME": timedelta(minutes=5),
"SLIDING_TOKEN_REFRESH_LIFETIME": timedelta(days=1),
}
# CORS settings
CORS_ALLOWED_ORIGINS = get_env("CORS_ALLOWED_ORIGINS", "http://localhost:3000,http://127.0.0.1:3000")
CORS_ALLOWED_ORIGINS = get_env(
"CORS_ALLOWED_ORIGINS", "http://localhost:3000,http://127.0.0.1:3000"
)
if isinstance(CORS_ALLOWED_ORIGINS, str):
CORS_ALLOWED_ORIGINS = CORS_ALLOWED_ORIGINS.split(",")
CORS_ALLOW_CREDENTIALS = True
@@ -236,6 +235,8 @@ LOGGING = {
"level": "INFO",
"propagate": False,
},
},
}
# Test runner configuration
TEST_RUNNER = "config.custom_test_runner.CustomTestRunner"