Skip to content

Commit c4563ce

Browse files
authored
Merge pull request #143 from olafmeneses/feat/migrate-to-uv
feat: migrate to uv for 15x faster package installation and 40% CI time reduction
2 parents dee4bef + 4a9283c commit c4563ce

File tree

14 files changed

+3044
-285
lines changed

14 files changed

+3044
-285
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# This workflow is dedicated to building and saving the UV cache for Windows environments.
2+
# It is triggered on dependency file changes, manually, or on a schedule to warm the cache
3+
# for other workflows, helping to speed up their execution by providing a pre-built cache.
4+
name: Build UV Global Cache (Windows Only)
5+
6+
on:
7+
push:
8+
branches:
9+
- master
10+
- develop
11+
paths:
12+
- "uv.lock"
13+
- "pyproject.toml"
14+
- "requirements.txt"
15+
workflow_dispatch:
16+
schedule:
17+
# Every 5 days at midnight UTC, before cache expiry (7 days)
18+
- cron: "0 0 */5 * *"
19+
20+
jobs:
21+
build-cache-windows:
22+
runs-on: windows-latest
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
python: ["3.9", "3.10", "3.11", "3.12"]
27+
28+
name: Cache Windows / Python ${{ matrix.python }}
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v5
33+
34+
- name: Set up Python
35+
uses: actions/setup-python@v6
36+
with:
37+
python-version: ${{ matrix.python }}
38+
39+
- name: Install uv
40+
run: |
41+
irm https://astral.sh/uv/0.8.15/install.ps1 | iex
42+
$env:PATH = "$env:USERPROFILE\.local\bin;$env:PATH"
43+
Add-Content -Path $env:GITHUB_PATH -Value "$env:USERPROFILE\.local\bin"
44+
shell: powershell
45+
46+
- name: Install dependencies and populate cache
47+
run: |
48+
echo "Building global UV cache for Windows Python ${{ matrix.python }}..."
49+
uv sync --extra dev
50+
echo "Cache populated successfully"
51+
52+
- name: Save uv caches (Windows)
53+
uses: actions/cache/save@v4
54+
with:
55+
path: |
56+
~\AppData\Local\uv\cache
57+
~\AppData\Roaming\uv
58+
.venv
59+
key: uv-windows-latest-py${{ matrix.python }}-${{ hashFiles('uv.lock', 'pyproject.toml', 'requirements.txt') }}

.github/workflows/python-package.yml

Lines changed: 29 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -8,149 +8,53 @@ on:
88
branches: [ master, develop ]
99
tags:
1010
- "*"
11+
paths-ignore:
12+
- "docs/**"
13+
- "**/*.md"
14+
- "**/*.rst"
1115
pull_request:
1216
branches:
1317
- "*"
18+
paths-ignore:
19+
- "docs/**"
20+
- "**/*.md"
21+
- "**/*.rst"
1422

1523
jobs:
1624

1725
lint:
1826
runs-on: ubuntu-latest
1927
steps:
20-
- uses: actions/checkout@v2
21-
- uses: actions/setup-python@v1
28+
- uses: actions/checkout@v5
29+
- name: Set up Python
30+
uses: actions/setup-python@v6
2231
with:
2332
python-version: "3.12"
24-
- name: Install dependencies
33+
- name: Install uv
34+
uses: astral-sh/setup-uv@v6
35+
with:
36+
version: "0.8.15"
37+
- name: Set up dependencies
2538
run: |
26-
python -m pip install --upgrade pip
27-
pip install tox virtualenv ruff
39+
uv sync --extra dev
2840
- name: Lint
29-
run: "tox -e lint"
30-
31-
test:
32-
runs-on: ${{ matrix.os }}
33-
strategy:
34-
fail-fast: false
35-
matrix:
36-
name:
37-
- "ubuntu-py39"
38-
- "ubuntu-py310"
39-
- "ubuntu-py311"
40-
- "ubuntu-py312"
41-
42-
- "macos-py39"
43-
- "macos-py310"
44-
- "macos-py311"
45-
- "macos-py312"
46-
47-
- "windows-py39"
48-
- "windows-py310"
49-
- "windows-py311"
50-
- "windows-py312"
51-
52-
include:
53-
- name: "ubuntu-py39"
54-
python: "3.9"
55-
os: ubuntu-latest
56-
tox_env: "py39"
57-
- name: "ubuntu-py310"
58-
python: "3.10"
59-
os: ubuntu-latest
60-
tox_env: "py310"
61-
- name: "ubuntu-py311"
62-
python: "3.11"
63-
os: ubuntu-latest
64-
tox_env: "py311"
65-
- name: "ubuntu-py312"
66-
python: "3.12"
67-
os: ubuntu-latest
68-
tox_env: "py312"
41+
run: |
42+
uv run tox -e lint
6943
70-
- name: "macos-py39"
71-
python: "3.9"
72-
os: macos-latest
73-
tox_env: "py39"
74-
- name: "macos-py310"
75-
python: "3.10"
76-
os: macos-latest
77-
tox_env: "py310"
78-
- name: "macos-py311"
79-
python: "3.11"
80-
os: macos-latest
81-
tox_env: "py311"
82-
- name: "macos-py312"
83-
python: "3.12"
84-
os: macos-latest
85-
tox_env: "py312"
44+
windows-tests:
45+
name: test (Windows)
46+
uses: ./.github/workflows/test-windows.yml
8647

87-
- name: "windows-py39"
88-
python: "3.9"
89-
os: windows-latest
90-
tox_env: "py39"
91-
- name: "windows-py310"
92-
python: "3.10"
93-
os: windows-latest
94-
tox_env: "py310"
95-
- name: "windows-py311"
96-
python: "3.11"
97-
os: windows-latest
98-
tox_env: "py311"
99-
- name: "windows-py312"
100-
python: "3.12"
101-
os: windows-latest
102-
tox_env: "py312"
48+
macos-tests:
49+
name: test (macOS)
50+
uses: ./.github/workflows/test-macos.yml
10351

