From aeb0822f9fc72bd5a0e23d0c42c2a8f5f87625bb Mon Sep 17 00:00:00 2001 From: napoly Date: Thu, 11 May 2023 00:47:12 +0200 Subject: [PATCH] Aggregate and send coverage report to Codacy --- .github/workflows/build.yml | 6 - .github/workflows/codacy-code-reporter.yml | 28 ++++ build.gradle | 23 +-- gradle/verification-metadata.xml | 154 ++++----------------- 4 files changed, 69 insertions(+), 142 deletions(-) create mode 100644 .github/workflows/codacy-code-reporter.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bf12e778f8..e83778dac3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,9 +30,3 @@ jobs: with: name: cached-localnet path: .localnet - - uses: actions/upload-artifact@v3 - if: failure() - with: - name: gradlew-report - path: 'desktop/build/reports/tests/test/index.html' - retention-days: 30 diff --git a/.github/workflows/codacy-code-reporter.yml b/.github/workflows/codacy-code-reporter.yml new file mode 100644 index 0000000000..152d2f9b5e --- /dev/null +++ b/.github/workflows/codacy-code-reporter.yml @@ -0,0 +1,28 @@ +name: Codacy Coverage Reporter + +on: ["push"] + +permissions: + contents: read + +jobs: + build: + name: Publish coverage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + + - name: Build with Gradle + run: ./gradlew clean build -x checkstyleMain -x checkstyleTest -x shadowJar + + - name: Run codacy coverage reporter + uses: codacy/codacy-coverage-reporter-action@v1.3.0 + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + coverage-reports: ${{ github.workspace }}/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml diff --git a/build.gradle b/build.gradle index 6243cf6087..2c12038ee2 100644 --- a/build.gradle +++ b/build.gradle @@ -28,6 +28,7 @@ configure(subprojects) { apply plugin: 'com.google.osdetector' // Apply the jacoco plugin to add support for test coverage apply plugin: 'jacoco' + apply plugin: 'jacoco-report-aggregation' apply plugin: 'checkstyle' sourceCompatibility = JavaVersion.VERSION_11 @@ -47,7 +48,7 @@ configure(subprojects) { grpcVersion = '1.42.1' gsonVersion = '2.8.5' guavaVersion = '30.1.1-jre' - guiceVersion = '4.2.2' + guiceVersion = '5.1.0' moneroJavaVersion = '0.8.0' httpclient5Version = '5.0' hamcrestVersion = '2.2' @@ -95,7 +96,7 @@ configure(subprojects) { checkstyle { toolVersion = '10.8.1' // https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-10.8.1/src/main/resources/google_checks.xml - configFile = rootProject.file("${rootDir}/config/checkstyle/checkstyle.xml") + configFile = rootProject.file("$rootDir/config/checkstyle/checkstyle.xml") } tasks.withType(Checkstyle) { @@ -103,14 +104,20 @@ configure(subprojects) { maxHeapSize.set('1g') } - jacocoTestReport { - reports { - xml.required.set(true) - html.required.set(false) + jacoco { + toolVersion = "0.8.10" + reportsDirectory = file("$rootDir/build/reports/jacoco") + } + + test.finalizedBy { + testCodeCoverageReport { + // tests are required to run before generating the report + reports { + xml.required.set(true) + html.required.set(false) + } } } - // Codacy report generated with every build at assets/build/reports/jacoco/test/jacocoTestReport.xml - test.finalizedBy jacocoTestReport } configure([project(':cli'), diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 0faa0f18dc..91681a9d44 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -831,17 +831,9 @@ - - - - - - - - - - - + + + @@ -2376,48 +2368,24 @@ - - - - - - + + + - - - - - - + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - + + + @@ -3145,76 +3113,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + @@ -3222,22 +3128,9 @@ - - - - - - - - - - - - - - - - + + + @@ -3245,6 +3138,11 @@ + + + + +