name: Pull requests

on:
  pull_request:
    branches:
      - '**'

jobs:

  build_job:
    name: Build Pull Request
    runs-on: ubuntu-18.04

    steps:
      - uses: actions/checkout@v1
        with:
          fetch-depth: 1

      - name: Set up JDK 11
        uses: actions/setup-java@v1
        with:
          java-version: 11

      - name: Install dependencies
        run: bash ./install_deps.sh

      - name: Compile Project
        run: |
          ./gradlew generateHeaderFilesFromJavaWrapper build

      - name: create unit coverage
        run: |
          ./gradlew createCodeCoverageReport

      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v2

      - name: Upload Coverage to GH-Actions
        uses: actions/upload-artifact@v2.2.0
        if: ${{ always()  }}
        with:
            name: Tests Coverage Report
            path: |
              lib/build/coverage-report/
