Merge pull request #116 from igerber/release/v2.2.0 #176
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Rust Backend Tests | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'rust/**' | |
| - 'diff_diff/**' | |
| - 'tests/**' | |
| - 'pyproject.toml' | |
| - '.github/workflows/rust-test.yml' | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - 'rust/**' | |
| - 'diff_diff/**' | |
| - 'tests/**' | |
| - 'pyproject.toml' | |
| - '.github/workflows/rust-test.yml' | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| # Run Rust unit tests on all platforms | |
| rust-tests: | |
| name: Rust Unit Tests (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| PYO3_USE_ABI3_FORWARD_COMPATIBILITY: 1 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Run Rust tests | |
| working-directory: rust | |
| run: cargo test --verbose | |
| # Build and test with Python on multiple platforms | |
| python-tests: | |
| name: Python Tests (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install test dependencies | |
| run: pip install pytest numpy pandas scipy | |
| - name: Build and install with maturin | |
| run: | | |
| pip install maturin | |
| maturin build --release -o dist | |
| echo "=== Built wheels ===" | |
| ls -la dist/ || dir dist | |
| shell: bash | |
| - name: Install wheel (Unix) | |
| if: runner.os != 'Windows' | |
| run: pip install --no-index --find-links=dist diff-diff | |
| - name: Install wheel (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| $wheel = Get-ChildItem dist/*.whl | Select-Object -First 1 | |
| pip install $wheel.FullName | |
| shell: pwsh | |
| - name: Verify Rust backend is available (Unix) | |
| if: runner.os != 'Windows' | |
| working-directory: /tmp | |
| run: | | |
| python -c "import diff_diff; print('Location:', diff_diff.__file__)" | |
| python -c "from diff_diff import HAS_RUST_BACKEND; print('HAS_RUST_BACKEND:', HAS_RUST_BACKEND); assert HAS_RUST_BACKEND, 'Rust backend not available'" | |
| - name: Verify Rust backend is available (Windows) | |
| if: runner.os == 'Windows' | |
| working-directory: ${{ runner.temp }} | |
| run: | | |
| python -c "import diff_diff; print('Location:', diff_diff.__file__)" | |
| python -c "from diff_diff import HAS_RUST_BACKEND; print('HAS_RUST_BACKEND:', HAS_RUST_BACKEND); assert HAS_RUST_BACKEND, 'Rust backend not available'" | |
| - name: Copy tests to isolated location (Unix) | |
| if: runner.os != 'Windows' | |
| run: cp -r tests /tmp/tests | |
| - name: Copy tests to isolated location (Windows) | |
| if: runner.os == 'Windows' | |
| run: Copy-Item -Recurse tests $env:RUNNER_TEMP\tests | |
| shell: pwsh | |
| - name: Run Rust backend tests (Unix) | |
| if: runner.os != 'Windows' | |
| working-directory: /tmp | |
| run: pytest tests/test_rust_backend.py -v | |
| - name: Run Rust backend tests (Windows) | |
| if: runner.os == 'Windows' | |
| working-directory: ${{ runner.temp }} | |
| run: pytest tests/test_rust_backend.py -v | |
| - name: Run tests with Rust backend (Unix) | |
| if: runner.os != 'Windows' | |
| working-directory: /tmp | |
| run: DIFF_DIFF_BACKEND=rust pytest tests/ -x -q | |
| - name: Run tests with Rust backend (Windows) | |
| if: runner.os == 'Windows' | |
| working-directory: ${{ runner.temp }} | |
| run: | | |
| $env:DIFF_DIFF_BACKEND="rust" | |
| pytest tests/ -x -q | |
| shell: pwsh | |
| # Test pure Python fallback (without Rust extension) | |
| python-fallback: | |
| name: Pure Python Fallback | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: pip install numpy pandas scipy pytest | |
| - name: Verify pure Python mode | |
| run: | | |
| # Use PYTHONPATH to import directly (skips maturin build) | |
| PYTHONPATH=. python -c "from diff_diff import HAS_RUST_BACKEND; print(f'HAS_RUST_BACKEND: {HAS_RUST_BACKEND}'); assert not HAS_RUST_BACKEND" | |
| - name: Run tests in pure Python mode | |
| run: PYTHONPATH=. DIFF_DIFF_BACKEND=python pytest tests/ -x -q --ignore=tests/test_rust_backend.py |