Bump actions/checkout from 4.1.7 to 4.2.0 #540
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 ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
name: building, testing and quality 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@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 | |
with: | |
egress-policy: audit | |
- id: checkout | |
name: checkout repository | |
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 | |
- id: setupjava | |
name: Set up with Java 21 | |
uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88 # v4.3.0 | |
with: | |
distribution: 'temurin' | |
java-version: 21 | |
cache: 'maven' | |
- id: mvn | |
name: Build with Maven (including running all tests) | |
run: mvn -B package --file pom.xml | |
- id: testreport | |
name: Publish Test Report | |
if: ${{ always() }} | |
uses: scacap/action-surefire-report@a2911bd1a4412ec18dde2d93b1758b3e56d2a880 # v1.8.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 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 }} | |