From bb0a4d68174f286aafce0339a95b459d31e203e7 Mon Sep 17 00:00:00 2001 From: JIHO LEE <161289673+GitJIHO@users.noreply.github.com> Date: Sun, 20 Oct 2024 18:50:29 +0900 Subject: [PATCH] =?UTF-8?q?Deploy:=20PR=20=EC=83=9D=EC=84=B1=EC=8B=9C=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=BD=94=EB=93=9C=20=EC=88=98?= =?UTF-8?q?=ED=96=89=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84=20(#94)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * deploy: PR 생성시 테스트코드 수행 로직 추가 * feat: jwt.secret키를 깃허브 시크릿에 저장 및 환경변수 설정 * feat: 환경변수 읽어오도록 수정 * feat: 도커를 사용하여 레디스 환경 구축 --- .github/workflows/testcode.yml | 36 +++++++++++++++++++ .../sinitto/SinittoApplicationTests.java | 7 ++++ 2 files changed, 43 insertions(+) create mode 100644 .github/workflows/testcode.yml diff --git a/.github/workflows/testcode.yml b/.github/workflows/testcode.yml new file mode 100644 index 00000000..a1710fd5 --- /dev/null +++ b/.github/workflows/testcode.yml @@ -0,0 +1,36 @@ +name: Run Tests on Pull Request + +on: + pull_request: + branches: + - Weekly + +jobs: + test: + runs-on: ubuntu-latest + + services: + redis: + image: redis:alpine + ports: + - 6379:6379 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: '21' + distribution: 'temurin' + + - name: Run Tests + env: + JWT_SECRET: ${{ secrets.JWT_SECRET }} + run: ./gradlew test diff --git a/src/test/java/com/example/sinitto/SinittoApplicationTests.java b/src/test/java/com/example/sinitto/SinittoApplicationTests.java index b4b7d602..be2f259e 100644 --- a/src/test/java/com/example/sinitto/SinittoApplicationTests.java +++ b/src/test/java/com/example/sinitto/SinittoApplicationTests.java @@ -1,13 +1,20 @@ package com.example.sinitto; import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; +import static org.hibernate.validator.internal.util.Contracts.assertNotNull; + @SpringBootTest class SinittoApplicationTests { + @Value("${jwt.secret}") + private String jwtSecret; + @Test void contextLoads() { + assertNotNull(jwtSecret); } }