1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
name: Test
on: [push, pull_request]
defaults:
run:
shell: bash
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v3
with:
version: "latest"
args: "check --fix-only --exit-non-zero-on-fix"
- uses: pre-commit-ci/lite-action@v1.1.0
if: always()
with:
msg: '[pre-commit.ci lite] apply automatic fixes for ruff linting errors'
test:
needs: [ruff]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ["3.11", "3.12", "3.13", "3.14"]
fail-fast: false
env:
BUILD_WHEEL: ${{ (matrix.os == 'ubuntu-latest' && matrix.python-version == '3.14') && 'true' || '' }}
PYTHONUNBUFFERED: "1"
steps:
- name: Obtain sasmodels source from git
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 }}
cache: 'pip'
cache-dependency-path: |
**/requirements*.txt
# If actions have problems with disk-space this can be re-enabled
# (The reports always show many GB in free space and it takes minutes to run)
# - name: Free Disk Space (Ubuntu)
# if: ${{ matrix.os == 'ubuntu-latest' }}
# uses: jlumbroso/free-disk-space@main
# with:
# haskell: false
# large-packages: false
### Build sasmodels
- name: Record figure building tools
if: env.BUILD_WHEEL
id: build-tools
run: |
echo "details=$(
python -m pip index versions matplotlib --json | python -c "import json; print(json.loads(input())['latest'])"
)" >> $GITHUB_OUTPUT
SASMODELS_BUILD_CACHE=~/.cache/sasmodels-figures
mkdir -p $SASMODELS_BUILD_CACHE
echo "SASMODELS_BUILD_CACHE=$SASMODELS_BUILD_CACHE" >> $GITHUB_ENV
- name: Cache figures in documentation
if: env.BUILD_WHEEL
id: cache-figures
uses: actions/cache@v4
with:
path: ${{ env.SASMODELS_BUILD_CACHE }}
key: ${{ steps.build-tools.outputs.details }}-${{ hashFiles('doc/genmodel.py') }}
- name: Report cache status
if: env.BUILD_WHEEL
run: |
if [ "${{ steps.cache-figures.outputs.cache-hit }}" == "true" ]; then
echo "Figure cache hit - using cached figures"
else
echo "Figure cache miss - will generate new figures"
fi
- name: Build sasmodels
if: env.BUILD_WHEEL
run: |
python -m pip install build hatchling
python -m build --sdist --wheel
python -m pip install dist/sasmodels*whl
- name: Publish sdist and wheel package
if: env.BUILD_WHEEL
uses: actions/upload-artifact@v4
with:
name: sasmodels-${{ matrix.os }}-${{ matrix.python-version }}
path: |
dist/sasmodels*whl
dist/sasmodels*tar*
if-no-files-found: ignore
### Publish documentation
- name: Publish sasmodels docs
if: env.BUILD_WHEEL
uses: actions/upload-artifact@v4
with:
name: sasmodels-docs-${{ matrix.os }}-${{ matrix.python-version }}
path: |
build/doc/
if-no-files-found: error
### Install dependencies
- name: Install Python dependencies (tests)
run: |
python -m pip install -r build_tools/requirements.txt -r build_tools/requirements-test.txt -r build_tools/requirements-opencl.txt
### Build and test sasmodels
- name: Test with pytest
env:
PYOPENCL_COMPILER_OUTPUT: 1
SAS_OPENCL: none
run: |
pytest -v
|