name: Run basic tests

on:
  workflow_dispatch:
  push:
    branches:
      - "main"
  pull_request:
    paths:
      - ".github/workflows/build.yaml"
      - ".github/workflows/matrix.json"
      - "integration-tests/**"
      - "backends/**"
      - "core/**"
      - "router/**"
      - "Cargo.lock"
      - "rust-toolchain.toml"
      - "Dockerfile"
    branches:
      - "main"

jobs:
  tests:
    concurrency:
      group: ${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.run_id }}
      cancel-in-progress: true
    runs-on:
      group: aws-highmemory-32-plus-priv
    steps:
      - name: Checkout repository
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd  # v6.0.2
      - uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c  # v1.15.2
      - name: Run sccache-cache
        uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad  # v0.0.9
        with:
          version: "v0.10.0"
      - name: Compile project
        env:
          SCCACHE_GHA_ENABLED: "true"
          RUSTC_WRAPPER: "sccache"
          HF_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
        run: |
          sudo apt-get update && sudo apt-get install protobuf-compiler -y
          cargo test --profile=release-debug
