Skip to content

Commit

Permalink
Merge pull request #11 from snuhcs-course/feat/CICD-backend
Browse files Browse the repository at this point in the history
Feat/CICD backend
  • Loading branch information
sukchan-0811 authored Oct 26, 2023
2 parents 4406b80 + 52b2007 commit 05b21b1
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 7 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/backend_CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: SpeechBuddy Backend CD

on:
push:
branches: [ "main" ]

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: SSH Remote Commands
uses: appleboy/[email protected]
with:
key: ${{ secrets.SSH_KEY }}
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
script: |
sh deploy.sh
39 changes: 39 additions & 0 deletions .github/workflows/backend_CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: SpeechBuddy Backend CI

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

jobs:
build:

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.9]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
run: |
cd backend
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Tests
run: |
cd backend
python manage.py test --no-input
env:
SECRET_KEY: ${{ secrets.SECRET_KEY }}
EMAIL_HOST_USER: ${{ secrets.EMAIL_HOST_USER }}
EMAIL_HOST_PASSWORD: ${{ secrets.EMAIL_HOST_PASSWORD }}
21 changes: 14 additions & 7 deletions backend/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
secret_file = os.path.join(BASE_DIR, 'secrets.json') # secrets.json 파일 위치를 명시

with open(secret_file) as f:
secrets = json.loads(f.read())
if "GITHUB_ACTIONS" in os.environ:
# If running in GitHub Actions, use secrets from environment variables
secrets = {
"SECRET_KEY": os.environ.get("SECRET_KEY"),
"EMAIL_HOST_USER": os.environ.get("EMAIL_HOST_USER"),
"EMAIL_HOST_PASSWORD": os.environ.get("EMAIL_HOST_PASSWORD"),
}
else:
secret_file = os.path.join(BASE_DIR, 'secrets.json') # secrets.json 파일 위치를 명시
with open(secret_file) as f:
secrets = json.loads(f.read())


def get_secret(setting, secrets=secrets):
Expand Down Expand Up @@ -122,9 +128,10 @@ def get_secret(setting, secrets=secrets):

# Remote DB settings
# Add your own confidential.py
import confidential
if not ("GITHUB_ACTIONS" in os.environ):
import confidential
DATABASES = confidential.DATABASES

DATABASES = confidential.DATABASES

# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
Expand Down
55 changes: 55 additions & 0 deletions backend/user/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from unittest import TestCase


class TestUserSignUpView(TestCase):
def test_post(self):
self.assertEqual(1, 1)

# class TestSignUpEmailVerifySendView(TestCase):
# def test_post(self):
# self.fail()
#
#
# class TestPasswordEmailVerifySendView(TestCase):
# def test_post(self):
# self.fail()
#
#
# class TestSignUpEmailVerifyAcceptView(TestCase):
# def test_post(self):
# self.fail()
#
#
# class TestPasswordEmailVerifyAcceptView(TestCase):
# def test_post(self):
# self.fail()
#
#
# class TestUserLoginView(TestCase):
# def test_post(self):
# self.fail()
#
#
# class TestUserLogoutView(TestCase):
# def test_post(self):
# self.fail()
#
#
# class TestUserProfileView(TestCase):
# def test_get(self):
# self.fail()
#
#
# class TestPasswordUpdateView(TestCase):
# def test_patch(self):
# self.fail()
#
#
# class TestNicknameUpdateView(TestCase):
# def test_patch(self):
# self.fail()
#
#
# class TestUserWithdrawView(TestCase):
# def test_post(self):
# self.fail()

0 comments on commit 05b21b1

Please sign in to comment.