Skip to content

Commit

Permalink
Switch to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
Parnassius committed Jan 11, 2025
1 parent c3793a6 commit 1cc24a9
Show file tree
Hide file tree
Showing 11 changed files with 785 additions and 652 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ insert_final_newline = true

[*.yml]
indent_size = 2

[Makefile]
indent_style = tab
65 changes: 27 additions & 38 deletions .github/workflows/main.yml → .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: main
name: ci/cd

on: [push, pull_request]

Expand All @@ -7,22 +7,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Hatch
run: pipx install hatch
- name: Set up python 3.9
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: "pip"
cache-dependency-path: "pyproject.toml"
- name: Check formatting
run: hatch run ruff-format --check
- name: Check docstrings with darglint
run: hatch run darglint
- name: Type check with mypy
run: hatch run mypy
- name: Lint with ruff
run: hatch run ruff
- name: Lint
run: make lint

test:
runs-on: ${{ matrix.os }}-latest
Expand All @@ -40,19 +34,19 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Install Hatch
run: pipx install hatch
- name: Set up python ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
cache: "pip"
cache-dependency-path: "pyproject.toml"
- name: Test with pytest
- name: Test
env:
COVERAGE_FILE: .coverage.${{ matrix.os }}.${{ matrix.python-version }}
run: hatch run pytest-ci ${{ matrix.python-version }}
run: make pytest
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
Expand All @@ -66,7 +60,6 @@ jobs:
outputs:
percentage: ${{ steps.percentage.outputs.percentage }}
steps:
- uses: actions/checkout@v4
- name: Install Coverage.py
run: pipx install coverage[toml]
- name: Download coverage data
Expand Down Expand Up @@ -131,10 +124,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Hatch
run: pipx install hatch
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Build project
run: hatch build
run: uv build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -169,22 +164,16 @@ jobs:
working-directory: spec_parser
steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install poetry
- name: Set up python 3.9
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: "poetry"
cache-dependency-path: "spec_parser/poetry.lock"
- name: Install dependencies
run: poetry install --sync
- name: Check formatting
run: poetry run poe ruff-format --check
- name: Type check with mypy
run: poetry run poe mypy
- name: Lint with ruff
run: poetry run poe ruff
- name: Lint
run: make lint

dummy-required-job:
runs-on: ubuntu-latest
Expand Down
12 changes: 8 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
__pycache__/
/.coverage
/.venv
/dist
__pycache__
*.py[oc]
build
dist
wheels
*.egg-info
.venv
.coverage
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.PHONY: format
format:
@uv run ruff check src tests --fix-only
@uv run ruff format src tests

.PHONY: format-check
format-check:
@uv run ruff format src tests --check

.PHONY: darglint
darglint:
@uv run darglint src tests -v 2

.PHONY: mypy
mypy:
@uv run mypy src tests

.PHONY: ruff
ruff:
@uv run ruff check src tests

.PHONY: pytest
pytest:
@uv run pytest --cov

.PHONY: lint
lint: format-check darglint mypy ruff

.PHONY: all
all: format darglint mypy ruff pytest

.DEFAULT_GOAL := all
87 changes: 16 additions & 71 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"


[project]
name = "domify"
description = "HTML generator using pure Python"
Expand Down Expand Up @@ -31,78 +26,21 @@ classifiers = [
]
dynamic = ["version"]

[project.optional-dependencies]
lint = [
"domify[test]",
[project.urls]
Homepage = "https://github.com/Parnassius/domify"

[dependency-groups]
dev = [
"darglint==1.8.1",
"mypy==1.14.1",
"ruff==0.8.4",
]
test = [
"pytest==8.3.4",
"pytest-cov==6.0.0",
"ruff==0.8.4",
]


[project.urls]
Homepage = "https://github.com/Parnassius/domify"


[tool.hatch.build]
packages = ["src/domify"]

[tool.hatch.envs.default.scripts]
ruff-fix = "hatch run lint:ruff check src tests --fix-only {args}"
ruff-format = "hatch run lint:ruff format src tests {args}"
format = ["ruff-fix", "ruff-format"]

darglint = "hatch run lint:darglint src tests -v 2 {args}"
mypy = "hatch run lint:mypy src tests {args}"
ruff = "hatch run lint:ruff check src tests {args}"
pytest = "hatch run test:pytest {args}"
pytest-ci = "hatch run +py={args} test:pytest --cov"
all = ["format", "darglint", "mypy", "ruff", "pytest"]

_check_uncommited_changes = [
"git diff --quiet",
"git diff --cached --quiet",
]
_check_not_dev_version = 'case "$(hatch version)" in *dev*) false; esac'
_create_tag = 'git tag "$(hatch version)"'
_create_dev_commit = [
"hatch version patch,dev",
'git commit src/domify/__about__.py --message "Bump version to $(hatch version)"',
]
release = [
"_check_uncommited_changes",
"_check_not_dev_version",
"all",
"_check_uncommited_changes",
"_create_tag",
"_create_dev_commit",
]

[tool.hatch.envs.lint]
template = "lint"
features = ["lint"]

[tool.hatch.envs.test]
template = "test"
features = ["test"]

[[tool.hatch.envs.test.matrix]]
python = [
"3.9",
"3.10",
"3.11",
"3.12",
"3.13",
"pypy3.9",
"pypy3.10",
]

[tool.hatch.version]
path = "src/domify/__about__.py"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"


[tool.coverage.report]
Expand All @@ -118,6 +56,13 @@ source = ["src/domify"]
omit = ["src/domify/__about__.py"]


[tool.hatch.build]
packages = ["src/domify"]

[tool.hatch.version]
path = "src/domify/__about__.py"


[tool.mypy]
python_version = "3.9"
strict = true
Expand Down
1 change: 0 additions & 1 deletion spec_parser/.gitignore

This file was deleted.

24 changes: 24 additions & 0 deletions spec_parser/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.PHONY: format
format:
@uv run ruff check src --fix-only
@uv run ruff format src

.PHONY: format-check
format-check:
@uv run ruff format src --check

.PHONY: mypy
mypy:
@uv run mypy src

.PHONY: ruff
ruff:
@uv run ruff check src

.PHONY: lint
lint: format-check mypy ruff

.PHONY: all
all: format mypy ruff

.DEFAULT_GOAL := all
Loading

0 comments on commit 1cc24a9

Please sign in to comment.