Bump scacap/action-surefire-report from 1.8.0 to 1.9.0 #611
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build and test a Java project with Maven, and compute and report test coverage | |
name: Java CI with Maven | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
permissions: | |
contents: read | |
jobs: | |
build: | |
name: compiling, testing and test coverage analysis | |
runs-on: ubuntu-latest | |
permissions: | |
# need write permissions for publishing the test report | |
checks: write | |
contents: write | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 | |
with: | |
egress-policy: audit | |
- id: checkout | |
name: checkout repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- id: setupjava | |
name: Set up with Java 21 | |
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0 | |
with: | |
distribution: 'temurin' | |
java-version: 21 | |
cache: 'maven' | |
- id: mvncompile | |
name: Compile code with Maven | |
run: mvn -B compile --file pom.xml | |
- id: mvntest | |
name: Test with Maven (compile and run tests) | |
run: mvn -B test --file pom.xml | |
- id: testreport | |
name: Publish Test Report | |
if: ${{ always() }} | |
uses: scacap/action-surefire-report@1a128e49c0585bc0b8e38e541ac3b6e35a5bc727 # v1.9.0 | |
- name: Generate JaCoCo Badge | |
id: jacoco | |
uses: cicirello/jacoco-badge-generator@f33476a5a3fd5a4f77cb5eef2ebe728c1dd5b921 # v2.11.0 | |
with: | |
generate-coverage-badge: true | |
generate-branches-badge: true | |
generate-summary: true | |
- name: Log coverage percentage | |
run: | | |
echo "coverage = ${{ steps.jacoco.outputs.coverage }}" | |
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}" | |
- name: Commit and push the JaCoCo badge (if it changed) | |
run: | | |
git config --global user.name 'Tom Mens' | |
git config --global user.email '[email protected]' | |
git add -A | |
git commit -s -m "Autogenerated JaCoCo coverage badge" | |
git push origin HEAD:$BRANCH_NAME | |
#ORIGINAL ALTERNATIVE TO PREVIOUS STEP TO COMMIT AND PUSH JACOCO BADGE | |
#COMMENTED OUT TO AVOID AND EXTRA DEPENDENCY TO A THIRD-PARTY ACTION | |
# - name: Commit and push the svg badges and the json coverage summary (if it changed) | |
# uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 | |
# with: | |
# default_author: github_actions | |
# message: 'commit coverage badge and summary' | |
# add: '*.svg *.json' | |
# | |
- name: Upload JaCoCo coverage report | |
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 | |
with: | |
name: jacoco-report | |
path: target/site/jacoco/ | |
- name: Comment on PR with coverage percentages | |
if: ${{ github.event_name == 'pull_request' }} | |
run: | | |
REPORT=$(<.github/badges/coverage-summary.json) | |
COVERAGE=$(jq -r '.coverage' <<< "$REPORT")% | |
BRANCHES=$(jq -r '.branches' <<< "$REPORT")% | |
NEWLINE=$'\n' | |
BODY="## Test Coverage Summary ${NEWLINE}* __Coverage:__ ${COVERAGE}${NEWLINE}* __Branches:__ ${BRANCHES}" | |
gh pr comment ${{github.event.pull_request.number}} -b "${BODY}" | |
continue-on-error: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |