Skip to content

Commit

Permalink
Merge pull request #3 from GDSC-Hongik/feature/setup-lint
Browse files Browse the repository at this point in the history
chore: pre-commit lint 세팅
  • Loading branch information
dkfla authored Jul 20, 2024
2 parents 382144d + 4d4b9cd commit 9d34180
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 50 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions install_dependencies.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -18,5 +18,5 @@ def main():
execute_from_command_line(sys.argv)


if __name__ == '__main__':
if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion mustgou/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
79 changes: 40 additions & 39 deletions mustgou/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
DEBUG = True

ALLOWED_HOSTS = ['.pythonanywhere.com']
ALLOWED_HOSTS = [".pythonanywhere.com"]


# 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",
}
}

Expand All @@ -86,26 +87,26 @@

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",
},
]


# 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

Expand All @@ -115,10 +116,10 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/

STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = "static/"
STATIC_ROOT = os.path.join(BASE_DIR, "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"
2 changes: 1 addition & 1 deletion mustgou/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
from django.urls import path

urlpatterns = [
path('admin/', admin.site.urls),
path("admin/", admin.site.urls),
]
2 changes: 1 addition & 1 deletion mustgou/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion myapp/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from django.contrib import admin
# from django.contrib import admin

# Register your models here.
4 changes: 2 additions & 2 deletions myapp/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion myapp/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from django.db import models
# from django.db import models

# Create your models here.
2 changes: 1 addition & 1 deletion myapp/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from django.test import TestCase
# from django.test import TestCase

# Create your tests here.
2 changes: 1 addition & 1 deletion myapp/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from django.shortcuts import render
# from django.shortcuts import render

# Create your views here.

0 comments on commit 9d34180

Please sign in to comment.