diff --git a/.github/workflows/backend_CD.yml b/.github/workflows/backend_CD.yml new file mode 100644 index 00000000..15508f3b --- /dev/null +++ b/.github/workflows/backend_CD.yml @@ -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/ssh-action@v1.0.0 + with: + key: ${{ secrets.SSH_KEY }} + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + script: | + sh deploy.sh diff --git a/.github/workflows/backend_CI.yml b/.github/workflows/backend_CI.yml new file mode 100644 index 00000000..0e3910b2 --- /dev/null +++ b/.github/workflows/backend_CI.yml @@ -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 }} diff --git a/backend/config/settings.py b/backend/config/settings.py index 4131164d..ad0a74fa 100644 --- a/backend/config/settings.py +++ b/backend/config/settings.py @@ -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): @@ -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 diff --git a/backend/user/test_views.py b/backend/user/test_views.py new file mode 100644 index 00000000..dae0cad8 --- /dev/null +++ b/backend/user/test_views.py @@ -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()