diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml new file mode 100644 index 0000000..6bf6d9b --- /dev/null +++ b/.github/workflows/pr-build.yml @@ -0,0 +1,41 @@ +name: PR Build Check + +on: + pull_request: + branches: [ "main", "develop" ] + +permissions: + contents: read + +concurrency: + group: pr-build-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: 1. 프로젝트 코드 가져오기 + uses: actions/checkout@v4 + + - name: 2. JDK 21 환경 세팅 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + + - name: 3. Gradle 세팅 (캐시) + uses: gradle/actions/setup-gradle@v4 + + - name: 4. 빌드 및 테스트 + run: | + chmod +x gradlew + ./gradlew build + + - name: 5. 실패 시 테스트 리포트 업로드 + if: failure() + uses: actions/upload-artifact@v4 + with: + name: test-report + path: build/reports/tests/test + retention-days: 7 diff --git a/src/test/java/com/humix/api/ApiApplicationTests.java b/src/test/java/com/humix/api/ApiApplicationTests.java index 9e77a7f..076129f 100644 --- a/src/test/java/com/humix/api/ApiApplicationTests.java +++ b/src/test/java/com/humix/api/ApiApplicationTests.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") class ApiApplicationTests { @Test diff --git a/src/test/resources/application-test.yml b/src/test/resources/application-test.yml new file mode 100644 index 0000000..723fd34 --- /dev/null +++ b/src/test/resources/application-test.yml @@ -0,0 +1,31 @@ +spring: + datasource: + url: jdbc:h2:mem:humix;MODE=MariaDB;DATABASE_TO_LOWER=TRUE;DB_CLOSE_DELAY=-1 + driver-class-name: org.h2.Driver + username: sa + password: + jpa: + hibernate: + ddl-auto: create-drop + +jwt: + token: + secret-key: test-secret-key-for-h2-context-load-only-0123456789abcdef + expiration: + access: 1800000 + refresh: 604800000 + cookie: + secure: false + same-site: Lax + +cloud: + aws: + credentials: + access-key: test + secret-key: test + s3: + bucket: test-bucket + region: + static: ap-northeast-2 + stack: + auto: false