name: basic-test

on:
  workflow_call:

concurrency:
  group: ${ {github.event_name }}-${{ github.workflow }}-${{ github.ref }}-cibasic
  cancel-in-progress: ${{github.event_name == 'pull_request'}}

permissions: read-all

jobs:
  clang-smoketest:
    name: clang-smoketest
    runs-on: [ubuntu-latest]

    steps:
      - name: checkout code
        uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
        with:
          path: kokkos

      - name: Install ccache
        run: |
          sudo apt-get update
          sudo apt-get install ccache

      - uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
        with:
          path: ~/.cache/ccache
          key: kokkos-basic-test-${{ github.ref }}-${{ github.sha }}
          restore-keys: kokkos-basic-test-${{ github.ref }}

      - name: configure kokkos
        run: |
          cmake \
            -S kokkos \
            -B builddir \
            -DCMAKE_BUILD_TYPE=RelWithDebInfo \
            -DCMAKE_INSTALL_PREFIX=$PWD/../install \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_CXX_FLAGS="-Werror" \
            -DCMAKE_CXX_STANDARD=20 \
            -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
            -DKokkos_ENABLE_COMPILER_WARNINGS=ON \
            -DKokkos_ENABLE_DEPRECATED_CODE_4=OFF \
            -DKokkos_ENABLE_EXAMPLES=ON \
            -DKokkos_ENABLE_SERIAL=ON \
            -DKokkos_ENABLE_TESTS=ON

      - name: build_and_install_kokkos
        run:  |
          ccache -z
          cmake --build builddir --target install --parallel $(nproc)
          ccache -s

      - name: test_kokkos
        run: ctest --test-dir builddir --timeout 2000 -j$(nproc) --output-on-failure
