Add django.yml to run github action on tests (#11)

* Create django.yml

* Update django.yml

* Update django.yml

* Connect to Postgres before do test

* Fix Syntax Error

* Fix Migrate error

* Fix migration error / Modify requirments.txt

* Fix Database secret value missing

* Fix test error

* Add badge to README.md
This commit is contained in:
Sirin Puenggun 2023-10-30 20:25:27 +07:00 committed by GitHub
parent dc83c7b79c
commit f032ae50d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 61 additions and 9 deletions

43
.github/workflows/django.yml vendored Normal file
View File

@ -0,0 +1,43 @@
name: Django CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: github_actions
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run migrations
run: |
cd backend
python manage.py migrate
- name: Run tests
run: |
cd backend
python manage.py test

9
README.md Normal file
View File

@ -0,0 +1,9 @@
# TurTaskWeb
[![Django Testing](https://github.com/TurTaskProject/TurTaskWeb/actions/workflows/django.yml/badge.svg)](https://github.com/TurTaskProject/TurTaskWeb/actions/workflows/django.yml)
---
TurTask is a task and project management tool that incorporates gamification elements.
[Wiki Repository](https://github.com/TurTaskProject/TurTaskWiki)

View File

@ -22,7 +22,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = config('SECRET_KEY') SECRET_KEY = config('SECRET_KEY', default='j5&66&8@b-!3tbq!=w6-dypl($_0zzoi*ilxd1*&$_6s-59il5')
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config('DEBUG', default=False, cast=bool) DEBUG = config('DEBUG', default=False, cast=bool)
@ -82,8 +82,8 @@ REST_USE_JWT = True
SOCIALACCOUNT_PROVIDERS = { SOCIALACCOUNT_PROVIDERS = {
'google': { 'google': {
'APP': { 'APP': {
'client_id': config('GOOGLE_CLIENT_ID'), 'client_id': config('GOOGLE_CLIENT_ID', default='fake-client-id'),
'secret': config('GOOGLE_CLIENT_SECRET'), 'secret': config('GOOGLE_CLIENT_SECRET', default='fake-client-secret'),
'key': '' 'key': ''
}, },
"SCOPE": [ "SCOPE": [
@ -118,7 +118,7 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
# "allauth.account.middleware.AccountMiddleware", "allauth.account.middleware.AccountMiddleware",
] ]
ROOT_URLCONF = 'core.urls' ROOT_URLCONF = 'core.urls'
@ -150,11 +150,11 @@ WSGI_APPLICATION = 'core.wsgi.application'
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', 'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': config('DB_NAME'), 'NAME': config('DB_NAME', default='github_actions'),
'USER': config('DB_USER'), 'USER': config('DB_USER', default='postgres'),
'PASSWORD': config('DB_PASSWORD'), 'PASSWORD': config('DB_PASSWORD', default='postgres'),
'HOST': config('DB_HOST'), 'HOST': config('DB_HOST', default='127.0.0.1'),
'PORT': config('DB_PORT'), 'PORT': config('DB_PORT', default='5432'),
} }
} }

Binary file not shown.