From 01dd11dd9e1949cda61710e6fa877ada41d7367a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=EC=95=84=EB=A6=BC?= Date: Thu, 18 Jul 2024 01:16:41 +0900 Subject: [PATCH 1/3] =?UTF-8?q?chore:=20commit=20lint=20=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 20 +++++++++++ manage.py | 4 +-- mustgou/asgi.py | 2 +- mustgou/settings.py | 75 +++++++++++++++++++++-------------------- mustgou/urls.py | 2 +- mustgou/wsgi.py | 2 +- myapp/apps.py | 4 +-- 7 files changed, 65 insertions(+), 44 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..593cd42 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,20 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + + - repo: https://github.com/psf/black + rev: 23.3.0 + hooks: + - id: black + + - repo: https://github.com/PyCQA/flake8 + rev: 6.1.0 + hooks: + - id: flake8 + args: ["--max-line-length=88"] + exclude: mustgou/settings.py diff --git a/manage.py b/manage.py index 1c75612..2d9b06a 100755 --- a/manage.py +++ b/manage.py @@ -6,7 +6,7 @@ def main(): """Run administrative tasks.""" - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mustgou.settings') + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mustgou.settings") try: from django.core.management import execute_from_command_line except ImportError as exc: @@ -18,5 +18,5 @@ def main(): execute_from_command_line(sys.argv) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/mustgou/asgi.py b/mustgou/asgi.py index 32c5480..0607371 100644 --- a/mustgou/asgi.py +++ b/mustgou/asgi.py @@ -11,6 +11,6 @@ from django.core.asgi import get_asgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mustgou.settings') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mustgou.settings") application = get_asgi_application() diff --git a/mustgou/settings.py b/mustgou/settings.py index e7a7cde..0777132 100644 --- a/mustgou/settings.py +++ b/mustgou/settings.py @@ -20,63 +20,64 @@ # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-p@#&)c8s!q2!b2mfn)=39fqd@g&rz&zhy@r(p5-xu40cc-)r=%' +SECRET_KEY = "django-insecure-p@#&)c8s!q2!b2mfn)=39fqd@g&rz&zhy@r(p5-xu40cc-)r=%" # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ["localhost", "127.0.0.1"] # Application definition INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "myapp", ] MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", ] -ROOT_URLCONF = 'mustgou.urls' +ROOT_URLCONF = "mustgou.urls" TEMPLATES = [ { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", ], }, }, ] -WSGI_APPLICATION = 'mustgou.wsgi.application' +WSGI_APPLICATION = "mustgou.wsgi.application" # Database # https://docs.djangoproject.com/en/4.2/ref/settings/#databases DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": BASE_DIR / "db.sqlite3", } } @@ -86,16 +87,16 @@ 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.MinimumLengthValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", }, ] @@ -103,9 +104,9 @@ # Internationalization # https://docs.djangoproject.com/en/4.2/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = "en-us" -TIME_ZONE = 'UTC' +TIME_ZONE = "UTC" USE_I18N = True @@ -115,9 +116,9 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.2/howto/static-files/ -STATIC_URL = 'static/' +STATIC_URL = "static/" # Default primary key field type # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field -DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" diff --git a/mustgou/urls.py b/mustgou/urls.py index 23c9106..3853eff 100644 --- a/mustgou/urls.py +++ b/mustgou/urls.py @@ -18,5 +18,5 @@ from django.urls import path urlpatterns = [ - path('admin/', admin.site.urls), + path("admin/", admin.site.urls), ] diff --git a/mustgou/wsgi.py b/mustgou/wsgi.py index 136828f..8fa6b67 100644 --- a/mustgou/wsgi.py +++ b/mustgou/wsgi.py @@ -11,6 +11,6 @@ from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mustgou.settings') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mustgou.settings") application = get_wsgi_application() diff --git a/myapp/apps.py b/myapp/apps.py index c34fb20..da45bfa 100644 --- a/myapp/apps.py +++ b/myapp/apps.py @@ -2,5 +2,5 @@ class MyappConfig(AppConfig): - default_auto_field = 'django.db.models.BigAutoField' - name = 'myapp' + default_auto_field = "django.db.models.BigAutoField" + name = "myapp" From cfa4c59b04f286594b457a9fd60bc47b2038d7c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=EC=95=84=EB=A6=BC?= Date: Fri, 19 Jul 2024 00:51:32 +0900 Subject: [PATCH 2/3] =?UTF-8?q?chore:=20ci=20pipeline=20=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 24 ++++++++++++++++++++++++ install_dependencies.sh | 12 ++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 install_dependencies.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..160b6de --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: CI + +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.12 + + - name: Install dependencies + run: | + bash install_dependencies.sh + + - name: Run pre-commit + run: | + pre-commit run --all-files diff --git a/install_dependencies.sh b/install_dependencies.sh new file mode 100644 index 0000000..395af8a --- /dev/null +++ b/install_dependencies.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +# python3 또는 python 명령어를 찾습니다. +PYTHON=$(command -v python3 || command -v python) +PIP="$PYTHON -m pip" + +$PIP install --upgrade pip +$PIP install pre-commit +$PIP install black +$PIP install flake8 From 8d3d432bd663bfbbc815863de57f30ec749a1e34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=EC=95=84=EB=A6=BC?= Date: Sat, 20 Jul 2024 14:34:33 +0900 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20commit=20lint=20=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- myapp/admin.py | 2 +- myapp/models.py | 2 +- myapp/tests.py | 2 +- myapp/views.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/myapp/admin.py b/myapp/admin.py index 8c38f3f..4185d36 100644 --- a/myapp/admin.py +++ b/myapp/admin.py @@ -1,3 +1,3 @@ -from django.contrib import admin +# from django.contrib import admin # Register your models here. diff --git a/myapp/models.py b/myapp/models.py index 71a8362..0b4331b 100644 --- a/myapp/models.py +++ b/myapp/models.py @@ -1,3 +1,3 @@ -from django.db import models +# from django.db import models # Create your models here. diff --git a/myapp/tests.py b/myapp/tests.py index 7ce503c..a79ca8b 100644 --- a/myapp/tests.py +++ b/myapp/tests.py @@ -1,3 +1,3 @@ -from django.test import TestCase +# from django.test import TestCase # Create your tests here. diff --git a/myapp/views.py b/myapp/views.py index 91ea44a..fd0e044 100644 --- a/myapp/views.py +++ b/myapp/views.py @@ -1,3 +1,3 @@ -from django.shortcuts import render +# from django.shortcuts import render # Create your views here.