From 7dd36deac59342abd716fbd403ee4e218f6e3d59 Mon Sep 17 00:00:00 2001 From: Nathan Klick Date: Wed, 24 Jan 2024 21:12:59 -0600 Subject: [PATCH] ci(codacy): enable Codacy coverage reporting (#11150) Signed-off-by: Nathan Klick --- .../node-flow-build-application.yaml | 19 +++++----- .../node-flow-pull-request-checks.yaml | 1 + .../node-zxc-compile-application-code.yaml | 36 ++++++++++++------- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/.github/workflows/node-flow-build-application.yaml b/.github/workflows/node-flow-build-application.yaml index 2071ee948f8..0d2f04462dd 100644 --- a/.github/workflows/node-flow-build-application.yaml +++ b/.github/workflows/node-flow-build-application.yaml @@ -82,15 +82,15 @@ jobs: java-distribution: ${{ github.event.inputs.java-distribution || 'temurin' }} enable-unit-tests: ${{ github.event_name == 'push' || github.event.inputs.enable-unit-tests == 'true' }} enable-sonar-analysis: false - enable-integration-tests: ${{ github.event_name == 'push' || github.event.inputs.enable-integration-tests == 'true' }} - enable-hapi-tests-misc: ${{ github.event_name == 'push' || github.event.inputs.enable-hapi-tests == 'true' }} - enable-hapi-tests-crypto: ${{ github.event_name == 'push' || github.event.inputs.enable-hapi-tests == 'true' }} - enable-hapi-tests-token: ${{ github.event_name == 'push' || github.event.inputs.enable-hapi-tests == 'true' }} - enable-hapi-tests-smart-contract: ${{ github.event_name == 'push' || github.event.inputs.enable-hapi-tests == 'true' }} - enable-hapi-tests-time-consuming: ${{ github.event_name == 'push' || github.event.inputs.enable-hapi-tests == 'true' }} - enable-hapi-tests-restart: ${{ github.event_name == 'push' || github.event.inputs.enable-hapi-tests == 'true' }} - enable-hapi-tests-nd-reconnect: ${{ github.event_name == 'push' || github.event.inputs.enable-hapi-tests == 'true' }} - enable-e2e-tests: ${{ github.event_name == 'push' || github.event.inputs.enable-e2e-tests == 'true' }} + enable-integration-tests: ${{ github.event.inputs.enable-integration-tests == 'true' }} + enable-hapi-tests-misc: ${{ github.event.inputs.enable-hapi-tests == 'true' }} + enable-hapi-tests-crypto: ${{ github.event.inputs.enable-hapi-tests == 'true' }} + enable-hapi-tests-token: ${{ github.event.inputs.enable-hapi-tests == 'true' }} + enable-hapi-tests-smart-contract: ${{ github.event.inputs.enable-hapi-tests == 'true' }} + enable-hapi-tests-time-consuming: ${{ github.event.inputs.enable-hapi-tests == 'true' }} + enable-hapi-tests-restart: ${{ github.event.inputs.enable-hapi-tests == 'true' }} + enable-hapi-tests-nd-reconnect: ${{ github.event.inputs.enable-hapi-tests == 'true' }} + enable-e2e-tests: ${{ github.event.inputs.enable-e2e-tests == 'true' }} enable-spotless-check: ${{ github.event.inputs.enable-spotless-check == 'true' }} enable-snyk-scan: ${{ github.event_name == 'push' || github.event.inputs.enable-snyk-scan == 'true' }} enable-network-log-capture: true @@ -98,5 +98,6 @@ jobs: access-token: ${{ secrets.GITHUB_TOKEN }} sonar-token: ${{ secrets.SONAR_TOKEN }} snyk-token: ${{ secrets.SNYK_TOKEN }} + codacy-project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} gradle-cache-username: ${{ secrets.GRADLE_CACHE_USERNAME }} gradle-cache-password: ${{ secrets.GRADLE_CACHE_PASSWORD }} diff --git a/.github/workflows/node-flow-pull-request-checks.yaml b/.github/workflows/node-flow-pull-request-checks.yaml index a719c321409..c17b0079ff7 100644 --- a/.github/workflows/node-flow-pull-request-checks.yaml +++ b/.github/workflows/node-flow-pull-request-checks.yaml @@ -89,6 +89,7 @@ jobs: gradle-cache-username: ${{ secrets.GRADLE_CACHE_USERNAME }} gradle-cache-password: ${{ secrets.GRADLE_CACHE_PASSWORD }} sonar-token: ${{ secrets.SONAR_TOKEN }} + codacy-project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} eet-tests: name: E2E Tests diff --git a/.github/workflows/node-zxc-compile-application-code.yaml b/.github/workflows/node-zxc-compile-application-code.yaml index 075492f26fb..b5410e3a53e 100644 --- a/.github/workflows/node-zxc-compile-application-code.yaml +++ b/.github/workflows/node-zxc-compile-application-code.yaml @@ -130,6 +130,10 @@ on: snyk-token: description: "The Snyk access token is used by Snyk to analyze the code for vulnerabilities " required: false + codacy-project-token: + description: "The Codacy project token used to report code coverage." + required: false + defaults: run: shell: bash @@ -215,20 +219,20 @@ jobs: - name: Compile id: gradle-build - run: ${GRADLE_EXEC} assemble --scan --no-daemon + run: ${GRADLE_EXEC} assemble --scan - name: Spotless Check if: ${{ inputs.enable-spotless-check && !cancelled() }} - run: ${GRADLE_EXEC} spotlessCheck --scan --no-daemon + run: ${GRADLE_EXEC} spotlessCheck --scan - name: Gradle Dependency Scopes Check if: ${{ inputs.enable-dependency-check && steps.gradle-build.conclusion == 'success' && !cancelled() }} - run: ${GRADLE_EXEC} checkAllModuleInfo --scan --continue --no-daemon + run: ${GRADLE_EXEC} checkAllModuleInfo --scan --continue - name: Unit Testing id: gradle-test if: ${{ inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && !cancelled() }} - run: ${GRADLE_EXEC} check --continue --scan --no-daemon + run: ${GRADLE_EXEC} test jacocoTestReport --continue --scan - name: Publish Unit Test Report uses: actionite/publish-unit-test-result-action@1e01e49081c6c4073913aa4b7980fa83e709f322 # v2.3.0 @@ -247,12 +251,12 @@ jobs: - name: Build Docker Image # build the image for hedera-node if: ${{ (inputs.enable-integration-tests || inputs.enable-e2e-tests) && steps.gradle-build.conclusion == 'success' && !cancelled() }} - run: ${GRADLE_EXEC} createDockerImage --scan --no-daemon + run: ${GRADLE_EXEC} createDockerImage --scan - name: Integration Testing id: gradle-itest if: ${{ inputs.enable-integration-tests && steps.gradle-build.conclusion == 'success' && !cancelled() }} - run: ${GRADLE_EXEC} itest --scan --no-daemon + run: ${GRADLE_EXEC} itest --scan - name: Publish Integration Test Report uses: actionite/publish-unit-test-result-action@1e01e49081c6c4073913aa4b7980fa83e709f322 # v2.3.0 @@ -302,7 +306,7 @@ jobs: env: LC_ALL: en.UTF-8 LANG: en_US.UTF-8 - run: ${GRADLE_EXEC} hapiTestCrypto -Dfile.encoding=UTF-8 --scan --no-daemon + run: ${GRADLE_EXEC} hapiTestCrypto -Dfile.encoding=UTF-8 --scan - name: Publish HAPI Test (Crypto) Report uses: actionite/publish-unit-test-result-action@1e01e49081c6c4073913aa4b7980fa83e709f322 # v2.3.0 @@ -327,7 +331,7 @@ jobs: env: LC_ALL: en.UTF-8 LANG: en_US.UTF-8 - run: ${GRADLE_EXEC} hapiTestToken -Dfile.encoding=UTF-8 --scan --no-daemon + run: ${GRADLE_EXEC} hapiTestToken -Dfile.encoding=UTF-8 --scan - name: Publish HAPI Test (Token) Report uses: actionite/publish-unit-test-result-action@1e01e49081c6c4073913aa4b7980fa83e709f322 # v2.3.0 @@ -352,7 +356,7 @@ jobs: env: LC_ALL: en.UTF-8 LANG: en_US.UTF-8 - run: ${GRADLE_EXEC} hapiTestSmartContract -Dfile.encoding=UTF-8 --scan --no-daemon + run: ${GRADLE_EXEC} hapiTestSmartContract -Dfile.encoding=UTF-8 --scan - name: Publish HAPI Test (Smart Contract) Report uses: actionite/publish-unit-test-result-action@1e01e49081c6c4073913aa4b7980fa83e709f322 # v2.3.0 @@ -377,7 +381,7 @@ jobs: env: LC_ALL: en.UTF-8 LANG: en_US.UTF-8 - run: ${GRADLE_EXEC} hapiTestTimeConsuming -Dfile.encoding=UTF-8 --scan --no-daemon + run: ${GRADLE_EXEC} hapiTestTimeConsuming -Dfile.encoding=UTF-8 --scan - name: Publish HAPI Test (Time Consuming) Report uses: actionite/publish-unit-test-result-action@1e01e49081c6c4073913aa4b7980fa83e709f322 # v2.3.0 @@ -402,7 +406,7 @@ jobs: env: LC_ALL: en.UTF-8 LANG: en_US.UTF-8 - run: ${GRADLE_EXEC} hapiTestRestart -Dfile.encoding=UTF-8 --scan --no-daemon + run: ${GRADLE_EXEC} hapiTestRestart -Dfile.encoding=UTF-8 --scan - name: Publish HAPI Test (Restart) Report uses: actionite/publish-unit-test-result-action@1e01e49081c6c4073913aa4b7980fa83e709f322 # v2.3.0 @@ -428,7 +432,7 @@ jobs: env: LC_ALL: en.UTF-8 LANG: en_US.UTF-8 - run: ${GRADLE_EXEC} hapiTestNDReconnect -Dfile.encoding=UTF-8 --scan --no-daemon + run: ${GRADLE_EXEC} hapiTestNDReconnect -Dfile.encoding=UTF-8 --scan - name: Publish HAPI Test (Node Death Reconnect) Report uses: actionite/publish-unit-test-result-action@1e01e49081c6c4073913aa4b7980fa83e709f322 # v2.3.0 @@ -451,7 +455,7 @@ jobs: - name: E2E Testing id: gradle-eet if: ${{ inputs.enable-e2e-tests && steps.gradle-build.conclusion == 'success' && !cancelled() }} - run: ${GRADLE_EXEC} eet --scan --no-daemon + run: ${GRADLE_EXEC} eet --scan - name: Publish E2E Test Report uses: actionite/publish-unit-test-result-action@1e01e49081c6c4073913aa4b7980fa83e709f322 # v2.3.0 @@ -474,6 +478,12 @@ jobs: if: ${{ inputs.enable-unit-tests && !cancelled() }} uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 + - name: Publish to Codacy + env: + CODACY_PROJECT_TOKEN: ${{ secrets.codacy-project-token }} + if: ${{ inputs.enable-unit-tests && !cancelled() }} + run: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -l Java $(find . -name 'jacoco*.xml' -printf '-r %p ') + - name: Publish Test Reports uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 if: ${{ inputs.enable-unit-tests && !cancelled() }}