name: validate

on: [push, pull_request]

jobs:
  linux:
    runs-on: 'ubuntu-latest'
    steps:
    - uses: actions/checkout@v1
    - uses: actions/setup-java@v1
      with:
        java-version: '11'
        java-package: jdk
    - name: Cache local Maven repository
      uses: actions/cache@v2
      with:
        path: ~/.m2/repository
        key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
        restore-keys: |
          ${{ runner.os }}-maven-
    - name: Check formatting
      run: ./scripts/checkformatting.sh
    - name: Run core tests
      run: ./scripts/runcoretests.sh
    - name: Run application tests
      run: ./scripts/runapptests.sh
    - name: Run agent tests
      run: ./scripts/runagenttests.sh

  mac:
    runs-on: 'macOS-latest'
    steps:
    - uses: actions/checkout@v1
    - uses: actions/setup-java@v1
      with:
        java-version: '11'
        java-package: jdk
    - name: Cache local Maven repository
      uses: actions/cache@v2
      with:
        path: ~/.m2/repository
        key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
        restore-keys: |
          ${{ runner.os }}-maven-
    - name: Check formatting
      run: ./scripts/checkformatting.sh
    - name: Run core tests
      run: ./scripts/runcoretests.sh
    - name: Run application tests
      run: ./scripts/runapptests.sh
    - name: Run agent tests
      run: ./scripts/runagenttests.sh

  win:
    runs-on: 'windows-latest'
    steps:
    - uses: actions/checkout@v1
    - uses: actions/setup-java@v1
      with:
        java-version: '11'
        java-package: jdk
    - name: Cache local Maven repository
      uses: actions/cache@v2
      with:
        path: ~/.m2/repository
        key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
        restore-keys: |
          ${{ runner.os }}-maven-
    - name: Check formatting
      run: .\scripts\checkformatting.bat
      shell: cmd
    - name: Run core tests
      run: .\scripts\runcoretests.bat
      shell: cmd
    - name: Run application tests
      run: .\scripts\runapptests.bat
      shell: cmd
    - name: Run agent tests
      run: .\scripts\runagenttests.bat
      shell: cmd
