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

name: (Internal) CI Linux

on:
  push:
  workflow_dispatch:

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

permissions: read-all

jobs:

  ## Build Jobs ##

  build-rocky8:
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: rockylinux:8
      cmd: |
        .github/scripts/build.sh
      artifact-out: build-rocky8
      artifact-path: build

  build-rocky8-icx:
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: rockylinux:8
      cmd: |
        module load intel/2022.1
        export CC=icx
        export CXX=icpx
        export LDFLAGS="-static-intel"
        .github/scripts/build.sh
      artifact-out: build-rocky8-icx
      artifact-path: build

  build-rocky9:
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: rockylinux:9
      cmd: |
        .github/scripts/build.sh
      artifact-out: build-rocky9
      artifact-path: build

  build-ubuntu2004:
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: ubuntu:20.04
      cmd: |
        .github/scripts/build.sh -G Ninja
      artifact-out: build-ubuntu2004
      artifact-path: build

  build-ubuntu2204:
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: ubuntu:22.04
      cmd: |
        .github/scripts/build.sh -G Ninja
      artifact-out: build-ubuntu2204
      artifact-path: build

  build-ubuntu2404:
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: ubuntu:24.04
      cmd: |
        .github/scripts/build.sh -G Ninja
      artifact-out: build-ubuntu2404
      artifact-path: build

  build-arch:
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: archlinux:latest
      cmd: |
        .github/scripts/build.sh -G Ninja
      artifact-out: build-arch
      artifact-path: build
        
  build-arch-clang:
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: archlinux:latest
      cmd: |
        export CC=clang
        export CXX=clang++
        .github/scripts/build.sh -G Ninja
      artifact-out: build-arch-clang
      artifact-path: build

  build-arch-clang-sanitizer:
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: archlinux:latest
      cmd: |
        export CC=clang
        export CXX=clang++
        export CFLAGS=-fsanitize=address
        export CXXFLAGS=-fsanitize=address
        export LDFLAGS=-fsanitize=address
        .github/scripts/build.sh -G Ninja -DCMAKE_BUILD_TYPE=Debug
      artifact-out: build-arch-clang-sanitizer
      artifact-path: build

  ## Functional Test Jobs ##

  test-rocky8:
    needs: build-rocky8
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: rockylinux:8
      cmd: |
        ./build/rkcommon_test_suite
      artifact-in: build-rocky8

  test-rocky8-icx:
    needs: build-rocky8-icx
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: rockylinux:8
      cmd: |
        ./build/rkcommon_test_suite
      artifact-in: build-rocky8-icx

  test-rocky9:
    needs: build-rocky9
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: rockylinux:9
      cmd: |
        ./build/rkcommon_test_suite
      artifact-in: build-rocky9

  test-ubuntu2004:
    needs: build-ubuntu2004
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: ubuntu:20.04
      cmd: |
        ./build/rkcommon_test_suite
      artifact-in: build-ubuntu2004

  test-ubuntu2204:
    needs: build-ubuntu2204
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: ubuntu:22.04
      cmd: |
        ./build/rkcommon_test_suite
      artifact-in: build-ubuntu2204

  test-ubuntu2404:
    needs: build-ubuntu2404
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: ubuntu:24.04
      cmd: |
        ./build/rkcommon_test_suite
      artifact-in: build-ubuntu2404

  test-arch:
    needs: build-arch
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: archlinux:latest
      cmd: |
        ./build/rkcommon_test_suite
      artifact-in: build-arch

  test-arch-clang:
    needs: build-arch-clang
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: archlinux:latest
      cmd: |
        ./build/rkcommon_test_suite
      artifact-in: build-arch-clang

  test-arch-clang-sanitizer:
    needs: build-arch-clang-sanitizer
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: archlinux:latest
      cmd: |
        ./build/rkcommon_test_suite
      artifact-in: build-arch-clang-sanitizer

  ## Static Analysis ##

  static-analysis:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/static_analysis.yml@main
    with:
      project: RKCommon
      prebuild: cmake -S . -B build -DRKCOMMON_TASKING_SYSTEM=INTERNAL
      build: cmake --build build
