Skip to content

Commit

Permalink
♻️ refactor: move to uv (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
SigureMo authored Oct 12, 2024
1 parent d9cce2a commit c13c8e0
Show file tree
Hide file tree
Showing 14 changed files with 452 additions and 408 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/lint-and-fmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ jobs:
run: |
npm install -g prettier
- name: Install poetry
run: pipx install poetry
- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Install python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
cache: "poetry"

- name: Install just
uses: extractions/setup-just@v2
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Release

on:
push:
tags: ['v*']
workflow_dispatch:

jobs:
release-build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Install python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install just
uses: extractions/setup-just@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: build release distributions
run: |
just ci-install
just build
- name: upload dists
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/

publish-pypi:
runs-on: ubuntu-latest
name: Publish to PyPI
if: "startsWith(github.ref, 'refs/tags/')"
needs:
- release-build
permissions:
id-token: write

steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/

- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

publish-release:
runs-on: ubuntu-latest
name: Publish to GitHub
if: "startsWith(github.ref, 'refs/tags/')"
needs:
- release-build
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/
- name: Get tag name
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Publish to GitHub
uses: softprops/action-gh-release@v2
with:
draft: true
files: dist/*
tag_name: ${{ env.RELEASE_VERSION }}
5 changes: 2 additions & 3 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry
- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Install python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
cache: "poetry"

- name: Install just
uses: extractions/setup-just@v2
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ dmypy.json
# test files
*.test.py

# stub files
py.typed

# logs
log

Expand Down
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"recommendations": [
"ms-python.python",
"ms-python.vscode-pylance",
"charliermarsh.ruff",
"esbenp.prettier-vscode",
"EditorConfig.EditorConfig",
"aaron-bond.better-comments",
Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
"python.analysis.typeCheckingMode": "strict",
"python.analysis.inlayHints.functionReturnTypes": true,
"python.analysis.inlayHints.variableTypes": true,
"[python]": {
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
Some pre-commit hooks for docs.

<p align="center">
<a href="LICENSE"><img alt="LICENSE" src="https://img.shields.io/github/license/ShigureLab/dochooks?style=flat-square"></a>
<a href="https://python.org/" target="_blank"><img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/dochooks?logo=python&style=flat-square"></a>
<a href="https://pypi.org/project/dochooks/" target="_blank"><img src="https://img.shields.io/pypi/v/dochooks?style=flat-square" alt="pypi"></a>
<a href="https://pypi.org/project/dochooks/" target="_blank"><img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/dochooks?style=flat-square"></a>
<a href="LICENSE"><img alt="LICENSE" src="https://img.shields.io/github/license/PFCCLab/dochooks?style=flat-square"></a>
<br/>
<a href="https://github.com/astral-sh/uv"><img alt="uv" src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json&style=flat-square"></a>
<a href="https://github.com/astral-sh/ruff"><img alt="ruff" src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&style=flat-square"></a>
<a href="https://gitmoji.dev"><img src="https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67?style=flat-square" alt="Gitmoji"></a>
<a href="https://gitmoji.dev"><img alt="Gitmoji" src="https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67?style=flat-square"></a>
</p>

## Usage
Expand All @@ -14,7 +19,7 @@ Some pre-commit hooks for docs.

```yaml
repos:
- repo: https://github.com/ShigureLab/dochooks
- repo: https://github.com/PFCCLab/dochooks
rev: v0.3.0
hooks:
- id: check-whitespace-between-cn-and-en-char
Expand Down
Empty file added dochooks/py.typed
Empty file.
27 changes: 13 additions & 14 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
VERSION := `poetry run python -c "import sys; from dochooks import __version__ as version; sys.stdout.write(version)"`
VERSION := `uv run python -c "import sys; from dochooks import __version__ as version; sys.stdout.write(version)"`

install:
poetry install -E rst-parser
uv sync --all-extras --dev

test:
poetry run pytest
uv run pytest
just clean

fmt:
poetry run ruff format .
uv run ruff format .

lint:
poetry run pyright dochooks tests
poetry run ruff check .
uv run pyright dochooks tests
uv run ruff check .

fmt-docs:
prettier --write '**/*.md'

build:
poetry build
uv build

publish:
touch dochooks/py.typed
poetry publish --build
git tag "v{{VERSION}}"
uv build
uv publish
git push --tags
just clean-builds

Expand All @@ -39,18 +38,18 @@ clean-builds:
rm -rf *.egg-info/

hooks-update:
poetry run pre-commit autoupdate
uv run pre-commit autoupdate

ci-install:
poetry install --no-interaction --no-root -E rst-parser
just install

ci-fmt-check:
poetry run ruff format --check --diff .
uv run ruff format --check --diff .
prettier --check '**/*.md'

ci-lint:
just lint

ci-test:
poetry run pytest --reruns 3 --reruns-delay 1
uv run pytest --reruns 3 --reruns-delay 1
just clean
Loading

0 comments on commit c13c8e0

Please sign in to comment.