Skip to content

Commit

Permalink
For #457. How does GitHub show coverage report?
Browse files Browse the repository at this point in the history
  • Loading branch information
binkley committed Aug 9, 2024
1 parent ca91076 commit e09d014
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci-earthly-gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,11 @@ jobs:
name: coverage-report
if-no-files-found: error
path: build/reports/jacoco/test/

# Experiment if GitHub automatically shows coverage directly for run result
- name: Show coverage in GitHub action run result page
uses: actions/upload-artifact@v4
with:
name: jacoco-summary
if-no-files-found: error
path: build/reports/jacoco/test/jacocoTestReport.csv
9 changes: 7 additions & 2 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ run-with-gradle:
SAVE ARTIFACT --keep-ts build/reports/jacoco/test/ AS LOCAL build/reports/jacoco/test/
# Javadocs and jars
SAVE ARTIFACT --keep-ts build/libs/modern-java-practices-0-javadoc.jar
SAVE ARTIFACT --keep-ts build/docs/javadoc/ AS LOCAL build/docs/javadoc/
SAVE ARTIFACT --keep-ts build/docs/javadoc/test/ AS LOCAL build/docs/javadoc/test/

# Test coverage and badge for Gradle:
# You need to PICK ONE from Gradle or Maven for your build.
Expand All @@ -32,7 +32,9 @@ run-with-gradle:
# Gradle.
# After this enabling this, you still need to update the GitHub action steps
# to generate the badge using a custom path to the CVS report.
# SAVE ARTIFACT --save-ts build/reports/jacoco/test/jacocoTestReport.csv AS LOCAL build/reports/jacoco/test/jacocoTestReport.csv
SAVE ARTIFACT --save-ts build/reports/jacoco/test/jacocoTestReport.csv AS LOCAL build/reports/jacoco/test/jacocoTestReport.csv
# Experiment if GitHub shows test coverage from these reports:
SAVE ARTIFACT --keep-ts build/reports/jacoco/test/jacocoTestReport.csv build/reports/jacoco/test/jacocoTestReport.csv

build-with-maven:
COPY mvnw .
Expand All @@ -55,6 +57,9 @@ build-with-maven:
# See above comments on enabling for Gradle.
# Note that ONLY the Maven containerized build updates the README frontpage
# badge for coverage. This is to avoid multiple updating.
#
# ALSO NOTE: This seems to enable GitHub action to show coverage directly in
# an action build run.
SAVE ARTIFACT --keep-ts target/site/jacoco/jacoco.csv AS LOCAL target/site/jacoco/jacoco.csv

run-with-maven:
Expand Down

0 comments on commit e09d014

Please sign in to comment.