# Copyright 2022-2026, Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause

# Nightly Linux run.

name: Nightly tests / LLVM 21.1

permissions: read-all

# Run daily - test sse2-avx512 targets @ -O0/-O1/-O2
on:
  schedule:
    - cron:  '0 7 * * *'
  workflow_dispatch:

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

jobs:
  define-targets:
    # Only run in the main ispc/ispc repo to avoid unnecessary scheduled runs on forks.
    if: github.repository == 'ispc/ispc'
    runs-on: ubuntu-latest
    outputs:
      targets: >-
        ["generic-i1x4", "generic-i1x8", "generic-i1x16", "generic-i1x32",
         "generic-i8x16", "generic-i8x32",
         "generic-i16x8", "generic-i16x16",
         "generic-i32x4", "generic-i32x8", "generic-i32x16",
         "generic-i64x4",
         "sse2-i32x4", "sse2-i32x8",
         "sse4-i8x16", "sse4-i16x8", "sse4-i32x4", "sse4-i32x8",
         "avx1-i32x4", "avx1-i32x8", "avx1-i32x16", "avx1-i64x4",
         "avx2-i8x32", "avx2-i16x16", "avx2-i32x4", "avx2-i32x8", "avx2-i32x16", "avx2-i64x4",
         "avx2vnni-i32x4", "avx2vnni-i32x8", "avx2vnni-i32x16",
         "avx512skx-x4", "avx512skx-x8", "avx512skx-x16", "avx512skx-x64", "avx512skx-x32",
         "avx512icl-x4", "avx512icl-x8", "avx512icl-x16", "avx512icl-x64", "avx512icl-x32",
         "avx512spr-x4", "avx512spr-x8", "avx512spr-x16", "avx512spr-x64", "avx512spr-x32",
         "avx512gnr-x4", "avx512gnr-x8", "avx512gnr-x16", "avx512gnr-x64", "avx512gnr-x32",
         "avx10.2dmr-x4", "avx10.2dmr-x8", "avx10.2dmr-x16", "avx10.2dmr-x64", "avx10.2dmr-x32"]
    steps:
      - run: echo "Defining targets"

  linux-build-ispc-llvm:
    uses: ./.github/workflows/reusable.ispc.build.yml
    with:
      platform: linux
      artifact_name: ispc_llvm_linux
      runner: ubuntu-22.04
      llvm_version: "21.1"
      llvm_tar: llvm-21.1.8-ubuntu22.04-Release+Asserts-x86.arm.wasm.tar.xz

  linux-test:
    needs: [define-targets, linux-build-ispc-llvm]
    strategy:
      fail-fast: false
      matrix:
        arch: [x86, x86-64]
    uses: ./.github/workflows/reusable.ispc.test.yml
    with:
      platform: linux
      architecture: ${{ matrix.arch }}
      artifact_name: ispc_llvm_linux
      targets: ${{ needs.define-targets.outputs.targets }}
      optsets: -O0 -O1 -O2

  win-build-ispc-llvm:
    uses: ./.github/workflows/reusable.ispc.build.yml
    with:
      platform: windows
      artifact_name: ispc_llvm_win
      runner: windows-2022
      llvm_version: "21.1"
      llvm_tar: llvm-21.1.8-win.vs2022-Release+Asserts-x86.arm.wasm.tar.7z

  win-test:
    needs: [define-targets, win-build-ispc-llvm]
    strategy:
      fail-fast: false
      matrix:
        arch: [x86, x86-64]
    uses: ./.github/workflows/reusable.ispc.test.yml
    with:
      platform: windows
      architecture: ${{ matrix.arch }}
      artifact_name: ispc_llvm_win
      targets: ${{ needs.define-targets.outputs.targets }}
      optsets: -O0 -O1 -O2
