Skip to content

Commit 6c0ea0f

Browse files
authored
Simplify conda use in tests (#674)
* Simplify conda use in tests * Make some commands one-liners * Move pcodec import back * Add no cover if codec not available
1 parent 3a060f4 commit 6c0ea0f

File tree

2 files changed

+21
-50
lines changed

2 files changed

+21
-50
lines changed

.github/workflows/ci.yaml

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ jobs:
1616
# macos-13 is an intel runner, macos-14 is a arm64 runner
1717
platform: [ubuntu-latest, windows-latest, macos-13, macos-14]
1818

19+
defaults:
20+
run:
21+
shell: bash -el {0}
22+
1923
steps:
2024
- name: Checkout source
2125
uses: actions/checkout@v4
@@ -26,80 +30,47 @@ jobs:
2630
- name: Set up Conda
2731
uses: conda-incubator/[email protected]
2832
with:
29-
channels: conda-forge
30-
miniforge-version: latest
31-
python-version: ${{ matrix.python-version }}
33+
channels: conda-forge
34+
miniforge-version: latest
35+
python-version: ${{ matrix.python-version }}
3236

33-
- name: Show info about `base` environment
34-
shell: "bash -l {0}"
35-
run: |
36-
conda info
37-
conda config --show-sources
38-
conda list --show-channel-urls
39-
40-
- name: Set up `env`
41-
shell: "bash -l {0}"
42-
run: >
43-
conda create -n env
44-
c-compiler cxx-compiler
45-
python=${{matrix.python-version}} wheel pip
37+
- name: Install compilers
38+
run: conda install -y c-compiler cxx-compiler
4639

4740
- name: Install clang
48-
shell: "bash -l {0}"
4941
if: matrix.platform == 'macos-13'
50-
run: |
51-
conda activate env
52-
conda install -y 'clang>=12.0.1,<17'
42+
run: conda install -y 'clang>=12.0.1,<17'
5343

54-
- name: Show info about `env` environment
55-
shell: "bash -l {0}"
44+
- name: Show conda environment info
5645
run: |
57-
conda list --show-channel-urls -n env
46+
conda info
47+
conda config --show-sources
48+
conda list --show-channel-urls
5849
5950
- name: Install numcodecs
60-
shell: "bash -l {0}"
6151
run: |
62-
conda activate env
6352
export DISABLE_NUMCODECS_AVX2=""
6453
# TODO: put back zfpy import when it supports numpy 2.0
65-
python -m pip install -v -e .[test,test_extras,msgpack,crc32c]
66-
67-
- name: Install pcodec
68-
if: matrix.python-version != '3.13'
69-
shell: "bash -l {0}"
70-
run: |
71-
conda activate env
72-
python -m pip install -v ".[pcodec]"
54+
python -m pip install -v -e .[test,test_extras,msgpack,crc32c,pcodec]
7355
7456
- name: Install zarr-python
75-
shell: "bash -l {0}"
7657
# Since zarr v3 requires numpy >= 1.25, on Python 3.11 leave it out
7758
# so we can have some tests of our minimum version of numpy (1.24)
7859
if: matrix.python-version != '3.11'
79-
run: |
80-
conda activate env
81-
# TODO: remove --pre option when zarr v3 is out
82-
python -m pip install --pre zarr>=3.0.0b2
60+
# TODO: remove --pre option when zarr v3 is out
61+
run: python -m pip install --pre zarr>=3.0.0b2
8362

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

9268
- name: List installed packages
93-
shell: "bash -l {0}"
94-
run: |
95-
conda activate env
96-
python -m pip list
69+
run: python -m pip list
9770

9871
- name: Run tests
9972
shell: "bash -l {0}"
100-
run: |
101-
conda activate env
102-
pytest -v
73+
run: pytest -v
10374

10475
- uses: codecov/codecov-action@v5
10576
with:

numcodecs/tests/test_zarr3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def test_generic_bytes_codec(
230230
pytest.xfail(f"{codec_class.codec_name} is not available: {e}")
231231
else:
232232
raise # pragma: no cover
233-
except ImportError as e:
233+
except ImportError as e: # pragma: no cover
234234
pytest.xfail(f"{codec_class.codec_name} is not available: {e}")
235235

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

0 commit comments

Comments
 (0)