-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (84 loc) · 2.79 KB
/
unittests.yml
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
name: Tests
on:
push:
branches:
- main
pull_request:
branches:
- "**"
jobs:
tests:
strategy:
fail-fast: false
matrix:
# Note that we only do type checking on Python 3.13 (the latest Python version).
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
os:
- ubuntu-latest
- windows-latest
- macos-latest
runs-on: ${{ matrix.os }}
env:
# Set the Python version that `uv` will use for its virtual environment.
UV_PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4
- name: Set up base Python
uses: actions/setup-python@v5
with:
# Note that this is just the version of Python that we use to run `uv` with.
# `uv` manages its own version of Python.
# For speed, we use the same version for both, but in principle these could differ.
python-version: ${{ matrix.python-version }}
- name: Set up uv cache directory location (Linux/Mac)
run: echo "UV_CACHE_DIR=${{ runner.temp }}/.uv-cache" >> $GITHUB_ENV
if: runner.os != 'Windows'
- name: Set up uv cache directory location (Windows)
run: echo "UV_CACHE_DIR=${{ runner.temp }}/.uv-cache" >> $env:GITHUB_ENV
if: runner.os == 'Windows'
- name: Restore uv cache
uses: actions/cache@v4
with:
path: ${{ env.UV_CACHE_DIR }}
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}-${{ matrix.python-version }}-test
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}-${{ matrix.python-version }}
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install uv
run: pip install uv
- name: Install test dependencies
run: uv sync --extra test --no-dev --locked
- name: Debug - uv pip freeze
run: uv pip freeze
- name: Run tests incompatible with type checking
run: >
uv run pytest
--ignore=tests/test_examples.py
-W "error::vanguard.utils.UnseededRandomWarning"
-m "no_beartype"
if: matrix.python-version == '3.13'
- name: Test with pytest (and type checking)
run: >
uv run pytest
--ignore=tests/test_examples.py
-W "error::vanguard.utils.UnseededRandomWarning"
-m "not no_beartype"
--beartype-packages="vanguard"
if: matrix.python-version == '3.13'
- name: Run all tests
run: >
uv run pytest
--ignore=tests/test_examples.py
-W "error::vanguard.utils.UnseededRandomWarning"
if: matrix.python-version != '3.13'
- name: Minimize UV cache
run: uv cache prune --ci
if: always()