Skip to content

Commit

Permalink
Simplify conda use in tests (#674)
Browse files Browse the repository at this point in the history
* Simplify conda use in tests

* Make some commands one-liners

* Move pcodec import back

* Add no cover if codec not available
  • Loading branch information
dstansby authored Jan 4, 2025
1 parent 3a060f4 commit 6c0ea0f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 50 deletions.
69 changes: 20 additions & 49 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ jobs:
# macos-13 is an intel runner, macos-14 is a arm64 runner
platform: [ubuntu-latest, windows-latest, macos-13, macos-14]

defaults:
run:
shell: bash -el {0}

steps:
- name: Checkout source
uses: actions/checkout@v4
Expand All @@ -26,80 +30,47 @@ jobs:
- name: Set up Conda
uses: conda-incubator/[email protected]
with:
channels: conda-forge
miniforge-version: latest
python-version: ${{ matrix.python-version }}
channels: conda-forge
miniforge-version: latest
python-version: ${{ matrix.python-version }}

- name: Show info about `base` environment
shell: "bash -l {0}"
run: |
conda info
conda config --show-sources
conda list --show-channel-urls
- name: Set up `env`
shell: "bash -l {0}"
run: >
conda create -n env
c-compiler cxx-compiler
python=${{matrix.python-version}} wheel pip
- name: Install compilers
run: conda install -y c-compiler cxx-compiler

- name: Install clang
shell: "bash -l {0}"
if: matrix.platform == 'macos-13'
run: |
conda activate env
conda install -y 'clang>=12.0.1,<17'
run: conda install -y 'clang>=12.0.1,<17'

- name: Show info about `env` environment
shell: "bash -l {0}"
- name: Show conda environment info
run: |
conda list --show-channel-urls -n env
conda info
conda config --show-sources
conda list --show-channel-urls
- name: Install numcodecs
shell: "bash -l {0}"
run: |
conda activate env
export DISABLE_NUMCODECS_AVX2=""
# TODO: put back zfpy import when it supports numpy 2.0
python -m pip install -v -e .[test,test_extras,msgpack,crc32c]
- name: Install pcodec
if: matrix.python-version != '3.13'
shell: "bash -l {0}"
run: |
conda activate env
python -m pip install -v ".[pcodec]"
python -m pip install -v -e .[test,test_extras,msgpack,crc32c,pcodec]
- name: Install zarr-python
shell: "bash -l {0}"
# Since zarr v3 requires numpy >= 1.25, on Python 3.11 leave it out
# so we can have some tests of our minimum version of numpy (1.24)
if: matrix.python-version != '3.11'
run: |
conda activate env
# TODO: remove --pre option when zarr v3 is out
python -m pip install --pre zarr>=3.0.0b2
# TODO: remove --pre option when zarr v3 is out
run: python -m pip install --pre zarr>=3.0.0b2

# This is used to test with zfpy, which does not yet support numpy 2.0
- name: Install older numpy and zfpy
if: matrix.python-version == '3.11'
shell: "bash -l {0}"
run: |
conda activate env
python -m pip install -v ".[zfpy]"
run: python -m pip install -v ".[zfpy]"

- name: List installed packages
shell: "bash -l {0}"
run: |
conda activate env
python -m pip list
run: python -m pip list

- name: Run tests
shell: "bash -l {0}"
run: |
conda activate env
pytest -v
run: pytest -v

- uses: codecov/codecov-action@v5
with:
Expand Down
2 changes: 1 addition & 1 deletion numcodecs/tests/test_zarr3.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def test_generic_bytes_codec(
pytest.xfail(f"{codec_class.codec_name} is not available: {e}")
else:
raise # pragma: no cover
except ImportError as e:
except ImportError as e: # pragma: no cover
pytest.xfail(f"{codec_class.codec_name} is not available: {e}")

data = np.arange(0, 256, dtype="float32").reshape((16, 16))
Expand Down

0 comments on commit 6c0ea0f

Please sign in to comment.