Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/CICD backend #11

Merged
merged 16 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
sukchan-0811 marked this conversation as resolved.
Show resolved Hide resolved