Skip to content

Commit ee9dffc

Browse files
committed
♻️ refactor: move to uv
1 parent d340263 commit ee9dffc

30 files changed

+490
-379
lines changed

.github/workflows/black-fmt.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/workflows/lint-and-fmt.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Lint and Format
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
merge_group:
8+
workflow_dispatch:
9+
10+
jobs:
11+
lint-and-fmt:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
# Only run linter and formatter on minimum supported Python version
16+
python-version: ['3.9']
17+
architecture: ['x64']
18+
name: lint and fmt - Python ${{ matrix.python-version }} on ${{ matrix.architecture }}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Install prettier
24+
run: |
25+
npm install -g prettier
26+
27+
- name: Install uv
28+
uses: astral-sh/setup-uv@v2
29+
30+
- name: Install python
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
architecture: ${{ matrix.architecture }}
35+
36+
- name: Install just
37+
uses: extractions/setup-just@v2
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Install dependencies
42+
run: |
43+
just ci-install
44+
45+
- name: lint
46+
run: |
47+
just ci-lint
48+
49+
- name: format check
50+
run: |
51+
just ci-fmt-check

.github/workflows/release.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ['v*']
6+
workflow_dispatch:
7+
8+
jobs:
9+
release-build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v2
18+
19+
- name: Install python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.x'
23+
24+
- name: Install just
25+
uses: extractions/setup-just@v2
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: build release distributions
30+
run: |
31+
just ci-install
32+
just build
33+
34+
- name: upload dists
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: release-dists
38+
path: dist/
39+
40+
publish-pypi:
41+
runs-on: ubuntu-latest
42+
name: Publish to PyPI
43+
if: "startsWith(github.ref, 'refs/tags/')"
44+
needs:
45+
- release-build
46+
permissions:
47+
id-token: write
48+
49+
steps:
50+
- name: Retrieve release distributions
51+
uses: actions/download-artifact@v4
52+
with:
53+
name: release-dists
54+
path: dist/
55+
56+
- name: Publish release distributions to PyPI
57+
uses: pypa/gh-action-pypi-publish@release/v1
58+
59+
publish-release:
60+
runs-on: ubuntu-latest
61+
name: Publish to GitHub
62+
if: "startsWith(github.ref, 'refs/tags/')"
63+
needs:
64+
- release-build
65+
permissions:
66+
contents: write
67+
steps:
68+
- uses: actions/download-artifact@v4
69+
with:
70+
name: release-dists
71+
path: dist/
72+
- name: Get tag name
73+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
74+
- name: Publish to GitHub
75+
uses: softprops/action-gh-release@v2
76+
with:
77+
draft: true
78+
files: dist/*
79+
tag_name: ${{ env.RELEASE_VERSION }}

.github/workflows/unit-test.yml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,42 @@
11
name: Unit Test
22

3-
on: [push, pull_request, workflow_dispatch]
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
merge_group:
8+
workflow_dispatch:
49

510
jobs:
611
unit-test:
712
runs-on: ubuntu-latest
813
strategy:
914
matrix:
10-
python-version: ["3.9", "3.10"]
11-
architecture: ["x64"]
12-
name: Python ${{ matrix.python-version }} on ${{ matrix.architecture }} test
15+
python-version: ['3.9', '3.10', '3.11', '3.12']
16+
architecture: ['x64']
17+
name: unittest - Python ${{ matrix.python-version }} on ${{ matrix.architecture }}
1318
steps:
1419
- name: Checkout
15-
uses: actions/checkout@v3
20+
uses: actions/checkout@v4
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v2
1624

1725
- name: Install python
18-
uses: actions/setup-python@v4
26+
uses: actions/setup-python@v5
1927
with:
2028
python-version: ${{ matrix.python-version }}
2129
architecture: ${{ matrix.architecture }}
2230

23-
- name: Install poetry
24-
uses: snok/install-poetry@v1
25-
26-
- uses: actions/cache@v3
27-
id: poetry-cache
28-
with:
29-
path: |
30-
**/.venv
31-
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.architecture }}-poetry-${{ hashFiles('poetry.lock') }}
31+
- name: Install just
32+
uses: extractions/setup-just@v2
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3235

3336
- name: Install dependencies
34-
if: steps.poetry-cache.outputs.cache-hit != 'true'
3537
run: |
36-
poetry install
38+
just ci-install
3739
3840
- name: unit test
3941
run: |
40-
poetry run pytest --workers auto
42+
just ci-test

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ dmypy.json
131131
# test files
132132
*.test.py
133133

134-
# stub files
135-
py.typed
136-
137134
# logs
138135
log
139136

.vscode/extensions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"recommendations": [
33
"ms-python.python",
44
"ms-python.vscode-pylance",
5+
"charliermarsh.ruff",
56
"esbenp.prettier-vscode",
67
"EditorConfig.EditorConfig",
78
"aaron-bond.better-comments",

.vscode/settings.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
{
22
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
3-
"python.formatting.provider": "black",
4-
"python.formatting.blackArgs": ["--line-length", "120"],
53
"python.analysis.typeCheckingMode": "strict",
64
"python.analysis.inlayHints.functionReturnTypes": true,
75
"python.analysis.inlayHints.variableTypes": true,
8-
9-
"[rst][markdown]": {
10-
"editor.formatOnSave": false
6+
"[python]": {
7+
"editor.defaultFormatter": "charliermarsh.ruff"
118
}
129
}

docufix/_compat.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

docufix/utils/__init__.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

justfile

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
1-
VERSION := `poetry run python -c "import sys; from docufix import __version__ as version; sys.stdout.write(version)"`
1+
VERSION := `uv run python -c "import sys; from docufix import __version__ as version; sys.stdout.write(version)"`
2+
3+
install:
4+
uv sync --all-extras --dev
25

36
test:
4-
poetry run pytest --reruns 3 --reruns-delay 1
7+
uv run pytest
58
just clean
69

710
fmt:
8-
poetry run isort .
9-
poetry run black .
11+
uv run ruff format .
12+
13+
lint:
14+
uv run pyright src/docufix tests
15+
uv run ruff check .
1016

1117
fmt-docs:
12-
poetry run docufix '**/*.md' --fix
13-
poetry run docufix '**/*.rst' --fix
18+
prettier --write '**/*.md'
1419

1520
build:
16-
poetry build
21+
uv build
1722

18-
publish:
19-
touch docufix/py.typed
20-
poetry publish --build
23+
release:
24+
@echo 'Tagging v{{VERSION}}...'
2125
git tag "v{{VERSION}}"
26+
@echo 'Push to GitHub to trigger publish process...'
2227
git push --tags
23-
just clean-builds
28+
29+
# Missing command for uv
30+
# publish:
31+
# poetry publish --build
32+
# git tag "v{{VERSION}}"
33+
# git push --tags
34+
# just clean-builds
2435

2536
clean:
2637
find . -name "*.pyc" -print0 | xargs -0 rm -f
@@ -32,3 +43,17 @@ clean-builds:
3243
rm -rf build/
3344
rm -rf dist/
3445
rm -rf *.egg-info/
46+
47+
ci-install:
48+
just install
49+
50+
ci-fmt-check:
51+
uv run ruff format --check --diff .
52+
prettier --check '**/*.md'
53+
54+
ci-lint:
55+
just lint
56+
57+
ci-test:
58+
uv run pytest --reruns 3 --reruns-delay 1
59+
just clean

0 commit comments

Comments
 (0)