| 1 |
name: CI |
| 2 |
on: |
| 3 |
pull_request: |
| 4 |
paths-ignore: |
| 5 |
- '**/*.md' |
| 6 |
push: |
| 7 |
branches: |
| 8 |
- main |
| 9 |
schedule: |
| 10 |
# run this every Wednesday at 3 am UTC |
| 11 |
- cron: 0 3 * * 3 |
| 12 |
workflow_dispatch: |
| 13 |
|
| 14 |
jobs: |
| 15 |
tests: |
| 16 |
strategy: |
| 17 |
fail-fast: false |
| 18 |
matrix: |
| 19 |
os: |
| 20 |
- ubuntu-latest |
| 21 |
python-version: |
| 22 |
- '3.10' |
| 23 |
- '3.11' |
| 24 |
- '3.12' |
| 25 |
- '3.13' |
| 26 |
include: |
| 27 |
# only test oldest and most recent Python on other platforms |
| 28 |
- os: macos-latest |
| 29 |
python-version: '3.10' |
| 30 |
- os: macos-latest |
| 31 |
python-version: '3.13' |
| 32 |
- os: windows-latest |
| 33 |
python-version: '3.10' |
| 34 |
- os: windows-latest |
| 35 |
python-version: '3.13' |
| 36 |
- os: ubuntu-20.04 |
| 37 |
python-version: '3.10' |
| 38 |
# 2023-09-15 is numpy 1.26.0's release date |
| 39 |
install-args: --resolution=lowest-direct --exclude-newer '2023-09-16' |
| 40 |
|
| 41 |
runs-on: ${{ matrix.os }} |
| 42 |
steps: |
| 43 |
- name: Checkout Source |
| 44 |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 45 |
- uses: astral-sh/setup-uv@887a942a15af3a7626099df99e897a18d9e5ab3a # v5.1.0 |
| 46 |
with: |
| 47 |
python-version: ${{ matrix.python-version }} |
| 48 |
|
| 49 |
- name: Run test suite |
| 50 |
shell: bash # for windows compat |
| 51 |
# forcing bytecode compilation for colorspacious |
| 52 |
# see https://github.com/astral-sh/uv/issues/4758 |
| 53 |
# Cannot use --frozen here because it overrides options like --resolution |
| 54 |
run: | |
| 55 |
uv run --no-editable --compile-bytecode \ |
| 56 |
--group test ${{ matrix.install-args }} \ |
| 57 |
pytest --color yes -ra |
| 58 |
|
| 59 |
- uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 |
| 60 |
if: failure() |
| 61 |
with: |
| 62 |
name: test_results |
| 63 |
path: test_results/ |
| 64 |
|
| 65 |
image-tests: |
| 66 |
name: Image tests |
| 67 |
runs-on: ubuntu-latest |
| 68 |
steps: |
| 69 |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 70 |
- uses: astral-sh/setup-uv@887a942a15af3a7626099df99e897a18d9e5ab3a # v5.1.0 |
| 71 |
with: |
| 72 |
python-version: '3.13' |
| 73 |
|
| 74 |
- name: Run Image Tests |
| 75 |
# forcing bytecode compilation for colorspacious |
| 76 |
# see https://github.com/astral-sh/uv/issues/4758 |
| 77 |
run: | |
| 78 |
uv run --frozen --no-editable --compile-bytecode --group test \ |
| 79 |
pytest --color=yes --mpl -m mpl_image_compare \ |
| 80 |
--mpl-generate-summary=html \ |
| 81 |
--mpl-results-path=pytest_mpl_results \ |
| 82 |
--mpl-baseline-path=tests/baseline |
| 83 |
|
| 84 |
- name: Generate new image baseline |
| 85 |
if: failure() |
| 86 |
run: | |
| 87 |
uv run --frozen --no-editable --group test \ |
| 88 |
pytest --color=yes --mpl -m mpl_image_compare \ |
| 89 |
--mpl-generate-path=pytest_mpl_new_baseline \ |
| 90 |
--last-failed |
| 91 |
|
| 92 |
# always attempt to upload artifacts, even |
| 93 |
# (and especially) in case of failure. |
| 94 |
- name: Upload pytest-mpl report |
| 95 |
if: always() |
| 96 |
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 |
| 97 |
with: |
| 98 |
name: cmyt_pytest_mpl_results |
| 99 |
path: pytest_mpl_results/* |
| 100 |
|
| 101 |
- name: Upload pytest-mpl baseline |
| 102 |
if: always() |
| 103 |
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 |
| 104 |
with: |
| 105 |
name: cmyt_pytest_mpl_new_baseline |
| 106 |
path: pytest_mpl_new_baseline/* |
| 107 |
if-no-files-found: ignore |
| 108 |
|
| 109 |
type-check: |
| 110 |
runs-on: ubuntu-latest |
| 111 |
|
| 112 |
strategy: |
| 113 |
matrix: |
| 114 |
python-version: |
| 115 |
# oldest and newest supported versions |
| 116 |
- '3.10' |
| 117 |
- '3.13' |
| 118 |
concurrency: |
| 119 |
# auto-cancel any in-progress job *on the same branch* |
| 120 |
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.python-version }}-typecheck |
| 121 |
cancel-in-progress: true |
| 122 |
|
| 123 |
steps: |
| 124 |
- name: Checkout repo |
| 125 |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 126 |
- uses: astral-sh/setup-uv@887a942a15af3a7626099df99e897a18d9e5ab3a # v5.1.0 |
| 127 |
with: |
| 128 |
python-version: ${{ matrix.python-version }} |
| 129 |
|
| 130 |
- name: Run mypy |
| 131 |
run: uv run --frozen --no-editable --group typecheck mypy cmyt |