name: CI

on:
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        java: [ 16 ]

    name: CI (Java ${{ matrix.java }})

    steps:
      - uses: actions/checkout@v2

      - name: Set up JDK
        uses: actions/setup-java@v1
        with:
          distribution: 'adopt'
          java-version: ${{ matrix.java }}

      - name: Validate Gradle wrapper
        uses: gradle/wrapper-validation-action@v1

      - name: Cache gradle
        uses: actions/cache@v2
        with:
          path: |
            ~/.gradle/caches
            ~/.gradle/wrapper
          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
          restore-keys: |
            ${{ runner.os }}-gradle-

      - name: Build with Gradle
        run: BUILD_EXTRAS=true ./gradlew assemble --no-daemon

      - name: Cleanup Gradle Cache
        # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
        # Restoring these files from a GitHub Actions cache might cause problems for future builds.
        run: |
          rm -f ~/.gradle/caches/modules-2/modules-2.lock
          rm -f ~/.gradle/caches/modules-2/gc.properties
