-
Notifications
You must be signed in to change notification settings - Fork 428
74 lines (63 loc) · 2.2 KB
/
python-tests.yml
File metadata and controls
74 lines (63 loc) · 2.2 KB
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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python lint and tests
on:
push:
pull_request:
branches: ["dev"]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install uv and set the python version
id: setup-uv
uses: astral-sh/setup-uv@v7
with:
version: "0.8.15" # It is considered best practice to pin to a specific uv version
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
enable-cache: true
cache-dependency-glob: |
**/*requirements*.txt
**/pyproject.toml
**/uv.lock
- name: Do something if the cache was restored
if: steps.setup-uv.outputs.cache-hit == 'true'
run: echo "Cache was restored"
- name: Install the project
run: uv sync --all-extras --dev
- name: Run pre-commit hooks
run: >
uv run pre-commit
run --all-files
--show-diff-on-failure --color=always
test:
needs: lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v6
- name: Install uv and set the python version
id: setup-uv
uses: astral-sh/setup-uv@v7
with:
# https://docs.astral.sh/uv/guides/integration/github/#multiple-python-versions
python-version: ${{ matrix.python-version }}
version: "0.8.15" # It is considered best practice to pin to a specific uv version
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
enable-cache: true
cache-dependency-glob: |
**/*requirements*.txt
**/pyproject.toml
**/uv.lock
- name: Do something if the cache was restored
if: steps.setup-uv.outputs.cache-hit == 'true'
run: echo "Cache was restored"
- name: Install the project
run: uv sync --all-extras --dev
- name: Run tests
# For example, using `pytest`
run: uv run pytest -m ci