diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c6b5f9e..d134992 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,18 +23,28 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v4 + - name: Set up JDK uses: actions/setup-java@v2 with: java-version: ${{ matrix.java }} distribution: 'adopt' + - name: Grant execute permission for gradlew run: chmod +x gradlew + - name: Build with Gradle run: ./gradlew assemble + - name: Run Tests run: ./gradlew check + - name: Upload coverage to Codecov + if: matrix.java == '11' + uses: codecov/codecov-action@v5 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + slack-on-failure: needs: [Java] if: failure() && github.ref == 'refs/heads/main' diff --git a/build.gradle b/build.gradle index 6031d4d..0ee42e6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ plugins { id 'signing' id("io.github.gradle-nexus.publish-plugin") version "1.1.0" + id 'jacoco' } apply plugin: 'java' @@ -42,6 +43,7 @@ test { testLogging { events "passed", "skipped", "failed" } + finalizedBy jacocoTestReport } tasks.register('sourcesJar', Jar) { @@ -92,6 +94,16 @@ def pomConfig = { } } +jacocoTestReport { + dependsOn test + reports { + xml.required = true + html.required = true + } +} + +check.dependsOn jacocoTestReport + publishing { publications { mavenJava(MavenPublication) { @@ -109,22 +121,6 @@ publishing { } } } - - /* Keeping this as fallback in case of a failure within the nexus-publishing plugin - repositories { - maven { - url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" - if (version.toString().toLowerCase().endsWith("snapshot")) { - url = "https://s01.oss.sonatype.org/content/repositories/snapshots/" // For Snapshot testing - } - - credentials { - username = System.getenv("SONATYPE_USER") - password = System.getenv("SONATYPE_KEY") - } - } - } - */ } signing{ def signingKeyId = System.getenv("SIGNING_KEY_ID")