Skip to content

Commit eded712

Browse files
Emlyn GrahamEmlyn Graham
authored andcommitted
Add uv to CI and requirements to pyproject
1 parent 69b41c4 commit eded712

30 files changed

Lines changed: 3455 additions & 252 deletions

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# SCM syntax highlighting & preventing 3-way merges
2+
uv.lock merge=binary linguist-language=TOML linguist-generated=true -diff
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Set up uv
2+
description: Install the pinned version of uv and cache its package cache
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Install uv
8+
shell: bash
9+
run: pip install -r .github/uv-requirements.txt
10+
11+
- name: Cache uv packages
12+
uses: actions/cache@v4
13+
with:
14+
path: ~/.cache/uv
15+
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
16+
restore-keys: |
17+
uv-${{ runner.os }}-

.github/dependabot.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
version: 2
22
updates:
3-
- package-ecosystem: "pip"
3+
- package-ecosystem: "uv"
44
directory: "/"
55
schedule:
66
interval: weekly
77
groups:
88
python-packages:
99
patterns:
1010
- "*"
11+
- package-ecosystem: "pip"
12+
directory: "/.github"
13+
schedule:
14+
interval: "weekly"

.github/uv-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uv==0.11.3

.github/workflows/ci.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,11 @@ jobs:
2525
steps:
2626
- uses: actions/checkout@v5
2727
with:
28-
fetch-depth: 0 # Fetch all, necessary to find tags and branches
28+
fetch-depth: 0 # Fetch all, necessary to find tags and branches
2929
fetch-tags: true
3030

31-
- uses: actions/setup-python@v5
32-
with:
33-
python-version: ${{ matrix.python }}
34-
35-
- run: python -m pip install --upgrade pip
36-
37-
- name: Setup nox
38-
run: pip install -c requirements-dev.txt nox
31+
- name: Setup uv
32+
uses: ./.github/actions/setup-uv
3933

40-
- run: nox --python ${{ matrix.python }}
34+
- name: Run nox
35+
run: uv run --extra dev nox -db uv --python ${{ matrix.python }}

.github/workflows/cov.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: pytest-cov
22

3-
# Need to include "push"
43
on: [push, pull_request]
54

65
permissions:
@@ -16,22 +15,17 @@ jobs:
1615
steps:
1716
- uses: actions/checkout@v5
1817
with:
19-
fetch-depth: 0 # Fetch all, necessary to find tags and branches
18+
fetch-depth: 0 # Fetch all, necessary to find tags and branches
2019
fetch-tags: true
2120

22-
- name: Set up Python
23-
uses: actions/setup-python@v5
21+
- name: Setup uv
22+
uses: ./.github/actions/setup-uv
2423
with:
24+
enable-cache: true
2525
python-version: ${{ env.python-version }}
2626

27-
- name: Upgrade pip
28-
run: python -m pip install --upgrade pip
29-
30-
- name: Install graphix with dev deps.
31-
run: pip install .[dev,extra]
32-
3327
- name: Run pytest
34-
run: pytest --cov=./graphix --cov-report=xml --cov-report=term --doctest-modules
28+
run: uv run --extra dev --extra extra pytest --cov=./graphix --cov-report=xml --cov-report=term --doctest-modules
3529

3630
- name: Upload coverage reports to Codecov
3731
uses: codecov/codecov-action@v5

.github/workflows/doc.yml

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,44 +22,39 @@ jobs:
2222
steps:
2323
- uses: actions/checkout@v5
2424
with:
25-
fetch-depth: 0 # Fetch all, necessary to find tags and branches
25+
fetch-depth: 0 # Fetch all, necessary to find tags and branches
2626
fetch-tags: true
2727

28-
- uses: actions/setup-python@v5
28+
- name: Setup uv
29+
uses: ./.github/actions/setup-uv
2930
with:
31+
enable-cache: true
3032
python-version: ${{ env.python-version }}
3133

32-
- name: Upgrade pip
33-
run: python -m pip install --upgrade pip
34-
35-
- name: Install graphix
36-
run: pip install -e ".[dev,doc]"
37-
3834
- name: Make docs
39-
run: sphinx-build -W docs/source docs/build -j auto
35+
run: uv run --extra dev --extra doc sphinx-build -W docs/source docs/build -j auto
4036

4137
lint-text:
4238
runs-on: ubuntu-latest
4339
steps:
44-
- uses: actions/checkout@v4
40+
- uses: actions/checkout@v5
4541

46-
- uses: actions/setup-python@v5
42+
- name: Setup uv
43+
uses: ./.github/actions/setup-uv
4744
with:
48-
python-version: ${{ env.python-version }}
45+
enable-cache: true
4946

