name: OpenOSRS - CI (push)

on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    name: Build

    steps:
      - uses: actions/checkout@v2.3.4
      - uses: actions/cache@v2.1.3
        with:
          path: ~/.gradle/caches
          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
          restore-keys: |
            ${{ runner.os }}-gradle-
      - name: Make gradlew executable
        run: chmod +x ./gradlew
      - name: Set up JDK 11
        uses: actions/setup-java@v1.4.3
        with:
          java-version: 11
      - name: Assembling
        run: ./gradlew assemble --console=plain
      - name: Building
        run: ./gradlew build --stacktrace -x test -x checkstyleMain --console=plain

  test:
    runs-on: ubuntu-latest
    name: Test

    steps:
      - uses: actions/checkout@v2.3.4
      - uses: actions/cache@v2.1.3
        with:
          path: ~/.gradle/caches
          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
          restore-keys: |
            ${{ runner.os }}-gradle-
      - name: Make gradlew executable
        run: chmod +x ./gradlew
      - name: Set up JDK 11
        uses: actions/setup-java@v1.4.3
        with:
          java-version: 11
      - name: Assembling
        run: ./gradlew assemble --console=plain
      - name: Testing
        run: ./gradlew test -x deobfuscator:test --stacktrace --console=plain

  checkstyleMain:
    name: Checkstyle main
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2.3.4
      - uses: actions/cache@v2.1.3
        with:
          path: ~/.gradle/caches
          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
          restore-keys: |
            ${{ runner.os }}-gradle-
      - name: Make gradlew executable
        run: chmod +x ./gradlew
      - name: Set up JDK 11
        uses: actions/setup-java@v1.4.3
        with:
          java-version: 11
      - name: Assembling
        run: ./gradlew assemble --console=plain
      - name: Checking code conventions
        run: ./gradlew checkstyleMain --console=plain

  checkstyleTest:
    name: Checkstyle test
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2.3.4
      - uses: actions/cache@v2.1.3
        with:
          path: ~/.gradle/caches
          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
          restore-keys: |
            ${{ runner.os }}-gradle-
      - name: Make gradlew executable
        run: chmod +x ./gradlew
      - name: Set up JDK 11
        uses: actions/setup-java@v1.4.3
        with:
          java-version: 11
      - name: Assembling
        run: ./gradlew assemble --console=plain
      - name: Checking code conventions
        run: ./gradlew checkstyleTest --console=plain
