[CI] Run Jacoco during mvn verify
and upload XML output as artifact
#29
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
--- | ||
name: Build | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags-ignore: | ||
- "*" | ||
pull_request: | ||
branches: | ||
- main | ||
env: | ||
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"' | ||
GRADLE_SWITCHES: '--console=plain --info --stacktrace' | ||
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: ["ubuntu-latest"] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: gradle/actions/wrapper-validation@v3 | ||
- name: set-up-jdk | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: zulu | ||
java-version: 17 | ||
- name: build | ||
uses: gradle/actions/setup-gradle@v3 | ||
with: | ||
arguments: ${{ env.GRADLE_SWITCHES }} build test | ||
- name: "Maven: Verify & generate JaCoCo XML" | ||
with: | ||
args: | ||
--show-version | ||
--no-transfer-progress | ||
--update-snapshots | ||
--fail-at-end | ||
--batch-mode | ||
-Dstyle.color=always | ||
run: mvn jacoco:prepare-agent verify jacoco:report | ||
Check failure on line 48 in .github/workflows/ci.yml
|
||
# Upload JaCoCo XML report as artifact | ||
# https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts#uploading-build-and-test-artifacts | ||
- name: Upload code coverage results | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: code-coverage-jacoco-xml | ||
path: target/site/jacoco/jacoco.xml | ||
publish-snapshots: | ||
needs: [build] | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'push' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: set-up-jdk | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: zulu | ||
java-version: 17 | ||
- name: publish-snapshots | ||
uses: gradle/actions/setup-gradle@v3 | ||
if: github.event_name == 'push' | ||
timeout-minutes: 30 | ||
with: | ||
arguments: ${{ env.GRADLE_SWITCHES }} snapshot |