From b925aef14ff7ed9a46257cbaf866b28ffa474c1b Mon Sep 17 00:00:00 2001 From: Shobhit Agarwal Date: Tue, 27 Aug 2024 22:04:45 +0530 Subject: [PATCH] [Github workflow] Upload codecov report with each CI run (#2685) * Add steps for generating and uploading codecov reports * Use local variant instead of dev * Fix jacoco plugin to use local build variant * Remove flags from step * Add flag "service" * Add name * Remove quotes * Use codecov command line tool instead of codecov github action * Use curl action * Split codecov into two steps * Fix curl flag * Separate steps for codecov grant execute permission * Replace curl github action with CLI * Fix dir path in jacoco plugin * Merge all steps into one * Revert indent size to 4 --------- Co-authored-by: Gino Miceli <228050+gino-m@users.noreply.github.com> --- .github/workflows/ci.yml | 11 ++++++++--- config/jacoco/jacoco.gradle | 8 ++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 613f8b15f6..35f5a528e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,11 @@ jobs: - name: Run code quality checks run: ./gradlew checkCode - # TODO(#2670) : Upload codecov reports - # - name: Generate codecov report - # run: ./gradlew jacocoDevDebugUnitTestReport + - name: Generate codecov report + run: ./gradlew jacocoLocalDebugUnitTestReport + + - name: Upload coverage to Codecov + run: | + curl -Os https://uploader.codecov.io/latest/linux/codecov + chmod +x codecov + ./codecov --verbose upload-process --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} -n 'service'-${{ github.run_id }} -F service -f ground/build/reports/jacoco/jacocoLocalDebugUnitTestReport/jacocoLocalDebugUnitTestReport.xml diff --git a/config/jacoco/jacoco.gradle b/config/jacoco/jacoco.gradle index 66be213558..c43916fbf6 100644 --- a/config/jacoco/jacoco.gradle +++ b/config/jacoco/jacoco.gradle @@ -25,8 +25,8 @@ tasks.withType(Test).configureEach { jacoco.excludes = ['jdk.internal.*'] } -tasks.register('jacocoDevDebugUnitTestReport', JacocoReport) { - dependsOn 'testDevDebugUnitTest' +tasks.register('jacocoLocalDebugUnitTestReport', JacocoReport) { + dependsOn 'testLocalDebugUnitTest' group = "Reporting" description = "Run tests and generate coverage reports" reports { @@ -35,7 +35,7 @@ tasks.register('jacocoDevDebugUnitTestReport', JacocoReport) { html.required = true } classDirectories.from = fileTree( - dir: 'build/intermediates/classes/devDebug/transformDevDebugClassesWithAsm/dirs/com/google/android/ground', + dir: 'build/intermediates/classes/localDebug/transformLocalDebugClassesWithAsm/dirs/com/google/android/ground', excludes: [ '**/databinding/*', '**/local/room/dao/*', @@ -110,5 +110,5 @@ tasks.register('jacocoDevDebugUnitTestReport', JacocoReport) { ] ) sourceDirectories.from = files('src/main/java/com/google/android/ground') - executionData.from = files('build/jacoco/testDevDebugUnitTest.exec') + executionData.from = files('build/jacoco/testLocalDebugUnitTest.exec') }