From a7837201e5529c66d26abbb573760d7b3472ee4f Mon Sep 17 00:00:00 2001 From: teho Date: Wed, 24 Apr 2024 23:32:07 +0900 Subject: [PATCH] =?UTF-8?q?[#47]=20feat:=20workflow=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gradle.yml | 47 +++++++------------ .gitignore | 1 + .../nanaland/NanalandApplicationTests.java | 4 +- 3 files changed, 22 insertions(+), 30 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 18ff8573..6f723f3f 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -17,38 +17,11 @@ permissions: contents: read jobs: - test: - name: Test - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set YML for Test - run: echo "${{ secrets.TEST_YML }}" | base64 --decode > src/test/resources/application.yml - - - name: Set up MariaDB 10 for Test - uses: getong/mariadb-action@v1.1 - with: - host port: 3306 - container port: 3306 - mysql database: 'nanaland_test' - mysql user: 'root' - mysql password: ${{ secrets.DATABASE_KEY }} - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - - name: Build and Run Tests - run: ./gradlew clean test - deploy: - name: Deploy + name: deploy runs-on: ubuntu-latest - environment: production - # 아래의 flow들이 차례대로 실행됩니다. + steps: # 1) 기본 체크아웃 - name: Checkout @@ -68,6 +41,14 @@ jobs: echo "${{ secrets.YML }}" | base64 --decode > src/main/resources/application.yml find src + # 2.5) secret설정한 test yml 등록 + - name: Set Test YML + run: | + mkdir -p src/main/resources + echo "${{ secrets + .TEST_YML }}" | base64 --decode > src/main/resources/application-test.yml + find src + - name: Set up MariaDB 10 uses: getong/mariadb-action@v1.1 with: @@ -78,11 +59,19 @@ jobs: mysql password: ${{ secrets.DATABASE_KEY }} # mysql root password: ${{ secrets.RootPassword }} # Required if "mysql user" is empty, default is empty. The root superuser password + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build and Run Tests + run: ./gradlew clean test # 3) gradlew 권한 설정 - name: Grant execute permission for gradlew run: chmod +x gradlew # working-directory: ${{ env.working-directory }} + # 4) test 빌드 + - name: Build and Run Tests + run: ./gradlew clean test # 4) gradle 빌드 - name: Build with Gradle diff --git a/.gitignore b/.gitignore index 6733cc09..3a5436bb 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ build/ !**/src/test/**/build/ application.yml +application-test.yml ## test를 위한 controller TestController.java diff --git a/src/test/java/com/jeju/nanaland/NanalandApplicationTests.java b/src/test/java/com/jeju/nanaland/NanalandApplicationTests.java index 37f9224b..106c6d85 100644 --- a/src/test/java/com/jeju/nanaland/NanalandApplicationTests.java +++ b/src/test/java/com/jeju/nanaland/NanalandApplicationTests.java @@ -2,8 +2,10 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; -@SpringBootTest +@ActiveProfiles("test") +@SpringBootTest(properties = "classpath:application-test.yml") class NanalandApplicationTests { @Test