Skip to content

Tests

Tests #691

Workflow file for this run

name: Tests
on:
push:
branches:
- main
pull_request:
schedule:
# Run weekly, Friday at 7:15 EST.
- cron: '15 12 * * 5'
jobs:
build:
if: |
startsWith(github.ref, 'refs/tags/v0') ||
startsWith(github.ref, 'refs/tags/v1') ||
startsWith(github.ref, 'refs/tags/v2') ||
startsWith(github.ref, 'refs/tags/v3') ||
startsWith(github.ref, 'refs/tags/v4') ||
startsWith(github.ref, 'refs/tags/v5') ||
startsWith(github.ref, 'refs/tags/v6') ||
startsWith(github.ref, 'refs/tags/v7') ||
startsWith(github.ref, 'refs/tags/v8') ||
startsWith(github.ref, 'refs/tags/v9')
name: Build Wheels
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install build
- name: Build
run: python -m build
- uses: actions/upload-artifact@v4
with:
path: |
./dist/*.whl
./dist/*.tar.gz
tests:
name: Tests
# always run, but wait for build if publishing
if: ${{ ! cancelled() }}
needs: [build]
runs-on: ubuntu-latest
env:
PUBLISH: >
${{
startsWith(github.ref, 'refs/tags/v0') ||
startsWith(github.ref, 'refs/tags/v1') ||
startsWith(github.ref, 'refs/tags/v2') ||
startsWith(github.ref, 'refs/tags/v3') ||
startsWith(github.ref, 'refs/tags/v4') ||
startsWith(github.ref, 'refs/tags/v5') ||
startsWith(github.ref, 'refs/tags/v6') ||
startsWith(github.ref, 'refs/tags/v7') ||
startsWith(github.ref, 'refs/tags/v8') ||
startsWith(github.ref, 'refs/tags/v9')
}}
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Pre-install dependencies
run: |
pip install -vU pip
pip install -vU setuptools wheel Cython 'numpy<2' # for classy
pip install -vU --no-build-isolation classy
- name: Install package from source
if: ${{ env.PUBLISH != 'true' }}
run: |
pip install -vU .[test]
make -C pipe_asdf
- name: Fetch wheel
if: ${{ env.PUBLISH == 'true' }}
uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- name: Install package from wheel
if: ${{ env.PUBLISH == 'true' }}
run: |
pip install $(ls dist/*.whl)[test]
- name: Test Python with pytest
run: |
# TODO: set up environment in tox
export NUMBA_THREADING_LAYER=forksafe
pytest -v
- name: Test pipe_asdf
# no C test client from wheels
if: ${{ env.PUBLISH != 'true' }}
run: |
./tests/test_pipe_asdf.sh
upload:
name: PyPI Upload
if: |
startsWith(github.ref, 'refs/tags/v0') ||
startsWith(github.ref, 'refs/tags/v1') ||
startsWith(github.ref, 'refs/tags/v2') ||
startsWith(github.ref, 'refs/tags/v3') ||
startsWith(github.ref, 'refs/tags/v4') ||
startsWith(github.ref, 'refs/tags/v5') ||
startsWith(github.ref, 'refs/tags/v6') ||
startsWith(github.ref, 'refs/tags/v7') ||
startsWith(github.ref, 'refs/tags/v8') ||
startsWith(github.ref, 'refs/tags/v9')
needs: [build, tests]
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1