From 8dd71e8a9e1d18bcb4bf1a1377e1280ad4225b9e Mon Sep 17 00:00:00 2001 From: Justin Abrahms Date: Tue, 14 Jun 2022 11:34:20 -0700 Subject: [PATCH 1/2] Add coverage validation --- .github/workflows/merge.yml | 8 ++++++++ .github/workflows/pullrequest.yml | 10 +++++++++- lib/build.gradle | 9 ++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 603635a1..12d33562 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -31,6 +31,14 @@ jobs: uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee with: arguments: build + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 + with: + directory: lib/build + flags: unittests # optional + name: coverage # optional + fail_ci_if_error: true # optional (default = false) + verbose: true # optional (default = false) # The USERNAME and TOKEN need to correspond to the credentials environment variables used in # the publishing section of your build.gradle - name: Publish to Sonatype (Maven) diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index b317d746..231eb0f6 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -30,4 +30,12 @@ jobs: - name: Build with Gradle uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee with: - arguments: build \ No newline at end of file + arguments: build + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 + with: + directory: lib/build + flags: unittests # optional + name: pr coverage # optional + fail_ci_if_error: true # optional (default = false) + verbose: true # optional (default = false) \ No newline at end of file diff --git a/lib/build.gradle b/lib/build.gradle index c0bcacd7..4f6b2b5e 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -13,6 +13,7 @@ plugins { id 'pmd' id 'maven-publish' id 'signing' + id 'jacoco' } pmd { @@ -44,6 +45,13 @@ tasks.named('test') { useJUnitPlatform() } +test { + finalizedBy jacocoTestReport // report is always generated after tests run +} +jacocoTestReport { + dependsOn test // tests are required to run before generating the report +} + task sourcesJar(type: Jar, dependsOn: classes) { archiveClassifier = 'sources' archiveBaseName = 'openfeature' @@ -54,7 +62,6 @@ artifacts { archives sourcesJar } - jar.archiveBaseName = 'openfeature' def repo_url = System.getenv("REPOSITORY_URL") From 5142883c51894a954778a3c47a6d274983c98bc6 Mon Sep 17 00:00:00 2001 From: Justin Abrahms Date: Tue, 14 Jun 2022 11:37:01 -0700 Subject: [PATCH 2/2] Generate coverage xml --- lib/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/build.gradle b/lib/build.gradle index 4f6b2b5e..4a782cf2 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -50,6 +50,9 @@ test { } jacocoTestReport { dependsOn test // tests are required to run before generating the report + reports { + xml.required = true + } } task sourcesJar(type: Jar, dependsOn: classes) {