From 5051f443708fe4e8bec75cfef3a8820014d63fec Mon Sep 17 00:00:00 2001 From: YeonJeong <65206075+yjeong-k@users.noreply.github.com> Date: Wed, 25 Oct 2023 16:36:16 +0900 Subject: [PATCH 01/15] Create aws.yml --- .github/workflows/aws.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/aws.yml diff --git a/.github/workflows/aws.yml b/.github/workflows/aws.yml new file mode 100644 index 00000000..15508f3b --- /dev/null +++ b/.github/workflows/aws.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 From 8d0edcf0367939d7f7f06324f5d75064a9ec5aac Mon Sep 17 00:00:00 2001 From: YeonJeong <65206075+yjeong-k@users.noreply.github.com> Date: Wed, 25 Oct 2023 16:44:51 +0900 Subject: [PATCH 02/15] :art: Rename and temporarily add new branch to on_push.yml --- .github/{workflows/aws.yml => workflow/backend_CD.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/{workflows/aws.yml => workflow/backend_CD.yml} (89%) diff --git a/.github/workflows/aws.yml b/.github/workflow/backend_CD.yml similarity index 89% rename from .github/workflows/aws.yml rename to .github/workflow/backend_CD.yml index 15508f3b..82459d43 100644 --- a/.github/workflows/aws.yml +++ b/.github/workflow/backend_CD.yml @@ -2,7 +2,7 @@ name: SpeechBuddy Backend CD on: push: - branches: [ "main" ] + branches: [ "main", "feat/CICD-backend" ] jobs: deploy: From 4ac3a231a49922dafc827b777116447f75851c3b Mon Sep 17 00:00:00 2001 From: YeonJeong Kim Date: Wed, 25 Oct 2023 16:56:52 +0900 Subject: [PATCH 03/15] :white_check_mark: Add tentative test to trigger CD --- backend/user/test_views.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 backend/user/test_views.py diff --git a/backend/user/test_views.py b/backend/user/test_views.py new file mode 100644 index 00000000..85a70e61 --- /dev/null +++ b/backend/user/test_views.py @@ -0,0 +1,6 @@ +from unittest import TestCase + + +class TestUserSignUpView(TestCase): + def test_post(self): + self.fail() From 2beb47301f6037221011512fcf29b971d82dd797 Mon Sep 17 00:00:00 2001 From: YeonJeong <65206075+yjeong-k@users.noreply.github.com> Date: Wed, 25 Oct 2023 17:03:12 +0900 Subject: [PATCH 04/15] :bug: Change the directory name --- .github/{workflow => workflows}/backend_CD.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflow => workflows}/backend_CD.yml (100%) diff --git a/.github/workflow/backend_CD.yml b/.github/workflows/backend_CD.yml similarity index 100% rename from .github/workflow/backend_CD.yml rename to .github/workflows/backend_CD.yml From 8d13c2ee4068d0baf3260a8e63da3a76c20f14b9 Mon Sep 17 00:00:00 2001 From: YeonJeong Kim Date: Wed, 25 Oct 2023 17:07:19 +0900 Subject: [PATCH 05/15] :white_check_mark: Add tentative test functions to trigger CD --- backend/user/test_views.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/backend/user/test_views.py b/backend/user/test_views.py index 85a70e61..ca8e6361 100644 --- a/backend/user/test_views.py +++ b/backend/user/test_views.py @@ -4,3 +4,28 @@ class TestUserSignUpView(TestCase): def test_post(self): self.fail() + + +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() From 7f607dc29ba5ba96c3f0a0685febf227f2826985 Mon Sep 17 00:00:00 2001 From: YeonJeong Kim Date: Wed, 25 Oct 2023 17:53:43 +0900 Subject: [PATCH 06/15] :white_check_mark: Add tentative test functions to trigger CD --- backend/user/test_views.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/user/test_views.py b/backend/user/test_views.py index ca8e6361..3100f41d 100644 --- a/backend/user/test_views.py +++ b/backend/user/test_views.py @@ -29,3 +29,8 @@ def test_post(self): class TestUserLoginView(TestCase): def test_post(self): self.fail() + + +class TestUserLogoutView(TestCase): + def test_post(self): + self.fail() From b109c2e24f63c3b95e4903d4118eec57b5076232 Mon Sep 17 00:00:00 2001 From: YeonJeong Kim Date: Wed, 25 Oct 2023 17:56:49 +0900 Subject: [PATCH 07/15] :white_check_mark: Add tentative test functions to trigger CD.. Last check! --- backend/user/test_views.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/backend/user/test_views.py b/backend/user/test_views.py index 3100f41d..3f5184b9 100644 --- a/backend/user/test_views.py +++ b/backend/user/test_views.py @@ -34,3 +34,23 @@ def test_post(self): 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() From 05a1258910b5b0eee5d156234f7f78937156560a Mon Sep 17 00:00:00 2001 From: YeonJeong <65206075+yjeong-k@users.noreply.github.com> Date: Wed, 25 Oct 2023 18:01:59 +0900 Subject: [PATCH 08/15] :wrench: Complete backend_CD.yml --- .github/workflows/backend_CD.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend_CD.yml b/.github/workflows/backend_CD.yml index 82459d43..15508f3b 100644 --- a/.github/workflows/backend_CD.yml +++ b/.github/workflows/backend_CD.yml @@ -2,7 +2,7 @@ name: SpeechBuddy Backend CD on: push: - branches: [ "main", "feat/CICD-backend" ] + branches: [ "main" ] jobs: deploy: From 649f5ff31e919b0de95aad4c9b3a39b3bcd0be47 Mon Sep 17 00:00:00 2001 From: YeonJeong <65206075+yjeong-k@users.noreply.github.com> Date: Wed, 25 Oct 2023 18:25:29 +0900 Subject: [PATCH 09/15] :construction_worker: Create backend_CI.yml --- .github/workflows/backend_CI.yml | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/backend_CI.yml diff --git a/.github/workflows/backend_CI.yml b/.github/workflows/backend_CI.yml new file mode 100644 index 00000000..3a3e13af --- /dev/null +++ b/.github/workflows/backend_CI.yml @@ -0,0 +1,39 @@ +name: SpeechBuddy Backend CI + +on: + push: + branches: [ "main", "feat/CICD-backend" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.8, 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 }} From 85328585560520e0320c4730a44d6833019745a2 Mon Sep 17 00:00:00 2001 From: YeonJeong <65206075+yjeong-k@users.noreply.github.com> Date: Wed, 25 Oct 2023 18:28:19 +0900 Subject: [PATCH 10/15] :wrench: Update backend_CD to recheck.yml --- .github/workflows/backend_CD.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend_CD.yml b/.github/workflows/backend_CD.yml index 15508f3b..82459d43 100644 --- a/.github/workflows/backend_CD.yml +++ b/.github/workflows/backend_CD.yml @@ -2,7 +2,7 @@ name: SpeechBuddy Backend CD on: push: - branches: [ "main" ] + branches: [ "main", "feat/CICD-backend" ] jobs: deploy: From ca002654ee9a4e45b9632fb1d821a1eeb338c615 Mon Sep 17 00:00:00 2001 From: YeonJeong Kim Date: Wed, 25 Oct 2023 18:45:40 +0900 Subject: [PATCH 11/15] :wrench: Modify settings.py to get secret variables in CI --- backend/config/settings.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/backend/config/settings.py b/backend/config/settings.py index 4131164d..2bdee62c 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): From ba62bceba32e03712a187a8c15119c07fa571a70 Mon Sep 17 00:00:00 2001 From: YeonJeong Kim Date: Wed, 25 Oct 2023 18:57:07 +0900 Subject: [PATCH 12/15] :wrench: Modify settings.py to handle confidential.py for DB settings --- backend/config/settings.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/config/settings.py b/backend/config/settings.py index 2bdee62c..ad0a74fa 100644 --- a/backend/config/settings.py +++ b/backend/config/settings.py @@ -128,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 From a7938f09b7a1ce6c2a44cc68059643ed00f09d56 Mon Sep 17 00:00:00 2001 From: YeonJeong Kim Date: Wed, 25 Oct 2023 19:05:25 +0900 Subject: [PATCH 13/15] :white_check_mark: Modify tests to have only one trivial test --- backend/user/test_views.py | 101 ++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/backend/user/test_views.py b/backend/user/test_views.py index 3f5184b9..dae0cad8 100644 --- a/backend/user/test_views.py +++ b/backend/user/test_views.py @@ -3,54 +3,53 @@ class TestUserSignUpView(TestCase): def test_post(self): - self.fail() - - -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() + 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() From 46beebda24b8f7f484c82a132bab72dda72647ad Mon Sep 17 00:00:00 2001 From: YeonJeong <65206075+yjeong-k@users.noreply.github.com> Date: Wed, 25 Oct 2023 19:09:57 +0900 Subject: [PATCH 14/15] :construction_worker: Complete backend_CI.yml --- .github/workflows/backend_CI.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backend_CI.yml b/.github/workflows/backend_CI.yml index 3a3e13af..0e3910b2 100644 --- a/.github/workflows/backend_CI.yml +++ b/.github/workflows/backend_CI.yml @@ -2,7 +2,7 @@ name: SpeechBuddy Backend CI on: push: - branches: [ "main", "feat/CICD-backend" ] + branches: [ "main" ] pull_request: branches: [ "main" ] @@ -13,7 +13,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3.8, 3.9] + python-version: [3.9] steps: - uses: actions/checkout@v4 From 52b200716550ead454b31ec6b9fd32841b3feea2 Mon Sep 17 00:00:00 2001 From: YeonJeong <65206075+yjeong-k@users.noreply.github.com> Date: Wed, 25 Oct 2023 19:10:49 +0900 Subject: [PATCH 15/15] :wrench: Complete backend_CD.yml --- .github/workflows/backend_CD.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend_CD.yml b/.github/workflows/backend_CD.yml index 82459d43..15508f3b 100644 --- a/.github/workflows/backend_CD.yml +++ b/.github/workflows/backend_CD.yml @@ -2,7 +2,7 @@ name: SpeechBuddy Backend CD on: push: - branches: [ "main", "feat/CICD-backend" ] + branches: [ "main" ] jobs: deploy: