on:
  push:
    branches:
      - main
    paths:
      - 'src-tauri/**.rs'
      - '**/Cargo.toml'
      - '**/Cargo.lock'
      - '**/rust-toolchain.toml'
      - .github/workflows/cargo-test-tauri.yml
  pull_request:
    paths:
      - 'src-tauri/**.rs'
      - '**/Cargo.toml'
      - '**/Cargo.lock'
      - '**/rust-toolchain.toml'
      - .github/workflows/cargo-test-tauri.yml
  workflow_dispatch:
permissions: read-all
concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true
name: cargo test of tauri
jobs:
  cargotest:
    name: cargo test
    runs-on: ubuntu-latest-8-cores
    strategy:
      matrix:
        dir: ['src-tauri']
    steps:
      - uses: actions/checkout@v4
      - name: Install latest rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true
      - name: install dependencies
        if: matrix.dir ==  'src-tauri'
        run: |
          sudo apt-get update
          sudo apt-get install -y \
            libgtk-3-dev \
            libayatana-appindicator3-dev \
            webkit2gtk-driver \
            libsoup-3.0-dev \
            libjavascriptcoregtk-4.1-dev \
            libwebkit2gtk-4.1-dev \
            at-spi2-core \
            xvfb
      - name: Rust Cache
        uses: Swatinem/rust-cache@v2.6.1
      - name: cargo test
        shell: bash
        run: |-
          cd "${{ matrix.dir }}"
          cargo test --all
