name: Build

on:
  pull_request:
    branches:
      - 'future'
    paths-ignore:
      - '.gitignore'
      - 'examples'
      - 'README.md'

jobs:
  build:
    name: ${{ matrix.os }}-${{ matrix.jdk }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ ubuntu-latest, windows-latest ]
        jdk: [ 11, 17 ]
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - uses: actions/cache@v1
        with:
          path: ~/.m2/repository
          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            ${{ runner.os }}-maven-
      - name: Set up JDK ${{ matrix.jdk }}
        uses: actions/setup-java@v2
        with:
          java-version: ${{ matrix.jdk }}
          distribution: 'adopt'
          cache: maven
      - name: Build and test
        run: mvn clean install -DallTests -Pdist
      - uses: actions/upload-artifact@v2
        if: failure()
        with:
          name: surefire-reports
          path: '**/surefire-reports/*.txt'
