Python package tests #18
This file contains 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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
name: Python package tests | |
on: | |
pull_request: | |
branches: | |
- '*' | |
workflow_dispatch: | |
jobs: | |
test: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ ubuntu-latest, windows-latest, macos-13, macos-14 ] | |
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13.0-rc.3"] | |
runs-on: ${{ matrix.os }} | |
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 | |
python -m pip install setuptools cython | |
python -m pip install -e .[dev] | |
- name: Run tests in pure python mode | |
run: | | |
pytest tests --no-header --no-summary -v | |
if [ $? -ne 0 ]; then | |
echo "Pytest failed, running without capture" | |
pytest tests -v | |
else | |
echo "Pytest succeeded." | |
fi | |
shell: bash | |
if: runner.os != 'Windows' | |
- name: Run tests in pure python mode on Windows | |
run: | | |
pytest tests --no-header --no-summary -v | |
if %ERRORLEVEL% neq 0 ( | |
echo Pytest failed, running without capture | |
pytest tests -v | |
) else ( | |
echo Pytest succeeded. | |
) | |
shell: cmd | |
if: runner.os == 'Windows' | |
- name: Build cython modules | |
run: | | |
cd ./py_ballisticcalc.exts | |
python setup.py build_ext --inplace | |
cd .. | |
- name: Run unittest tests in binary mode | |
run: | | |
pytest tests --no-header --no-summary -v | |
if [ $? -ne 0 ]; then | |
echo "Pytest failed, running without capture" | |
pytest tests -v | |
else | |
echo "Pytest succeeded." | |
fi | |
shell: bash | |
if: runner.os != 'Windows' | |
- name: Run unittest tests in binary mode on Windows | |
run: | | |
pytest tests --no-header --no-summary -v | |
if %ERRORLEVEL% neq 0 ( | |
echo Pytest failed, running without capture | |
pytest tests -v | |
) else ( | |
echo Pytest succeeded. | |
) | |
shell: cmd | |
if: runner.os == 'Windows' |