name: Rust

on:
  push:
    branches: [ "*" ]
  pull_request:
    branches: [ "*" ]

env:
  CARGO_TERM_COLOR: always
  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
  RUST_LOG: info

jobs:
  build:

    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-15-intel, macos-latest, windows-latest]
        features_args: ["", "--no-default-features", "--features nostr"]

    steps:
    - uses: actions/checkout@v4
    - name: Build ${{ matrix.features_args }}
      run: cargo build --workspace --verbose ${{ matrix.features_args }}
    - name: Run workspace tests ${{ matrix.features_args }}
      run: |
        cargo test --workspace ${{ matrix.features_args }} -- --test-threads 1
    - name: Run get_file_hash_core tests ${{ matrix.features_args }}
      shell: bash
      run: |
        if [[ "${{ matrix.features_args }}" == "--features nostr" ]]; then
          cargo test -p get_file_hash_core ${{ matrix.features_args }} -- --test-threads 1 --nocapture
        else
          cargo test -p get_file_hash_core ${{ matrix.features_args }} -- --test-threads 1
        fi
    - name: Run get_file_hash tests ${{ matrix.features_args }}
      shell: bash
      run: |
        if [[ "${{ matrix.features_args }}" == "--features nostr" ]]; then
          cargo test -p get_file_hash ${{ matrix.features_args }} -- --test-threads 1 --nocapture
        else
          cargo test -p get_file_hash ${{ matrix.features_args }} -- --test-threads 1
        fi
    - name: Build Release ${{ matrix.features_args }}
      run: cargo build --workspace --release ${{ matrix.features_args }}
