fix window #14
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: Cross-Platform Tests | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| pull_request: | |
| branches: [ main, master ] | |
| workflow_dispatch: # Allows manual triggering | |
| # Add this section to control notification behavior | |
| defaults: | |
| run: | |
| shell: bash | |
| # Explicitly disable all notifications | |
| env: | |
| GITHUB_ACTIONS_SKIP_NOTIFICATIONS: true | |
| ACTIONS_STEP_DEBUG: false | |
| GITHUB_ACTIONS_NOTIFICATIONS: false | |
| jobs: | |
| build_and_test: | |
| name: Build and test on ${{ matrix.os }} with Python ${{ matrix.python-version }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false # Continue with other jobs if one fails | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| python-version: ['3.11'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| # Cache Python packages | |
| - name: Cache pip packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip-${{ matrix.python-version }}- | |
| # Cache Rust dependencies | |
| - name: Cache Cargo registry and index | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml', '**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Create virtual environment | |
| run: | | |
| python -m venv .venv | |
| echo "VIRTUAL_ENV=$PWD/.venv" >> $GITHUB_ENV | |
| - name: Set PATH for Unix | |
| if: matrix.os != 'windows-latest' | |
| run: echo "$PWD/.venv/bin" >> $GITHUB_PATH | |
| - name: Set PATH for Windows | |
| if: matrix.os == 'windows-latest' | |
| run: echo "$PWD/.venv/Scripts" >> $GITHUB_PATH | |
| shell: bash | |
| # Attempt to install OpenSSL using Chocolatey for Windows if needed by the crate itself | |
| - name: Install OpenSSL (Windows only) | |
| if: matrix.os == 'windows-latest' | |
| run: choco install openssl -y --no-progress || echo "OpenSSL installation failed, continuing..." | |
| shell: bash | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pytest pytest-benchmark | |
| if [ -f tests/requirements.txt ]; then pip install -r tests/requirements.txt || echo "Failed to install some dependencies from tests/requirements.txt, continuing..."; fi | |
| shell: bash | |
| - name: Build and install package with maturin | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| target: ${{ matrix.os == 'macos-latest' && 'universal2-apple-darwin' || (matrix.os == 'windows-latest' && 'x86_64-pc-windows-msvc' || 'x86_64') }} | |
| command: develop | |
| args: --release | |
| sccache: 'true' | |
| - name: Run tests | |
| run: | | |
| # Skip c2pa-python comparison tests on Windows if necessary | |
| if [ "${{ matrix.os }}" == "windows-latest" ]; then | |
| # Only run tests that don't require c2pa-python if installation failed | |
| pip list | grep -q c2pa-python || export SKIP_COMPARISON_TESTS=1 | |
| fi | |
| python run_tests.py | |
| continue-on-error: true # Continue even if tests fail to get wheels | |
| - name: Build wheel | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| target: ${{ matrix.os == 'macos-latest' && 'universal2-apple-darwin' || (matrix.os == 'windows-latest' && 'x86_64-pc-windows-msvc' || 'x86_64') }} | |
| command: build | |
| args: --release | |
| sccache: 'true' | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.os }}-py${{ matrix.python-version }} | |
| path: target/wheels/ | |
| # Create a release job that collects all wheels | |
| collect_wheels: | |
| name: Collect all wheels | |
| needs: build_and_test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: wheels | |
| - name: Display wheel files | |
| run: find wheels -type f -name "*.whl" | sort | |
| shell: bash | |
| - name: Upload combined wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: all-wheels | |
| path: wheels/*/*.whl |