Skip to content

CI: Rewrite the "test" job matrix to run windows #84

CI: Rewrite the "test" job matrix to run windows

CI: Rewrite the "test" job matrix to run windows #84

name: Python package
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
release:
types: [ created ]
jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.11]
name: "lint | Python ${{ matrix.python-version }}"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install .
- name: Setup flake8 annotations
uses: rbialon/flake8-annotations@v1
- name: Run flake8
run: |
flake8 clifford --show-source --statistics
test:
defaults:
run:
# conda needs this to activate environments properly
shell: bash -l {0}
needs: lint
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.11"]
name: ['without JIT', 'default', 'doctests', 'slow tests', 'conda', 'benchmarks']
include:
# default tests with more python versions
- os: ubuntu-latest
python-version: "3.8"
name: 'default'
- os: ubuntu-latest
python-version: "3.12"
name: 'default'
- os: windows-latest
python-version: "3.12"
name: 'default'
name: "build | ${{ matrix.name }} | Py ${{matrix.python-version}} | ${{ matrix.os }}"
steps:
- uses: actions/checkout@v4
# python / pip
- name: Set up Python ${{ matrix.python-version }}
if: ${{ matrix.name != 'conda' }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
if: ${{ matrix.name != 'conda' }}
run: |
python -m pip install --upgrade pip;
pip install . --prefer-binary;
# test dependencies
pip install --upgrade pytest pytest-cov pytest-benchmark IPython
# conda
- name: Set up Python ${{ matrix.python-version }} (conda)
if: ${{ matrix.name == 'conda' }}
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Install dependencies (conda)
if: ${{ matrix.name == 'conda' }}
run: |
echo $CONDA/bin >> $GITHUB_PATH;
conda install \
"numpy>=1.17.0" \
scipy \
pip \
IPython \
h5py;
conda install -c conda-forge sparse;
conda install -c numba "numba>=0.45.1";
# make sure in conda we do not overwrite dependencies with pip
python setup.py develop --no-deps;
# test dependencies
python -m pip install --upgrade pytest pytest-cov pytest-benchmark;
- name: Select PYTEST_ARGS (${{ matrix.name }})
env:
NAME: ${{ matrix.name }}
run: |
if [[ "${NAME}" == "without JIT" ]]; then
echo NUMBA_DISABLE_JIT=1
echo NUMBA_DISABLE_JIT=1 >> $GITHUB_ENV
fi;
PYTEST_ARGS=();
if [[ "${NAME}" == "benchmarks" ]]; then
PYTEST_ARGS+=(--benchmark-only);
else
PYTEST_ARGS+=(--benchmark-skip);
fi;
if [[ "${NAME}" == "slow tests" ]]; then
PYTEST_ARGS+=(-m \"veryslow\");
else
PYTEST_ARGS+=(-m \"not veryslow\");
fi;
if [[ "${NAME}" == "doctests" ]]; then
PYTEST_ARGS+=(--doctest-modules --ignore clifford/test);
fi;
echo PYTEST_ARGS=${PYTEST_ARGS[@]}
echo PYTEST_ARGS=${PYTEST_ARGS[@]} >> $GITHUB_ENV
- name: Test with pytest
run: |
# `python -m` ensures we dispatch to conda if appropriate
python -m pytest \
--pyargs clifford \
${{ env.PYTEST_ARGS }} \
--color=yes \
-o junit_family=legacy \
--junitxml=junit/test-results.xml \
--durations=25 \
--cov=clifford \
--cov-branch;
# This only publishes result for the last run right now
# - name: Publish Test Report
# uses: mikepenz/action-junit-report@v2
# if: ${{ always() }}
# with:
# report_paths: 'junit/test-results.xml'
- uses: codecov/codecov-action@v5
deploy:
needs: test
runs-on: ubuntu-latest
name: deploy
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: "Install"
run: |
python -m pip install --upgrade pip;
python -m pip install build
python -m build --sdist --wheel --outdir dist/
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
if: startsWith(github.ref, 'refs/tags/v')
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}