add more python versions to tests #108
Workflow file for this run
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
name: Build and test wakepy | |
'on': | |
# Allows for manually starting tests | |
workflow_dispatch: | |
# Make this a reusable workflow | |
workflow_call: | |
# Triggers when pull request is created and when pushing to PR | |
pull_request: | |
# Common environment variables | |
env: | |
TOX_REQUIREMENT: 'tox -c requirements/requirements-test.txt' | |
# List of available versions: https://github.com/actions/python-versions/blob/main/versions-manifest.json | |
PYTHON_VERSION: '3.10' | |
jobs: | |
build-python-distributions: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get history and tags for setuptools-scm | |
run: | | |
git fetch --prune --unshallow | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
git describe --tags | |
git describe --tags $(git rev-list --tags --max-count=1) | |
- name: Install python | |
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d #v5.1 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: install tox | |
run: | | |
python${{ env.PYTHON_VERSION }} -m pip install -U pip wheel && \ | |
python${{ env.PYTHON_VERSION }} -m pip install ${{ env.TOX_REQUIREMENT }} | |
- name: Build with tox | |
run: tox -e build | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wakepy-python-packages | |
path: ./dist/*.* | |
if-no-files-found: error | |
retention-days: 1 | |
test-supported-python-versions: | |
name: Tests (${{ matrix.python-version }} @${{ matrix.os }}) | |
runs-on: ${{ matrix.os }} | |
needs: build-python-distributions | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: wakepy-python-packages | |
path: ./dist/ | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d #v5.1 | |
with: | |
python-version: ${{ matrix.python-version }} | |
allow-prereleases: true | |
- name: Run tox | |
run: | | |
python -m pip install ${{ env.TOX_REQUIREMENT }} | |
tox -e ${{ matrix.python-version }} --skip-build | |
tox -e show-uncovered-lines | |
tox -e mypy --skip-build | |
test-other-platforms: | |
name: Tests (${{ matrix.python-version }} @${{ matrix.os }}) | |
runs-on: ${{ matrix.os }} | |
needs: build-python-distributions | |
strategy: | |
matrix: | |
os: [macos-latest, windows-latest] | |
# Test only on oldest and newest supported versions | |
# different python versions are already tested in another step. | |
python-version: ["3.7", "3.13"] | |
exclude: | |
- python-version: "3.7" | |
os: macos-latest | |
include: | |
- python-version: "3.7" | |
os: macos-13 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: wakepy-python-packages | |
path: ./dist/ | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d #v5.1 | |
with: | |
python-version: ${{ matrix.python-version }} | |
allow-prereleases: true | |
- name: Run tox | |
run: | | |
python -m pip install ${{ env.TOX_REQUIREMENT }} | |
tox -e ${{ matrix.python-version }} --skip-build | |
tox -e show-uncovered-lines | |
check-code: | |
# Reasons this is a separate job | |
# (1) This runs fast. Different from the other steps, this does not require | |
# the build step. It gives instant feedback if code has minor problems. | |
# (2) This runs isort + black + ruff + mypy. For most of there it is enough | |
# to run it once with one version of python and one OS. | |
# (3) This runs more comprehensive mypy check as it checks also the tests | |
# whereas the mypy check in test jobs only runs mypy on the /src | |
# folder. Note that some mypy check results depend on the used version | |
# of python and therefore it needs also a separate step (with multiple | |
# versions of python) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install python | |
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d #v5.1 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: install tox | |
run: | | |
python${{ env.PYTHON_VERSION }} -m pip install -U pip wheel && \ | |
python${{ env.PYTHON_VERSION }} -m pip install ${{ env.TOX_REQUIREMENT }} | |
- name: Check code | |
run: tox -e check | |
test-build-docs: | |
runs-on: ubuntu-latest | |
needs: build-python-distributions | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install python | |
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d #v5.1 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: install tox | |
run: | | |
python${{ env.PYTHON_VERSION }} -m pip install -U pip wheel && \ | |
python${{ env.PYTHON_VERSION }} -m pip install ${{ env.TOX_REQUIREMENT }} | |
- name: Test building docs | |
run: tox -e builddocs | |
# Cancel in-progress jobs/runs for the same workflow; if you push to same | |
# pull request twice, the previous workflow should be canceled. | |
# From: https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
# See: https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs | |
permissions: | |
actions: write | |
checks: none | |
contents: read | |
deployments: none | |
id-token: none | |
issues: none | |
discussions: none | |
packages: none | |
pages: none | |
pull-requests: none | |
repository-projects: none | |
security-events: read | |
statuses: none |