5047
- name: Run language-agnostic linters
5148
run: |
52-
pip install pre-commit
53-
5449
# Non-fixable
55-
pre-commit run -a check-case-conflict
56-
pre-commit run -a check-yaml
50+
uvx pre-commit run -a check-case-conflict
51+
uvx pre-commit run -a check-yaml
5752
5853
# Fixable
59-
pre-commit run -a end-of-file-fixer || true
60-
pre-commit run -a fix-byte-order-marker || true
61-
pre-commit run -a mixed-line-ending || true
62-
pre-commit run -a trailing-whitespace || true
54+
uvx pre-commit run -a end-of-file-fixer || true
55+
uvx pre-commit run -a fix-byte-order-marker || true
56+
uvx pre-commit run -a mixed-line-ending || true
57+
uvx pre-commit run -a trailing-whitespace || true
6358
6459
- uses: actions/setup-node@v4
6560

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
permissions:
1616
id-token: write
1717
steps:
18-
- uses: actions/checkout@v4
19-
- uses: actions/setup-python@v5
18+
- uses: actions/checkout@v5
19+
- uses: actions/setup-python@v6
2020
with:
2121
python-version: ${{ env.python-version }}
2222
- name: Install pypa/build

.github/workflows/ruff.yml

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,30 @@ jobs:
1515
lint:
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v4
19-
20-
- name: Cache pip dependencies
21-
uses: actions/cache@v4
18+
- uses: actions/checkout@v5
2219
with:
23-
path: ~/.cache/pip
24-
key: ${{ runner.os }}-pip-${{ hashFiles('requirements-dev.txt') }}
25-
restore-keys: |
26-
${{ runner.os }}-pip-
20+
fetch-depth: 0
2721

28-
- name: Install dependencies
29-
run: python -m pip install --upgrade pip && python -m pip install ruff -c requirements-dev.txt
22+
- name: Setup uv
23+
uses: ./.github/actions/setup-uv
24+
with:
25+
enable-cache: true
26+
cache-dependency-glob: "pyproject.toml"
3027

3128
- name: Run Ruff Linter
32-
run: ruff check --output-format=github
29+
run: uv run --with ruff ruff check --output-format=github
3330

3431
format:
3532
runs-on: ubuntu-latest
3633
steps:
37-
- uses: actions/checkout@v4
38-
39-
- name: Cache pip dependencies
40-
uses: actions/cache@v4
34+
- uses: actions/checkout@v5
4135
with:
42-
path: ~/.cache/pip
43-
key: ${{ runner.os }}-pip-${{ hashFiles('requirements-dev.txt') }}
44-
restore-keys: |
45-
${{ runner.os }}-pip-
36+
fetch-depth: 0
4637

47-
- name: Install dependencies
48-
run: python -m pip install --upgrade pip && python -m pip install ruff -c requirements-dev.txt
38+
- name: Setup uv
39+
uses: ./.github/actions/setup-uv
40+
with:
41+
enable-cache: true
4942

5043
- name: Run Ruff Formatter Check
51-
run: ruff format --check
44+
run: uv run --with ruff ruff format --check

.github/workflows/typecheck.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,18 @@ jobs:
2323
steps:
2424
- uses: actions/checkout@v5
2525
with:
26-
fetch-depth: 0 # Fetch all, necessary to find tags and branches
26+
fetch-depth: 0 # Fetch all, necessary to find tags and branches
2727
fetch-tags: true
2828

29-
- uses: actions/setup-python@v5
29+
- name: Setup uv
30+
uses: ./.github/actions/setup-uv
3031
with:
32+
enable-cache: true
3133
python-version: ${{ env.python-version }}
3234

33-
- run: |
34-
python -m pip install --upgrade pip
35-
pip install -e .[dev,extra,typing]
36-
pip install --no-deps -e .[no-deps]
35+
- run: uv run --extra dev --extra extra --extra typing mypy
3736

38-
- run: mypy
39-
40-
- run: pyright
37+
- run: uv run --extra dev --extra extra --extra typing pyright
4138

4239
# Check that `mypy` find installed `graphix` package (#328)
4340
#
@@ -54,20 +51,20 @@ jobs:
5451
steps:
5552
- uses: actions/checkout@v5
5653
with:
57-
fetch-depth: 0 # Fetch all, necessary to find tags and branches
54+
fetch-depth: 0 # Fetch all, necessary to find tags and branches
5855
fetch-tags: true
5956

60-
- uses: actions/setup-python@v5
57+
- name: Setup uv
58+
uses: ./.github/actions/setup-uv
6159
with:
60+
enable-cache: true
6261
python-version: ${{ env.python-version }}
6362

6463
- name: Install graphix and mypy
65-
run: |
66-
python -m pip install --upgrade pip
67-
pip install .[dev]
64+
run: uv sync --extra dev --no-editable
6865

6966
- name: Test type-checking
7067
run: |
7168
cd ${{ runner.temp }}
7269
echo "from graphix import Pattern" > test_graphix_type.py
73-
mypy test_graphix_type.py
70+
uv run --project ${{ github.workspace }} --no-sync mypy test_graphix_type.py

0 commit comments

Comments
 (0)