name: Build all targets and run all tests

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

  workflow_dispatch:

jobs:
     
  build_and_test:
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v2
      
      - name: Set up JDK
        uses: actions/setup-java@v1
        with:
          java-version: 16

#      Disabled due to issues with missing dependency declarations on system headers.
#      - name: Mount bazel cache
#        uses: actions/cache@v2
#        with:
#          path: "/home/runner/.cache/bazel"
#          key: bazel

      - name: Build
        run: ./bazelisk-linux-amd64 build -c opt //...

      - name: Test
        run: ./bazelisk-linux-amd64 test -c opt //...

name: Build all targets and run all tests

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

  workflow_dispatch:

jobs:
     
  build_and_test:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
        include:
          - os: ubuntu-latest
            arch: "linux"
            cache: "/home/runner/.cache"
          - os: macos-latest
            arch: "darwin"
            cache: "/private/var/tmp"

    steps:
      - uses: actions/checkout@v2
      
      - name: Set up JDK
        uses: actions/setup-java@v1
        with:
          java-version: 16

#      Disabled due to issues with missing dependency declarations on system headers.
#      - name: Mount bazel cache
#        uses: actions/cache@v2
#        with:
#          path: "/home/runner/.cache/bazel"
#          key: bazel

      - name: Download Bazelisk for macOS
        if: matrix.arch == darwin
        run: curl -LO https://github.com/bazelbuild/bazelisk/releases/download/v1.7.5/bazelisk-darwin-amd64 && chmod +x bazelisk-darwin-amd64

      - name: Build
        run: ./bazelisk-${{ matrix.arch }}-amd64 build -c opt //...

      - name: Test
        run: ./bazelisk-${{ matrix.arch }}-amd64 test -c opt --test_tag_filters="-broken-on-${{ matrix.arch }}" //...

      - name: Upload test logs
        if: always()
        uses: actions/upload-artifact@v2
        with:
          name: testlogs-${{ matrix.arch }}
          # https://github.com/actions/upload-artifact/issues/92#issuecomment-711107236
          path: bazel-testlogs*/**/test.log

Test macOS compatibility in CI
Test macOS compatibility in CI