104-
steps:
105-
- uses: actions/checkout@v2
106-
- name: Set up Python ${{ matrix.python }}
107-
uses: actions/setup-python@v2
108-
with:
109-
python-version: ${{ matrix.python }}
110-
- name: Install dependencies
111-
run: |
112-
python -m pip install --upgrade pip
113-
python -m pip install -r requirements_dev.txt
114-
python -m pip install -r requirements.txt
115-
- name: Lint with ruff
116-
run: |
117-
# ruff lint
118-
ruff check spade
119-
- name: Test with pytest
120-
run: |
121-
pytest
122-
123-
coverage:
124-
runs-on: ubuntu-latest
125-
strategy:
126-
fail-fast: false
127-
matrix:
128-
python-version: ["3.9", "3.10", "3.11", "3.12"]
129-
steps:
130-
- uses: actions/checkout@v2
131-
- name: Set up Python ${{ matrix.python-version }}
132-
uses: actions/setup-python@v4
133-
with:
134-
python-version: ${{ matrix.python-version }}
135-
- name: Install dependencies
136-
run: |
137-
python -m pip install --upgrade pip
138-
python -m pip install -r requirements_dev.txt
139-
python -m pip install -r requirements.txt
140-
- name: Run coverage
141-
run: |
142-
coverage erase
143-
coverage run --source=spade -m pytest
144-
- name: Coveralls
145-
uses: javipalanca/coveralls-python-action@develop
146-
with:
147-
parallel: true
148-
flag-name: Unit Test
149-
- name: Send coverage report to codecov
150-
uses: codecov/codecov-action@v1
52+
ubuntu-tests:
53+
name: test (Ubuntu)
54+
uses: ./.github/workflows/test-linux-with-coverage.yml
15155

15256
coveralls_finish:
153-
needs: coverage
57+
needs: ubuntu-tests
15458
runs-on: ubuntu-latest
15559
steps:
15660
- name: Coveralls Finished
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Ubuntu Tests with Coverage
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
test-linux-with-coverage:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
python: ["3.9", "3.10", "3.11", "3.12"]
13+
name: Python ${{ matrix.python }} with coverage
14+
15+
steps:
16+
- uses: actions/checkout@v5
17+
- name: Set up Python
18+
uses: actions/setup-python@v6
19+
with:
20+
python-version: ${{ matrix.python }}
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v6
23+
with:
24+
version: "0.8.15"
25+
- name: Set up dependencies
26+
run: |
27+
uv sync --extra dev
28+
- name: Run coverage
29+
run: |
30+
uv run coverage erase
31+
uv run coverage run --source=spade -m pytest -q
32+
uv run coverage xml -o coverage.xml
33+
- name: Coveralls
34+
uses: javipalanca/coveralls-python-action@develop
35+
with:
36+
parallel: true
37+
flag-name: Unit Test
38+
- name: Send coverage report to codecov
39+
uses: codecov/codecov-action@v5

.github/workflows/test-macos.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: macOS Tests
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
test-macos:
8+
runs-on: macos-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
python: ["3.9", "3.10", "3.11", "3.12"]
13+
name: Python ${{ matrix.python }}
14+
15+
steps:
16+
- uses: actions/checkout@v5
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v6
20+
with:
21+
python-version: ${{ matrix.python }}
22+
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v6
25+
with:
26+
version: "0.8.15"
27+
enable-cache: true
28+
29+
- name: Set up dependencies
30+
run: |
31+
uv sync --extra dev
32+
33+
- name: Test with pytest
34+
run: |
35+
uv run pytest -q

.github/workflows/test-windows.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Windows Tests
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
test-windows:
8+
runs-on: windows-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
python: ["3.9", "3.10", "3.11", "3.12"]
13+
name: Python ${{ matrix.python }}
14+
15+
steps:
16+
- uses: actions/checkout@v5
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v6
20+
with:
21+
python-version: ${{ matrix.python }}
22+
23+
- name: Restore global uv cache
24+
id: cache-restore-windows
25+
uses: actions/cache/restore@v4
26+
with:
27+
path: |
28+
~\AppData\Local\uv\cache
29+
~\AppData\Roaming\uv
30+
.venv
31+
key: uv-windows-latest-py${{ matrix.python }}-${{ hashFiles('uv.lock', 'pyproject.toml', 'requirements.txt') }}
32+
restore-keys: |
33+
uv-windows-latest-py${{ matrix.python }}-
34+
35+
- name: Install uv
36+
run: |
37+
irm https://astral.sh/uv/0.8.15/install.ps1 | iex
38+
$env:PATH = "$env:USERPROFILE\.local\bin;$env:PATH"
39+
Add-Content -Path $env:GITHUB_PATH -Value "$env:USERPROFILE\.local\bin"
40+
shell: powershell
41+
42+
- name: Set up dependencies
43+
run: |
44+
uv sync --extra dev
45+
46+
- name: Save uv cache (if cache miss)
47+
if: steps.cache-restore-windows.outputs.cache-hit != 'true'
48+
uses: actions/cache/save@v4
49+
with:
50+
path: |
51+
~\AppData\Local\uv\cache
52+
~\AppData\Roaming\uv
53+
.venv
54+
key: uv-windows-latest-py${{ matrix.python }}-${{ hashFiles('uv.lock', 'pyproject.toml', 'requirements.txt') }}
55+
56+
- name: Test with pytest
57+
run: |
58+
uv run pytest -q

0 commit comments

Comments
 (0)