name: Frozen TENT CPU comparison

on:
  pull_request:
    paths:
      - 'src/**'
      - 'tests/reference/**'
      - 'tests/unit/transport/rdma/slice.rs'
      - 'tests/fixtures/**'
      - 'Cargo.toml'
      - 'Cargo.lock'
      - '.github/workflows/native-cpu.yml'
      - '.github/scripts/install-native-deps.sh'
  workflow_dispatch:

permissions:
  contents: read

jobs:
  cpu-oracle:
    runs-on: ubuntu-24.04
    timeout-minutes: 20
    env:
      RUSTUP_TOOLCHAIN: stable
      CC: gcc
      CXX: g++
      LIBCLANG_PATH: /usr/lib/llvm-18/lib
      CLANG_PATH: /usr/bin/clang-18
    steps:
      - uses: actions/checkout@v7.0.1
      - name: Install reference build dependencies
        timeout-minutes: 10
        run: |
          .github/scripts/install-native-deps.sh cmake g++ git curl python3-dev libgoogle-glog-dev libgflags-dev libnuma-dev libyaml-cpp-dev libjsoncpp-dev libibverbs-dev libcurl4-openssl-dev libssl-dev clang-18 libclang-18-dev
          rustup toolchain install stable --profile minimal
      - name: Compare frozen native TENT and OrbitTE
        run: python3 tests/reference/run.py --fetch-reference --output "$RUNNER_TEMP/orbitte-native-cpu"
      - name: Compare frozen RDMA slice geometry and controls
        run: python3 tests/reference/rdma_geometry.py --tent-source "$RUNNER_TEMP/orbitte-native-cpu/reference" --output "$RUNNER_TEMP/orbitte-rdma-geometry"
      - name: Preserve RDMA geometry evidence
        if: always()
        uses: actions/upload-artifact@v7.0.2
        with:
          name: frozen-tent-rdma-geometry
          path: ${{ runner.temp }}/orbitte-rdma-geometry/
      - name: Preserve comparison evidence
        if: always()
        uses: actions/upload-artifact@v7.0.2
        with:
          name: frozen-tent-cpu
          path: |
            ${{ runner.temp }}/orbitte-native-cpu/manifest.json
            ${{ runner.temp }}/orbitte-native-cpu/*.stdout
            ${{ runner.temp }}/orbitte-native-cpu/*.stderr
            ${{ runner.temp }}/orbitte-native-cpu/tent-build/CMakeCache.txt
            ${{ runner.temp }}/orbitte-native-cpu/tent-driver
            ${{ runner.temp }}/orbitte-native-cpu/tent-build/**/*.so*
            ${{ runner.temp }}/orbitte-native-cpu/cargo/debug/examples/cpu_trace
