name: CI

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  test:
    name: "JDK ${{ matrix.java }}"
    strategy:
      matrix:
        java: [ 8, 11, 17, 21 ]
    runs-on: ubuntu-latest
    steps:
      # Cancel any previous runs for the same branch that are still running.
      - name: 'Cancel previous runs'
        uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa
        with:
          access_token: ${{ github.token }}
      - name: 'Check out repository'
        uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
      - name: 'Set up JDK ${{ matrix.java }}'
        uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165
        with:
          java-version: ${{ matrix.java }}
          distribution: 'zulu'
          cache: 'maven'
      - name: 'Install'
        shell: bash
        run: mvn -B -U install clean --fail-never --quiet -DskipTests=true -Dinvoker.skip=true
      - name: 'Test'
        shell: bash
        run: mvn -B verify
