build: probe CONDA_PREFIX on every platform, not just Windows #4
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: Tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: ["*"] | |
| workflow_dispatch: | |
| # Cancel in-flight runs on the same ref. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| # Strategy: conda-forge on every platform. | |
| # | |
| # Why conda everywhere instead of apt+brew+conda? Three reasons: | |
| # | |
| # 1. **Same versions everywhere.** Apt's libjxl is 0.7.0 on Ubuntu LTS, | |
| # brew has 0.11.2, conda-forge has 0.11.2. With one channel, every | |
| # runner gets the same lib versions and the same code paths exercise | |
| # identically across OSes. | |
| # | |
| # 2. **libjxl 0.11+ guaranteed.** Ubuntu LTS, Debian stable, Fedora 41, | |
| # Alpine ≤3.22, EPEL 8/9 all ship libjxl < 0.11. Only conda-forge | |
| # and rolling distros have 0.11+. Source-building libjxl works (we | |
| # do that for cibuildwheel) but adds ~5 min cold to each CI run. | |
| # | |
| # 3. **Already proven on Windows.** The win-vm setup verified locally | |
| # uses exactly this conda-forge env. Reusing it here means one | |
| # configuration drift surface, not three. | |
| # | |
| # Cost is ~60-90 seconds of conda env setup per matrix cell — comparable | |
| # to apt-get install on a fresh runner. | |
| jobs: | |
| test: | |
| name: ${{ matrix.os }} Py ${{ matrix.python-version }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| python-version: ["3.10", "3.13"] | |
| defaults: | |
| run: | |
| # `bash -el` activates the conda env automatically and works on | |
| # all three runner OSes (Windows-bash via Git for Windows). | |
| shell: bash -el {0} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Miniforge + codec libs | |
| uses: conda-incubator/setup-miniconda@v3 | |
| with: | |
| miniforge-version: latest | |
| python-version: ${{ matrix.python-version }} | |
| activate-environment: ocbuild | |
| channels: conda-forge | |
| - name: Install codec C libraries | |
| run: | | |
| conda install -y \ | |
| libjxl libavif libheif libwebp libpng libjpeg-turbo openjpeg \ | |
| zlib libdeflate brotli libbrotlicommon c-blosc2 lz4-c zstd | |
| # ----- Build + test ----- | |
| - name: Install package + test deps | |
| run: | | |
| python -m pip install --upgrade pip setuptools wheel | |
| python -m pip install -e .[test] | |
| - name: List registered codecs (libjxl MUST be present) | |
| run: | | |
| python -c " | |
| import opencodecs as oc | |
| names = sorted(c['name'] for c in oc.list_codecs()) | |
| print(f'{len(names)} codecs:', names) | |
| assert 'jxl' in names, 'libjxl extension MUST register on every platform' | |
| " | |
| - name: Run tests | |
| run: pytest -q --cov=src/opencodecs --cov-report=xml --junitxml=junit.xml | |
| - name: Upload coverage + junit (one matrix cell) | |
| if: matrix.os == 'macos-latest' && matrix.python-version == '3.13' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results | |
| path: | | |
| coverage.xml | |
| junit.xml | |
| if-no-files-found: warn |