name: Ubuntu

on: [ push, pull_request ]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: true
      matrix:
        java_version: [ 11, 14 ]

    steps:
      - uses: actions/checkout@v2
      - name: "Set up JDK ${{ matrix.java_version }}"
        uses: actions/setup-java@v1
        with:
          java-version: ${{ matrix.java_version }}

      - name: build
        run: ./gradlew build

      # TODO 0.18.0 re-activate scala API
      #            -   name: composite build atrium-scala2
      #                run: ./gradlew build
      #                working-directory: misc/tools/atrium-scala2-test

      - name: Upload build code coverage
        uses: codecov/codecov-action@v1
        if: ${{ github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/master') }}
        env:
          JAVA_VERSION: ${{ matrix.java_version }}
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          flags: current
          env_vars: JAVA_VERSION
          # too many timeout errors, let's not fail at the moment
          #fail_ci_if_error: true

      - name: composite build atrium-samples-test
        run: ./gradlew build
        working-directory: misc/tools/atrium-samples-test

      - name: composite build atrium-js-sample-test
        run: ./gradlew build
        working-directory: misc/tools/atrium-js-sample-test
