name: Rust

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

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v4

      # Ubuntu 专属依赖安装
      - name: Setup Ubuntu dependencies
        if: matrix.os == 'ubuntu-latest'
        run: |
          sudo apt-get update
          sudo apt install libasound2-dev

      # 构建项目
      - name: Build
        run: cargo build -vv

      # 运行测试
      - name: Run tests
        run: cargo test --workspace -vv