## Copyright 2022 Intel Corporation
## SPDX-License-Identifier: Apache-2.0

name: CI Mac Workflow
on:
  push:
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build-macOS:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main
    with:
      force-delete: true    # guarantees .gitattributes are respected in working dir
      submodules: true
      runs-on: '[ "macOS", "build", "x86_64" ]'
      artifact-out: build-macOS
      artifact-path: ./build/install ./build/openvkl/build
      cmd: |
        gitlab/build.sh

  test-macOS:
    needs: build-macOS
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main
    with:
      runs-on: '[ "macOS", "build", "x86_64" ]'
      artifact-in: build-macOS
      cmd: |
        ./build/openvkl/build/vklTutorialCPU
        ./build/openvkl/build/vklTutorialISPC
        ./build/openvkl/build/vklExamplesCPU -batch -printStats -spp 50 -framebufferSize 1024 1024
        ./build/openvkl/build/vklTestsCPU --durations yes

  build-macOS-TBB2020:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main
    with:
      force-delete: true    # guarantees .gitattributes are respected in working dir
      submodules: true
      runs-on: '[ "macOS", "build", "x86_64" ]'
      artifact-out: build-macOS-TBB2020
      artifact-path: ./build/install ./build/openvkl/build
      cmd: |
        gitlab/build.sh -D TBB_VERSION=2020.3 -D TBB_HASH=""

  test-macOS-TBB2020:
    needs: build-macOS-TBB2020
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main
    with:
      runs-on: '[ "macOS", "build", "x86_64" ]'
      artifact-in: build-macOS-TBB2020
      cmd: |
        ./build/openvkl/build/vklTutorialCPU
        ./build/openvkl/build/vklTutorialISPC
        ./build/openvkl/build/vklExamplesCPU -batch -printStats -spp 50 -framebufferSize 1024 1024
        ./build/openvkl/build/vklTestsCPU --durations yes

  build-macOS-arm-neon:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main
    with:
      force-delete: true    # guarantees .gitattributes are respected in working dir
      submodules: true
      runs-on: '[ "macOS", "build", "arm" ]'
      artifact-out: build-macOS-arm-neon
      artifact-path: ./build/install ./build/openvkl/build
      cmd: |
        gitlab/build.sh -DBUILD_TBB_FROM_SOURCE=ON -D OPENVKL_EXTRA_OPTIONS="-DOPENVKL_ISA_NEON=ON -DOPENVKL_ISA_NEON2X=OFF"


  test-macOS-arm-neon:
    needs: build-macOS-arm-neon
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main
    with:
      runs-on: '[ "macOS", "build", "arm" ]'
      artifact-in: build-macOS-arm-neon
      cmd: |
        export OPENVKL_LOG_LEVEL=debug # gives prints of current ISA and SIMD width
        ./build/openvkl/build/vklTutorialCPU
        ./build/openvkl/build/vklTutorialISPC
        ./build/openvkl/build/vklExamplesCPU -batch -printStats -spp 50 -framebufferSize 1024 1024
        ./build/openvkl/build/vklTestsCPU --durations yes

  build-macOS-arm-neon2x:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main
    with:
      force-delete: true    # guarantees .gitattributes are respected in working dir
      submodules: true
      runs-on: '[ "macOS", "build", "arm" ]'
      artifact-out: build-macOS-arm-neon2x
      artifact-path: ./build/install ./build/openvkl/build
      cmd: |
        gitlab/build.sh -DBUILD_TBB_FROM_SOURCE=ON -D OPENVKL_EXTRA_OPTIONS="-DOPENVKL_ISA_NEON=OFF -DOPENVKL_ISA_NEON2X=ON"


  test-macOS-arm-neon2x:
    needs: build-macOS-arm-neon2x
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main
    with:
      runs-on: '[ "macOS", "build", "arm" ]'
      artifact-in: build-macOS-arm-neon2x
      cmd: |
        export OPENVKL_LOG_LEVEL=debug # gives prints of current ISA and SIMD width
        ./build/openvkl/build/vklTutorialCPU
        ./build/openvkl/build/vklTutorialISPC
        ./build/openvkl/build/vklExamplesCPU -batch -printStats -spp 50 -framebufferSize 1024 1024
        ./build/openvkl/build/vklTestsCPU --durations yes
