Skip to content

[.pre-commit-config.yaml]: Update Hooks #341

[.pre-commit-config.yaml]: Update Hooks

[.pre-commit-config.yaml]: Update Hooks #341

Workflow file for this run

# Test Code.
#
# See:
# https://docs.github.com/en/actions/guides/building-and-testing-python
name: "Tests"
on:
push:
branches:
- "**"
paths:
- ".github/**"
- "**.py"
- "**.rst"
- "docs/**"
- ".flake8"
- "pyproject.toml"
- "**requirements*.txt"
tags:
- "v[0-9]*"
release:
jobs:
test:
strategy:
matrix:
# Tests must be run on all target platforms and Python versions
os:
- "ubuntu-latest"
- "macos-latest"
- "windows-latest"
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
# Do not cancel in-progress jobs if any matrix job fails
fail-fast: false
runs-on: "${{ matrix.os }}"
steps:
- name: "Checkout repository"
uses: "actions/checkout@v4"
- name: "Set up Python ${{ matrix.python-version }}"
uses: "actions/setup-python@v5"
with:
python-version: "${{ matrix.python-version }}"
- name: "Add directories where pip installs scripts to PATH"
run: |
echo "${HOME}/.local/bin" >> ${GITHUB_PATH}
# Installation path on MacOS for Python >=3.11.
echo "/Users/runner/Library/Python/${{ matrix.python-version }}/bin" >> ${GITHUB_PATH}
- name: "Get pip cache dir"
# pip's cache path depends on the operating system. See
# https://github.com/actions/cache/blob/main/examples.md#python---pip
# This requires pip >=20.1.
id: "pip-cache"
run: |
python -m pip install --user --upgrade pip
echo "dir=$(pip cache dir)" >> ${GITHUB_OUTPUT}
- name: "Create/Restore cache"
uses: "actions/cache@v4"
with:
path: |
${{ steps.pip-cache.outputs.dir }}/**
./docs/build/**
key: |
${{ runner.os }}-${{ matrix.python-version }}-${{ github.job }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}
${{ runner.os }}
- name: "Install/Upgrade setuptools and wheel"
run: "python -m pip install --user --upgrade setuptools wheel"
- name: "Install/Upgrade requirements to build the documentation"
run: |
python -m pip install --user --upgrade -r docs/requirements-docs.txt
- name: "Test build of the documentation"
run: "make -C ./docs/ html"
- name: "doctest"
# Because the default dtypes of NumPy arrays are different on
# Windows, doctest will detect false failures. See e.g.
# https://stackoverflow.com/questions/36278590/numpy-array-dtype-is-coming-as-int32-by-default-in-a-windows-10-64-bit-machine
if: "${{ runner.os != 'Windows' }}"
run: "make -C ./docs/ doctest"
- name: "linkcheck"
if: "${{ runner.os == 'Linux' && matrix.python-version == '3.11' }}"
run: "make -C ./docs/ linkcheck"