name: Unit Test Rust
on:
  push:
    paths:
      - ".github/workflows/test.yml"
      - "src/rust/**"
    tags-ignore:
      - "*.*"
  pull_request:
    types: [opened, synchronize, reopened]
    paths:
      - ".github/workflows/test.yml"
      - "src/rust/**"
jobs:
  test_rust:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./src/rust
    steps:
      - uses: actions/checkout@v6
      - name: cache
        uses: actions/cache@v5
        with:
          path: |
            src/rust/.cargo/registry
            src/rust/.cargo/git
            src/rust/target
            src/rust/lib_ccxr/target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: ${{ runner.os }}-cargo-
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true
      - name: Test main module
        run: cargo test
        working-directory: ./src/rust
      - name: Test lib_ccxr module
        run: cargo test
        working-directory: ./src/rust/lib_ccxr
