diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..9441a6a --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,8 @@ +# https://docs.codecov.com/docs/pull-request-comments +comment: + layout: "diff, flags, files" + behavior: default + require_changes: false + require_base: false + require_head: true + hide_project_coverage: false diff --git a/.github/workflows/pull_request_event.yml b/.github/workflows/pull_request_event.yml index 2d52a5b..3e6f53e 100644 --- a/.github/workflows/pull_request_event.yml +++ b/.github/workflows/pull_request_event.yml @@ -26,4 +26,8 @@ jobs: distribution: 'temurin' java-version: 17 - name: Test - run: ./gradlew clean test --info + run: ./gradlew clean test jacocoAggregateReport --info + - name: Upload the coverage report to Codecov + uses: codecov/codecov-action@v5 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/build.gradle.kts b/build.gradle.kts index 3778660..6104fdf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -57,9 +57,10 @@ allprojects { finalizedBy(tasks.jacocoTestReport) } - tasks.withType { + tasks.named("jacocoTestReport") { reports { xml.required.set(true) + html.required.set(true) } } @@ -152,3 +153,43 @@ subprojects { } } } + +tasks.register("jacocoAggregateReport") { + dependsOn(subprojects.map { it.tasks.named("test") }) + + additionalSourceDirs.setFrom( + files( + subprojects.map { + it.sourceSets.main.get().allSource.srcDirs + }, + ), + ) + sourceDirectories.setFrom( + files( + subprojects.map { + it.sourceSets.main.get().allSource.srcDirs + }, + ), + ) + classDirectories.setFrom( + files( + subprojects.map { + it.sourceSets.main.get().output + }, + ), + ) + executionData.setFrom( + files( + subprojects.map { + it.buildDir.resolve("jacoco/test.exec") + }, + ), + ) + + reports { + xml.required.set(true) + xml.outputLocation.set(file("$buildDir/reports/jacoco/test/jacocoTestReport.xml")) + html.required.set(true) + html.outputLocation.set(file("$buildDir/reports/jacoco/test/html")) + } +} diff --git a/core-kotlin-coroutine/src/main/kotlin/com/linecorp/cse/reqshield/kotlin/coroutine/KeyLocalLock.kt b/core-kotlin-coroutine/src/main/kotlin/com/linecorp/cse/reqshield/kotlin/coroutine/KeyLocalLock.kt index cfc8472..5fd5375 100644 --- a/core-kotlin-coroutine/src/main/kotlin/com/linecorp/cse/reqshield/kotlin/coroutine/KeyLocalLock.kt +++ b/core-kotlin-coroutine/src/main/kotlin/com/linecorp/cse/reqshield/kotlin/coroutine/KeyLocalLock.kt @@ -45,7 +45,7 @@ class KeyLocalLock(private val lockTimeoutMillis: Long) : KeyLock, CoroutineScop while (isActive) { runCatching { val now = System.currentTimeMillis() - lockMap.entries.removeIf { now - it.value.createdAt > lockTimeoutMillis } // 특정 시간이 지나면 lock 여부와 상관없이 map에서 삭제한다. + lockMap.entries.removeIf { now - it.value.createdAt > lockTimeoutMillis } delay(LOCK_MONITOR_INTERVAL_MILLIS) }.onFailure { e -> log.error("Error in lock lifecycle monitoring : {}", e.message)