Skip to content

Commit 32ef79c

Browse files
authored
Merge pull request #64 from mike-oakley/u/mike/uv
feat: Migrate to uv.
2 parents 8f2a7ca + f71e0a8 commit 32ef79c

File tree

15 files changed

+1519
-1400
lines changed

15 files changed

+1519
-1400
lines changed

.devcontainer/devcontainer.json

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
{
22
"name": "openapi-pydantic",
33
"image": "mcr.microsoft.com/devcontainers/python:0-3.11",
4+
"mounts": [
5+
"source=${devcontainerId}-cache,target=${containerWorkspaceFolder}/.cache,type=volume",
6+
"source=${devcontainerId}-venv,target=${containerWorkspaceFolder}/.venv,type=volume"
7+
],
8+
"onCreateCommand": "sudo chown vscode .cache && sudo chown vscode .venv",
49
"features": {
5-
"ghcr.io/devcontainers-contrib/features/poetry:2": {
6-
"version": "latest"
10+
"ghcr.io/va-h/devcontainers-features/uv:1": {
11+
"version": "latest",
12+
"shellautocompletion": true
713
}
814
},
915
"containerEnv": {
10-
"POETRY_VIRTUALENVS_IN_PROJECT": "true"
16+
"XDG_CACHE_DIR": ".cache",
17+
"UV_CACHE_DIR": ".cache/.uv-cache",
18+
"UV_LINK_MODE": "symlink",
19+
"RUFF_CACHE_DIR": ".cache/.ruff-cache",
20+
"MYPY_CACHE_DIR": ".cache/.mypy-cache"
1121
},
12-
"postCreateCommand": "poetry install && pip install --upgrade tox",
22+
"updateContentCommand": "uv sync --all-groups",
1323
"customizations": {
1424
"vscode": {
1525
"extensions": [
1626
"ms-python.python",
1727
"ms-python.vscode-pylance",
18-
"charliermarsh.ruff"
28+
"charliermarsh.ruff",
29+
"github.vscode-github-actions"
1930
]
2031
}
2132
}

.github/workflows/publish.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,27 @@ on:
66
types:
77
- published
88

9+
env:
10+
UV_VERSION: 0.7.5
11+
912
jobs:
1013
build:
1114
name: Build package
1215
runs-on: ubuntu-latest
1316
steps:
1417
- name: Checkout repository
1518
uses: actions/checkout@v4
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v6
21+
with:
22+
version: "${{ env.UV_VERSION }}"
23+
enable-cache: true
1624
- name: Set up Python
1725
uses: actions/setup-python@v5
1826
with:
1927
python-version: 3.12
20-
- name: Install Poetry
21-
uses: snok/install-poetry@v1
22-
with:
23-
virtualenvs-create: false
24-
version: 1.8.3
2528
- name: Build package distribution
26-
run: poetry build
29+
run: uv build
2730
- name: Upload package artifact
2831
uses: actions/upload-artifact@v4
2932
with:
@@ -38,7 +41,7 @@ jobs:
3841
name: test
3942
url: https://test.pypi.org/p/openapi-pydantic
4043
permissions:
41-
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
44+
id-token: write
4245
steps:
4346
- name: Download package distribution
4447
uses: actions/download-artifact@v4
@@ -58,7 +61,7 @@ jobs:
5861
name: production
5962
url: https://pypi.org/p/openapi-pydantic
6063
permissions:
61-
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
64+
id-token: write
6265
steps:
6366
- name: Download package distribution
6467
uses: actions/download-artifact@v4

.github/workflows/smokeshow.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Smokeshow
2+
3+
on:
4+
workflow_run:
5+
workflows: [Test]
6+
types: [completed]
7+
8+
permissions:
9+
statuses: write
10+
11+
env:
12+
UV_VERSION: 0.7.5
13+
SMOKESHOW_VERSION: 0.5.0
14+
15+
16+
jobs:
17+
smokeshow:
18+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Dump GitHub context
23+
env:
24+
GITHUB_CONTEXT: ${{ toJson(github) }}
25+
run: echo "$GITHUB_CONTEXT"
26+
- uses: actions/checkout@v4
27+
- uses: actions/setup-python@v5
28+
id: setup-python
29+
with:
30+
python-version: '3.12'
31+
- name: Setup uv
32+
uses: astral-sh/setup-uv@v6
33+
with:
34+
version: "${{ env.UV_VERSION }}"
35+
enable-cache: true
36+
- uses: actions/download-artifact@v4
37+
with:
38+
name: coverage-html
39+
path: htmlcov
40+
github-token: ${{ secrets.GITHUB_TOKEN }}
41+
run-id: ${{ github.event.workflow_run.id }}
42+
# Try 5 times to upload coverage to smokeshow
43+
- name: Upload coverage to Smokeshow
44+
run: |
45+
for i in 1 2 3 4 5; do
46+
if uv tool run smokeshow@${{ env.SMOKESHOW_VERSION }} upload htmlcov; then
47+
echo "Smokeshow upload success!"
48+
break
49+
fi
50+
echo "Smokeshow upload error, sleep 1 sec and try again."
51+
sleep 1
52+
done
53+
env:
54+
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}
55+
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 97
56+
SMOKESHOW_GITHUB_CONTEXT: coverage
57+
SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
59+
SMOKESHOW_AUTH_KEY: ${{ secrets.SMOKESHOW_AUTH_KEY }}

.github/workflows/test.yml

Lines changed: 102 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,122 @@
11
name: Test
22

3+
permissions:
4+
contents: read
5+
36
on:
47
push:
58
branches:
69
- main
710
pull_request:
811
types: [opened, synchronize, reopened]
912

13+
14+
env:
15+
UV_VERSION: 0.7.5
16+
1017
jobs:
11-
tox:
18+
lint:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
linter:
23+
- mypy
24+
- ruff
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: Install uv
28+
uses: astral-sh/setup-uv@v6
29+
with:
30+
version: "${{ env.UV_VERSION }}"
31+
enable-cache: true
32+
- name: Set up Python 3.12
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: '3.12'
36+
- name: Install the project
37+
run: uv sync --locked --all-extras --all-groups
38+
- name: Run ruff lint check
39+
if: matrix.linter == 'ruff'
40+
run: uv run ruff check openapi_pydantic tests
41+
- name: Run ruff format check
42+
if: matrix.linter == 'ruff'
43+
run: uv run ruff format --check openapi_pydantic tests
44+
- name: Run Mypy Check
45+
if: matrix.linter == 'mypy'
46+
run: uv run mypy openapi_pydantic tests
47+
48+
test:
1249
runs-on: ubuntu-latest
50+
permissions:
51+
contents: write
1352
strategy:
1453
matrix:
15-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
54+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
55+
pydantic-version: ['pydantic-v1', 'pydantic-v2']
56+
fail-fast: false
1657
steps:
1758
- uses: actions/checkout@v4
59+
- name: Install uv
60+
uses: astral-sh/setup-uv@v5
61+
with:
62+
version: "${{ env.UV_VERSION }}"
63+
enable-cache: true
1864
- name: Set up Python ${{ matrix.python-version }}
1965
uses: actions/setup-python@v5
2066
with:
2167
python-version: ${{ matrix.python-version }}
22-
- name: Install dependencies
23-
run: |
24-
python -m pip install --upgrade pip
25-
python -m pip install tox tox-gh-actions
26-
- name: Install Poetry
27-
uses: snok/install-poetry@v1
68+
- name: Install the project
69+
run: uv sync --locked --all-extras --group test
70+
- name: Install Pydantic v1
71+
if: matrix.pydantic-version == 'pydantic-v1'
72+
run: uv add "pydantic>=1.10.0,<2.0.0" --upgrade-package pydantic
73+
- name: Install Pydantic v2
74+
if: matrix.pydantic-version == 'pydantic-v2'
75+
run: uv add "pydantic>=2.0.2,<3.0.0" --upgrade-package pydantic
76+
- run: mkdir coverage
77+
- name: Test
78+
run: uv run coverage run -m pytest -vv tests
79+
env:
80+
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
81+
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
82+
- name: Store coverage files
83+
uses: actions/upload-artifact@v4
2884
with:
29-
version: 1.8.3
30-
virtualenvs-create: true
31-
virtualenvs-in-project: true
32-
- name: Run tox test suite
33-
run: tox
85+
name: coverage-${{ matrix.python-version }}-${{ matrix.pydantic-version }}
86+
path: coverage
87+
include-hidden-files: true
88+
89+
90+
coverage:
91+
needs: [test]
92+
runs-on: ubuntu-latest
93+
permissions:
94+
contents: write
95+
steps:
96+
- uses: actions/checkout@v4
97+
- uses: actions/setup-python@v5
98+
with:
99+
python-version: '3.12'
100+
- name: Install uv
101+
uses: astral-sh/setup-uv@v5
102+
with:
103+
version: "${{ env.UV_VERSION }}"
104+
enable-cache: true
105+
- name: Install Dependencies
106+
run: uv sync --locked --all-extras --group test
107+
- name: Get coverage files
108+
uses: actions/download-artifact@v4
109+
with:
110+
pattern: coverage-*
111+
path: coverage
112+
merge-multiple: true
113+
- run: ls -la coverage
114+
- run: uv run coverage combine coverage
115+
- run: uv run coverage report
116+
- run: uv run coverage html --title "Coverage for ${{ github.sha }}"
117+
- name: Store coverage HTML
118+
uses: actions/upload-artifact@v4
119+
with:
120+
name: coverage-html
121+
path: htmlcov
122+
include-hidden-files: true

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ __pycache__
33
/.mypy_cache
44
/.pytest_cache
55
/.ruff_cache
6-
/.tox
6+
/.uv_cache
7+
/.cache
78
/.venv
89
/*.egg-info
910
/build

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111
"source.fixAll": "explicit",
1212
"source.organizeImports": "explicit"
1313
},
14-
"editor.defaultFormatter": "charliermarsh.ruff"
14+
"editor.defaultFormatter": "charliermarsh.ruff",
15+
"[toml]": {
16+
"editor.defaultFormatter": "tamasfe.even-better-toml"
17+
}
1518
}

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ time by ensuring that your changes will be accepted with fewer revisions down th
1616

1717
### Local Development
1818

19-
A [devcontainer](https://code.visualstudio.com/docs/devcontainers/containers) configuration is provided in the repo to get your environment setup automatically. Alternatively you can install [tox](https://tox.wiki/en/latest/) and [poetry](https://python-poetry.org/) manually.
19+
A [devcontainer](https://code.visualstudio.com/docs/devcontainers/containers) configuration is provided in the repo to get your environment setup automatically.
20+
21+
If devcontainers aren't your speed, you can manually setup your environment by installing `uv` and
22+
then running `uv sync --all-groups`.
2023

2124
### Testing
2225

23-
Please ensure all changes have good test coverage and are formatted correctly. You can run the test
24-
suite and linters using [tox](https://tox.wiki/en/latest/) - just run `tox` from the root of this
25-
repo to run the checks. These will also be run automatically in CI once your PR is opened. Don't
26-
worry about testing against every Python version - the CI action will do this for you!
26+
Please ensure all changes have good test coverage. We use [pytest](https://docs.pytest.org/en/latest/) for testing, and [coverage](https://coverage.readthedocs.io/en/latest/) for measuring code coverage.
2727

2828
### Tagging
2929

openapi_pydantic/v3/v3_0/encoding.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"contentType": "image/png, image/jpeg",
1515
"headers": {
1616
"X-Rate-Limit-Limit": {
17-
"description": "The number of allowed requests in the "
18-
"current period",
17+
"description": "The number of allowed requests in the current period",
1918
"schema": {"type": "integer"},
2019
}
2120
},

openapi_pydantic/v3/v3_1/encoding.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"contentType": "image/png, image/jpeg",
1515
"headers": {
1616
"X-Rate-Limit-Limit": {
17-
"description": "The number of allowed requests in the "
18-
"current period",
17+
"description": "The number of allowed requests in the current period",
1918
"schema": {"type": "integer"},
2019
}
2120
},

openapi_pydantic/v3/v3_1/response.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@
3030
"content": {"text/plain": {"schema": {"type": "string", "example": "whoa!"}}},
3131
"headers": {
3232
"X-Rate-Limit-Limit": {
33-
"description": "The number of allowed requests in the "
34-
"current period",
33+
"description": "The number of allowed requests in the current period",
3534
"schema": {"type": "integer"},
3635
},
3736
"X-Rate-Limit-Remaining": {
38-
"description": "The number of remaining requests in the "
39-
"current period",
37+
"description": "The number of remaining requests in the current period",
4038
"schema": {"type": "integer"},
4139
},
4240
"X-Rate-Limit-Reset": {

0 commit comments

Comments
 (0)