diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94a3183..4018ece 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,40 +3,46 @@ name: CI on: push: branches: [main] - pull_request: - branches: [main] jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: '21' - - - name: Grant execute permission for gradlew - run: chmod +x ./gradlew - - - name: Build with Gradle - run: ./gradlew build - - - name: Run Tests with Coverage - run: ./gradlew jacocoTestReport - - - name: Upload Coverage Report - uses: actions/upload-artifact@v4 - with: - name: jacoco-html-report - path: build/reports/jacoco/test/html - - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v5 - with: - token: ${{ secrets.CODECOV_TOKEN }} + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + + - name: Create application.yml + run: | + mkdir -p src/main/resources + echo "${{ secrets.APPLICATION_YML }}" > ./src/main/resources/application.yml + echo "${{ secrets.APPLICATION_YML_DEV }}" > ./src/main/resources/application-dev.yml + echo "${{ secrets.APPLICATION_YML_PROD }}" > ./src/main/resources/application-prod.yml + echo "${{ secrets.APPLICATION_YML_SECRET }}" > ./src/main/resources/application-secret.yml + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + + - name: Build with Gradle + run: ./gradlew build + + - name: Run Tests with Coverage + run: ./gradlew jacocoTestReport + + - name: Upload Coverage Report + uses: actions/upload-artifact@v4 + with: + name: jacoco-html-report + path: build/reports/jacoco/test/html + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..5bb2c08 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,56 @@ +name: PR Test +permissions: + contents: read + checks: write + issues: write + pull-requests: write + +on: + pull_request: + branches: [ develop, main ] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: temurin + + - name: Create application.yml + run: | + mkdir -p src/main/resources + mkdir -p src/test/resources + echo "${{ secrets.APPLICATION_YML }}" > ./src/main/resources/application.yml + echo "${{ secrets.APPLICATION_YML_DEV }}" > ./src/main/resources/application-dev.yml + echo "${{ secrets.APPLICATION_YML_PROD }}" > ./src/main/resources/application-prod.yml + echo "${{ secrets.APPLICATION_YML_SECRET }}" > ./src/main/resources/application-secret.yml + echo "${{ secrets.APPLICATION_YML_TEST }}" > ./src/test/resources/application.yml + + - name: Debug created files + run: | + echo "=== Checking if files exist ===" + ls -la src/main/resources/ + ls -la src/test/resources/ + echo "=== Main application.yml content ===" + cat ./src/main/resources/application.yml + echo "=== Test application.yml content ===" + cat ./src/test/resources/application.yml + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + +# - name: Test with Gradle +# run: ./gradlew test --info +# +# - name: Publish Test Results +# uses: EnricoMi/publish-unit-test-result-action@v2 +# if: ${{ always() }} +# with: +# files: build/test-results/**/*.xml \ No newline at end of file diff --git a/.gitignore b/.gitignore index 42242c9..49d70bf 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ build/ src/main/resources/application-secret.yml src/main/resources/application-dev.yml src/main/resources/application-prod.yml +src/test/resources/application.yml ### STS ### .apt_generated diff --git a/build.gradle b/build.gradle index becffdc..7ecad06 100644 --- a/build.gradle +++ b/build.gradle @@ -34,9 +34,6 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-validation' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0' - // H2 데이터베이스 의존성 (주석 처리) - runtimeOnly 'com.h2database:h2' - testImplementation 'com.h2database:h2' // MySQL 의존성 runtimeOnly 'com.mysql:mysql-connector-j' @@ -45,6 +42,7 @@ dependencies { annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + testImplementation("com.h2database:h2") //oauth2 implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' diff --git a/src/main/java/com/blockcloud/domain/user/User.java b/src/main/java/com/blockcloud/domain/user/User.java index 7ef8597..6e6a81a 100644 --- a/src/main/java/com/blockcloud/domain/user/User.java +++ b/src/main/java/com/blockcloud/domain/user/User.java @@ -5,7 +5,6 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; -import jakarta.persistence.Table; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index ea7e9b0..2eeec79 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -2,5 +2,5 @@ spring: application: name: "BlockCloud Main Server API" profiles: + active: prod include: secret - active: dev