name: Java CI

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        java: [ 8, 11, 17 ]

    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-java@v3
        with:
          distribution: zulu
          java-version: ${{ matrix.java }}
      - uses: actions/cache@v3
        with:
          path: ~/.m2
          key: ${{ runner.os }}-${{ matrix.java }}-m2-${{ hashFiles('**/pom.xml') }}
          restore-keys: ${{ runner.os }}-${{ matrix.java }}-m2
      - run: mvn --batch-mode --update-snapshots -Dgpg.skip=true jacoco:prepare-agent verify jacoco:report
      - uses: codecov/codecov-action@v3
        with:
          file: ./**/target/site/jacoco/jacoco.xml
          name: codecov
