name: CI Ubuntu

on:
  workflow_dispatch:
  push:
    branches: [ main, devel ]
  pull_request:
    branches: [ main, devel ]

jobs:
  build_and_test:
    name: "Main tests"
    runs-on: ubuntu-latest
    strategy:
      matrix:
        toolchain:
          - stable
          - nightly
        feature:
          - serial
          - parallel
    
    steps:
    - uses: actions/checkout@v4
    - name: Install libfuse-dev
      run: |
        sudo apt-get update
        sudo apt-get install -y libfuse-dev
    - name: Set PKG_CONFIG_PATH
      run: echo "PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig" >> $GITHUB_ENV
    - name: Setup Rust
      run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
    - name: Build
      run: cargo build --verbose --features ${{ matrix.feature }}
    - name: Run tests
      run: cargo test  --verbose --features ${{ matrix.feature }}

  test_examples:
    name: "Examples crates"
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Install libfuse-dev
      run: |
        sudo apt-get update
        sudo apt-get install -y libfuse-dev
    - name: Set PKG_CONFIG_PATH
      run: echo "PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig" >> $GITHUB_ENV
    - name: Run tests of crates inside examples folder
      run: ./tests/test_all_examples.sh