name: CI

on:
  push:
    branches:
      - '*'
  pull_request:
    branches:
      - '*'

# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners

concurrency:
  # On master/release, we don't want any jobs cancelled so the sha is used to name the group
  # On PR branches, we cancel the job if new commits are pushed
  # More info: https://stackoverflow.com/a/68422069/253468
  group: ${{ (github.ref == 'refs/heads/branch_1.2.18' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/release' ) && format('ci-main-{0}', github.sha) || format('ci-main-{0}', github.ref) }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  Test:
    name: JDK ${{ matrix.jdk }}, ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        jdk: [11, 17]
        os: [ubuntu-latest, windows-latest, macos-latest]
      fail-fast: true
      max-parallel: 4
    steps:
    - uses: actions/checkout@v3
      with:
        fetch-depth: 50
    - name: Set up Java ${{ matrix.jdk }}
      if: ${{ matrix.jdk != '8' }}
      uses: actions/setup-java@v2
      with:
        distribution: 'temurin'
        java-version: ${{ matrix.jdk }}
    - name: Install
      # download dependencies, etc, so test log looks better
      run: mvn -B install


