name: LLVM AOT Smoke

on:
  push:
    paths:
      - 'src/**'
      - 'crates/**'
      - 'apps/**'
      - 'tools/**'
      - 'Cargo.toml'
      - 'Cargo.lock'
      - '.github/workflows/llvm-aot-smoke.yml'
  pull_request:
    paths:
      - 'src/**'
      - 'crates/**'
      - 'apps/**'
      - 'tools/**'
      - 'Cargo.toml'
      - 'Cargo.lock'

jobs:
  llvm-aot:
    runs-on: ubuntu-latest
    env:
      CARGO_TERM_COLOR: always
      NYASH_CLI_VERBOSE: '1'
      NYASH_DISABLE_PLUGINS: '1'
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Rust (stable)
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo registry and build
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-

      - name: Install LLVM 18 (llvm-config-18)
        run: |
          sudo apt-get update
          sudo apt-get install -y curl ca-certificates lsb-release wget gnupg
          curl -fsSL https://apt.llvm.org/llvm.sh -o llvm.sh
          chmod +x llvm.sh
          sudo ./llvm.sh 18
          llvm-config-18 --version

      - name: Run LLVM AOT smokes
        run: bash tools/llvm_smoke.sh

