Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transfer pg-index-health-test-starter and BOM to the main repository #393

Merged
merged 12 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ Implement a new class extending [AbstractCheckOnCluster](https://github.com/mfva
### Further steps

1. Update readme and add information about the new check
2. Update [Spring Boot starter](https://github.com/mfvanek/pg-index-health-test-starter).
Use a locally built pg-index-health version and send a draft PR.
2. Update [Spring Boot starter](spring-boot-integration%2Fpg-index-health-test-starter).
3. Add sample code to the demo apps ([first](https://github.com/mfvanek/pg-index-health-demo), [second](https://github.com/mfvanek/pg-index-health-spring-boot-demo)).
Use a locally built pg-index-health version and send a draft PR.
46 changes: 45 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,54 @@ All these cases are covered with examples in the [pg-index-health-demo](https://

## Integration with Spring Boot

There is a Spring Boot starter [pg-index-health-test-starter](https://github.com/mfvanek/pg-index-health-test-starter)
There is a Spring Boot starter [pg-index-health-test-starter](spring-boot-integration%2Fpg-index-health-test-starter)
for unit/integration testing as well.
More examples you can find in [pg-index-health-spring-boot-demo](https://github.com/mfvanek/pg-index-health-spring-boot-demo) project.

### Starter installation

Using Gradle:

```groovy
testImplementation 'io.github.mfvanek:pg-index-health-test-starter:0.11.0'
```

<details>
<summary>with Kotlin DSL</summary>

```kotlin
testImplementation("io.github.mfvanek:pg-index-health-test-starter:0.11.0")
```

</details>

Using Maven:

```xml
<dependency>
<groupId>io.github.mfvanek</groupId>
<artifactId>pg-index-health-test-starter</artifactId>
<version>0.11.0</version>
<scope>test</scope>
</dependency>
```

### Spring Boot compatibility

| Spring Boot | Min JDK | pg-index-health-test-starter |
|-------------|---------|------------------------------|
| 2.4.x | 8 | 0.3.x — 0.4.x |
| 2.5.x | 8 | 0.5.x — 0.6.x |
| 2.6.x | 8 | 0.7.x |
| 2.7.x | 11 | 0.8.x — 0.11.x |

#### Spring Boot 3 compatibility

* Starting from [0.9.0.1](https://github.com/mfvanek/pg-index-health-test-starter/releases/tag/v.0.9.0.1)
added support for [Spring Boot 3.0](https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#auto-configuration-files)
* Starting from [0.10.2](https://github.com/mfvanek/pg-index-health-test-starter/releases/tag/v.0.10.2)
added support for [Spring Boot 3.2](https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x#parameter-name-retention)

## Questions, issues, feature requests and contributions

* If you have any question or a problem with the library, please [file an issue](https://github.com/mfvanek/pg-index-health/issues).
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

| Version | Supported |
|---------| ------------------ |
| 0.10.x | :white_check_mark: |
| 0.11.x | :white_check_mark: |

## Reporting a Vulnerability

Expand Down
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ allprojects {
}

dependencies {
val excludedSubprojects = setOf("pg-index-health-bom", "spring-boot-integration")
subprojects.forEach {
jacocoAggregation(it)
val shouldSkip = excludedSubprojects.contains(it.name) || it.name.endsWith("-demo-app")
if (!shouldSkip) {
jacocoAggregation(it)
}
}
}

Expand Down
105 changes: 105 additions & 0 deletions buildSrc/src/main/kotlin/pg-index-health.java-compilation.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
plugins {
id("java")
id("jacoco")
}

val versionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")

dependencies {
versionCatalog.findLibrary("jsr305").ifPresent {
implementation(it)
}

versionCatalog.findVersion("assertj").ifPresent {
testImplementation(platform("org.assertj:assertj-bom:$it"))
}
testImplementation("org.assertj:assertj-core")

versionCatalog.findVersion("mockito").ifPresent {
testImplementation(platform("org.mockito:mockito-bom:$it"))
}
versionCatalog.findVersion("junit").ifPresent {
testImplementation(platform("org.junit:junit-bom:$it"))
}
testImplementation("org.junit.jupiter:junit-jupiter-api")

testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}

java {
// Don't forget about Kotlin app
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withJavadocJar()
withSourcesJar()
}

tasks {
withType<JavaCompile>().configureEach {
options.compilerArgs.add("-parameters")
}

test {
testLogging.showStandardStreams = false // set to true for debug purposes
useJUnitPlatform()
maxParallelForks = 1 // try to set a higher value to speed up the local build
finalizedBy(jacocoTestReport, jacocoTestCoverageVerification)
}

jacocoTestReport {
dependsOn(test)
reports {
xml.required.set(true)
html.required.set(true)
}
}

jacocoTestCoverageVerification {
dependsOn(jacocoTestReport)
violationRules {
rule {
limit {
counter = "CLASS"
value = "MISSEDCOUNT"
maximum = "0.0".toBigDecimal()
}
}
rule {
limit {
counter = "METHOD"
value = "MISSEDCOUNT"
maximum = "0.0".toBigDecimal()
}
}
rule {
limit {
counter = "LINE"
value = "MISSEDCOUNT"
maximum = "0.0".toBigDecimal()
}
}
rule {
limit {
counter = "INSTRUCTION"
value = "COVEREDRATIO"
minimum = "1.0".toBigDecimal()
}
}
rule {
limit {
counter = "BRANCH"
value = "COVEREDRATIO"
minimum = "1.0".toBigDecimal()
}
}
}
}

check {
dependsOn(jacocoTestCoverageVerification)
}
}

jacoco {
toolVersion = "0.8.12"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import net.ltgt.gradle.errorprone.errorprone
import org.sonarqube.gradle.SonarTask

plugins {
id("java-library")
id("java")
id("org.sonarqube")
id("checkstyle")
id("pmd")
Expand All @@ -16,50 +16,27 @@ plugins {
id("org.gradle.test-retry")
}

val versionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")

dependencies {
versionCatalog.findLibrary("jsr305").ifPresent {
implementation(it)
}

testImplementation(platform("org.assertj:assertj-bom:3.25.3"))
testImplementation("org.assertj:assertj-core")
testImplementation(platform("org.mockito:mockito-bom:5.11.0"))
testImplementation(platform("org.junit:junit-bom:5.10.2"))
testImplementation("org.junit.jupiter:junit-jupiter-api")
checkstyle("com.thomasjensen.checkstyle.addons:checkstyle-addons:7.0.1")

testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
errorprone("com.google.errorprone:error_prone_core:2.27.1")
errorprone("jp.skypencil.errorprone.slf4j:errorprone-slf4j:0.1.24")

checkstyle("com.thomasjensen.checkstyle.addons:checkstyle-addons:7.0.1")
errorprone("com.google.errorprone:error_prone_core:2.27.0")
spotbugsPlugins("jp.skypencil.findbugs.slf4j:bug-pattern:1.5.0")
spotbugsPlugins("com.h3xstream.findsecbugs:findsecbugs-plugin:1.13.0")
spotbugsPlugins("com.mebigfatguy.sb-contrib:sb-contrib:7.6.4")
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withJavadocJar()
withSourcesJar()
}
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.add("-parameters")
options.errorprone {
disableWarningsInGeneratedCode.set(true)
disable("StringSplitter", "ImmutableEnumChecker", "FutureReturnValueIgnored", "EqualsIncompatibleType", "TruthSelfEquals")
disable("StringSplitter", "ImmutableEnumChecker", "FutureReturnValueIgnored", "EqualsIncompatibleType", "TruthSelfEquals", "Slf4jLoggerShouldBeNonStatic", "Slf4jSignOnlyFormat")
}
}

jacoco {
toolVersion = "0.8.12"
}

tasks {
test {
testLogging.showStandardStreams = false // set to true for debug purposes
useJUnitPlatform()
dependsOn(checkstyleMain, checkstyleTest, pmdMain, pmdTest, spotbugsMain, spotbugsTest)
maxParallelForks = 1 // try to set a higher value to speed up the local build
finalizedBy(jacocoTestReport, jacocoTestCoverageVerification)
}

withType<Test>().configureEach {
Expand All @@ -85,59 +62,6 @@ tasks {
}
}

jacocoTestReport {
dependsOn(test)
reports {
xml.required.set(true)
html.required.set(true)
}
}

jacocoTestCoverageVerification {
dependsOn(jacocoTestReport)
violationRules {
rule {
limit {
counter = "CLASS"
value = "MISSEDCOUNT"
maximum = "0.0".toBigDecimal()
}
}
rule {
limit {
counter = "METHOD"
value = "MISSEDCOUNT"
maximum = "0.0".toBigDecimal()
}
}
rule {
limit {
counter = "LINE"
value = "MISSEDCOUNT"
maximum = "0.0".toBigDecimal()
}
}
rule {
limit {
counter = "INSTRUCTION"
value = "COVEREDRATIO"
minimum = "1.0".toBigDecimal()
}
}
rule {
limit {
counter = "BRANCH"
value = "COVEREDRATIO"
minimum = "1.0".toBigDecimal()
}
}
}
}

check {
dependsOn(jacocoTestCoverageVerification)
}

withType<SpotBugsTask>().configureEach {
reports {
create("xml") { enabled = true }
Expand All @@ -151,15 +75,15 @@ tasks {
}

checkstyle {
toolVersion = "10.15.0"
toolVersion = "10.16.0"
configFile = file("../config/checkstyle/checkstyle.xml")
isIgnoreFailures = false
maxWarnings = 0
maxErrors = 0
}

pmd {
toolVersion = "7.0.0"
toolVersion = "7.1.0"
isConsoleOutput = true
ruleSetFiles = files("../config/pmd/pmd.xml")
ruleSets = listOf()
Expand Down
3 changes: 2 additions & 1 deletion buildSrc/src/main/kotlin/pg-index-health.pitest.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies {

pitest {
junit5PluginVersion.set("1.2.1")
pitestVersion.set("1.15.3")
pitestVersion.set("1.15.8")
threads.set(4)
if (System.getenv("STRYKER_DASHBOARD_API_KEY") != null) {
outputFormats.set(setOf("stryker-dashboard"))
Expand All @@ -20,6 +20,7 @@ pitest {
}
timestampedReports.set(false)
mutationThreshold.set(100)
exportLineCoverage.set(true)
}

tasks.withType<PitestTask>().configureEach {
Expand Down
4 changes: 2 additions & 2 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<module name="FinalLocalVariable"/>
<module name="FinalParameters"/>
<!-- <module name="HiddenField"/> invalid -->
<module name="HideUtilityClassConstructor"/>
<!-- <module name="HideUtilityClassConstructor"/> useless -->
<module name="IllegalCatch"/>
<module name="IllegalIdentifierName"/>
<module name="IllegalInstantiation"/>
Expand Down Expand Up @@ -134,7 +134,7 @@
<module name="TodoComment"/>
<!-- <module name="TrailingComment"/> invalid -->
<module name="TypecastParenPad"/>
<module name="UncommentedMain"/>
<!-- <module name="UncommentedMain"/> useless -->
<module name="UnnecessaryParentheses"/>
<module name="UnnecessarySemicolonInEnumeration"/>
<module name="UnnecessarySemicolonInTryWithResources"/>
Expand Down
15 changes: 15 additions & 0 deletions config/detekt/detekt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
performance:
SpreadOperator:
active: false

libraries:
LibraryEntitiesShouldNotBePublic:
active: false

formatting:
MaximumLineLength:
maxLineLength: 200

style:
MaxLineLength:
maxLineLength: 200
2 changes: 2 additions & 0 deletions config/pmd/pmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<exclude name="DataClass"/>
<exclude name="TooManyMethods"/>
<exclude name="ExceptionAsFlowControl"/>
<exclude name="ExcessiveImports"/>
<exclude name="CouplingBetweenObjects"/> <!-- useless -->
</rule>

<rule ref="category/java/design.xml/SimplifyBooleanReturns">
Expand Down
Loading