Skip to content

Commit

Permalink
Merge pull request #88 from Travel-in-nanaland/feat/#47-ci-cd
Browse files Browse the repository at this point in the history
[#47] feat: workflow 수정
  • Loading branch information
Te-H0 authored Apr 24, 2024
2 parents 3b8a2c9 + a783720 commit ae75713
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 30 deletions.
47 changes: 18 additions & 29 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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
Expand All @@ -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/[email protected]
with:
Expand All @@ -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 Test with Gradle
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ build/
!**/src/test/**/build/

application.yml
application-test.yml

## test를 위한 controller
TestController.java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ae75713

Please sign in to comment.