name: CI

on: [push, pull_request]


jobs:
  build:
    name: build-only (Java ${{ matrix.java }})
    runs-on: ubuntu-latest
    strategy:
      matrix:
        java: [ 13 ]
    steps:
      - uses: actions/checkout@v2
      - name: Set up JDK
        uses: actions/setup-java@v1
        with:
          java-version: ${{ matrix.java }}
      - name: Cached .m2
        uses: actions/cache@v2
        with:
          path: ~/.m2/repository
          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            ${{ runner.os }}-maven-
      - name: Maven Install (skipTests)
        run: mvn -B install -DskipTests -D enable-ci --file pom.xml
  site:
    name: site (Java ${{ matrix.java }})
    runs-on: ubuntu-latest
    strategy:
      matrix:
        java: [ 8, 11 ]
    steps:
      - uses: actions/checkout@v2
      - name: Set up JDK
        uses: actions/setup-java@v1
        with:
          java-version: ${{ matrix.java }}
      - uses: actions/cache@v2
        with:
          path: ~/.m2/repository
          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            ${{ runner.os }}-maven-
      - name: Maven Site
        run: mvn -B site -D enable-ci --file pom.xml
  test:
    name: test (${{ matrix.os }}, Java ${{ matrix.java }})
    runs-on: ${{ matrix.os }}-latest
    strategy:
      matrix:
        os: [ ubuntu, windows ]
        java: [ 8, 11, 13, 15-ea ]
    steps:
    - uses: actions/checkout@v2
    - name: Set up JDK
      uses: actions/setup-java@v1
      with:
        java-version: ${{ matrix.java }}
    - uses: actions/cache@v2
      with:
        path: ~/.m2/repository
        key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
        restore-keys: |
          ${{ runner.os }}-maven-
    - name: Maven Install without Code Coverage
      if: matrix.os == 'windows'
      run: mvn -B install --file pom.xml
    - name: Maven Install with Code Coverage
      if: matrix.os != 'windows'
      run: mvn -B install -D enable-ci --file pom.xml
