name: Wine Tests

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

concurrency:
  group: wine-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1
  RUSTFLAGS: -Dwarnings

jobs:
  wine_test:
    name: Wine Sanity Check
    runs-on: [self-hosted, linux, X64]
    steps:
      - uses: actions/checkout@v4

      - name: Install Wine
        run: |
          # Use WineHQ for newer Wine with bcryptprimitives.dll support
          sudo dpkg --add-architecture i386
          sudo mkdir -pm755 /etc/apt/keyrings
          sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
          sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/$(lsb_release -cs)/winehq-$(lsb_release -cs).sources
          sudo apt-get update
          sudo apt-get install -y --install-recommends winehq-stable || sudo apt-get install -y wine64 wine32
          # Initialize Wine prefix
          WINEARCH=win64 wineboot --init

      - name: Install Rust + mingw target
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: x86_64-pc-windows-gnu

      - name: Install mingw-w64
        run: sudo apt-get install -y mingw-w64

      - name: Build tests
        # Release mode required - debug builds exceed mingw's export ordinal limit (~65k symbols)
        run: cargo build --target x86_64-pc-windows-gnu --tests --release

      - name: List available tests
        run: |
          for exe in target/x86_64-pc-windows-gnu/release/deps/*.exe; do
            echo "=== Tests in $exe ==="
            wine "$exe" --list
          done

      - name: Run tests under Wine
        run: |
          for exe in target/x86_64-pc-windows-gnu/release/deps/*.exe; do
            echo "=== Running $exe ==="
            wine "$exe" --test-threads=1
          done

Graph