Skip to content

Commit

Permalink
feat!(uv): replace rye with uv
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSasser committed Dec 19, 2024
1 parent f25ae2d commit a38e1ad
Show file tree
Hide file tree
Showing 13 changed files with 1,769 additions and 224 deletions.
38 changes: 15 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,33 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- name: Checkout code
uses: actions/checkout@v4.2.2

- name: "Set Python Version ${{ matrix.python-version }}"
run: echo '${{ matrix.python-version }}' > .python-version
# - name: "Set Python Version ${{ matrix.python-version }}"
# run: echo '${{ matrix.python-version }}' > .python-version

- name: Setup Rye
id: setup-rye
uses: eifinger/setup-rye@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "0.41.0"
enable-cache: true
cache-prefix: python-${{ matrix.python-version }}
github-token: ${{ secrets.GITHUB_TOKEN }}
cache-dependency-glob: "uv.lock"

- name: Install Project Dependencies
run: |
rye pin --no-update-requires-python '${{ matrix.python-version }}'
rye sync --all-features
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install the project
run: uv sync --all-extras --dev

- name: Run pre-commit
run: |
. .venv/bin/activate
pre-commit run --all-files
run: uv run pre-commit run --all-files

- name: Sphinx Build
- name: Build docs
working-directory: ./docs
run: |
. ../.venv/bin/activate
make html
run: make html

- name: Test with pytest
run: |
. .venv/bin/activate
rye test
run: uv run pytest tests
23 changes: 9 additions & 14 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,21 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4.2.2

- name: "Set Python Version ${{ matrix.python-version }}"
run: echo '${{ matrix.python-version }}' > .python-version

- name: Setup Rye
id: setup-rye
uses: eifinger/setup-rye@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
version: "0.41.0"
cache-dependency-glob: "uv.lock"

- name: Set up Python ${{ matrix.python-version }}
run: uv python install 3.13

- name: Install Project Dependencies
run: |
rye pin --no-update-requires-python '3.12'
rye sync --all-features
- name: Install the project
run: uv sync --all-extras --dev

- name: Make docs
working-directory: ${{env.working-directory}}
run: |
source ../.venv/bin/activate
make html
run: make html

- name: Deploy
uses: peaceiris/actions-gh-pages@v4.0.0
Expand Down
44 changes: 17 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,29 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4.2.2

- name: "Set Python Version ${{ matrix.python-version }}"
run: echo '${{ matrix.python-version }}' > .python-version

- name: Setup Rye
id: setup-rye
uses: eifinger/setup-rye@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "0.41.0"
enable-cache: true
github-token: ${{ secrets.GITHUB_TOKEN }}
cache-dependency-glob: "uv.lock"

- name: Set up Python ${{ matrix.python-version }}
run: uv python install 3.13

- name: Install Project Dependencies
run: |
rye pin --no-update-requires-python '3.12'
rye sync --all-features
- name: Install the project
run: uv sync --all-extras --dev

- name: Build project
run: rye build --all --clean
run: uv build

- name: Generate Changelog
run: uv run git cliff > CHANGELOG.md

- name: Zip project
run: zip --junk-paths matrixctl.zip dist/* README.md LICENSE.txt
run: zip --junk-paths matrixctl.zip dist/* README.md LICENSE.txt CHANGELOG.md

- name: Generate changelog_latest.md
run: git cliff --latest > changelog_latest.md
run: uv run git cliff --latest > changelog_latest.md

- name: Get the version
id: get_version
Expand All @@ -70,15 +69,6 @@ jobs:
run: rm -rf matrixctl.zip changelog_latest.md

- name: Publish
run: rye publish --token <your_token> --yes --skip-existing
# - name: pypi-publish
# uses: pypa/gh-action-pypi-publish@v1.10.2
# with:
# # PyPI user
# # user: # optional, default is __token__
# # Password for your PyPI user or an access token
# password: ${{ secrets.pypi_token }}
# # The repository URL to use
# # repository_url: # optional
# # The target directory for distribution
# # packages_dir: # optional, default is dist
env:
UV_PUBLISH_TOKEN: ${{ secrets.pypi_token }}
run: uv publish
22 changes: 18 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ minimum_pre_commit_version: 2.13.0

exclude: ^requirements.*\.lock$
repos:
- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.5.10
hooks:
# Update the uv lockfile
- id: uv-lock

- repo: meta
hooks:
- id: check-hooks-apply
Expand Down Expand Up @@ -75,15 +82,15 @@ repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.9
rev: v0.8.3
hooks:
- id: ruff # Linter
args: [--fix]
- id: ruff-format # Formatter

# static type checking with mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
rev: v1.13.0
hooks:
- id: mypy
additional_dependencies:
Expand All @@ -99,11 +106,11 @@ repos:
hooks:
- id: interrogate
args: [tests]
language_version: python3.10
# language_version: python3.10

# vulture
- repo: https://github.com/jendrikseipp/vulture
rev: "v2.13"
rev: "v2.14"
hooks:
- id: vulture

Expand All @@ -113,3 +120,10 @@ repos:
hooks:
- id: pycln
args: [--config=pyproject.toml]

# # basedpyright
# - repo: https://github.com/DetachHead/basedpyright-pre-commit-mirror
# rev: 1.23.0
# hooks:
# - id: basedpyright
# args: [--venvpath=.venv]
89 changes: 89 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
.PHONY: all

all: help


##@
##@ Build Commands
##@

update: ##@ Update the dependencies to the ones defined
##@ in the pyproject.toml [alias: u]
uv sync --all-extras --upgrade

u: update

build: ##@ Build the application [alias: b]
uv build

b: build

run: ##@ Build and run the application [alias: r]
uv run matrixctl

r: run

##@
##@ Check Commands
##@


check: fmt lint test ##@ Format, lint, run tests
##@ [alias: c]

c: check

test: ##@ Run tests [alias: t]
uv run coverage run -m pytest --doctest-modules

t: test

fmt: ##@ Format the project
ruff format

lint: lint-toml lint-python lint-type ##@ Lint the the source code (Rust, TOML)

lint-toml: ##@ Lint all TOML files
taplo lint --colors always

lint-python: ##@ Run ruff
uv run ruff check

lint-type: ##@ Run basedpyright
uv run basedpyright

tox: ##@ Run tox
uv tool run tox

##@
##@ Documentation Related Commands
##@

doc: ##@ Build the documentation [alias: d]
cargo doc --color always --bins --no-deps --frozen --examples --open --verbose --release

d: docs

changelog-unreleased: ##@ Preview the unreleased changes
git cliff --unreleased

##@
##@ Misc commands
##@

lines: ##@ Show lines of code
tokei

help: ##@ This help message
@printf "\nUsage: make <command>\n"
@grep -F -h "##@" $(MAKEFILE_LIST) | grep -F -v grep -F | sed -e 's/\\$$//' | awk 'BEGIN {FS = ":*[[:space:]]*##@[[:space:]]*"}; \
{ \
if($$2 == "") \
pass; \
else if($$0 ~ /^#/) \
printf "\n\n\033[1m%s\033[0m\n", $$2; \
else if($$1 == "") \
printf " %-25s%s\n", "", $$2; \
else \
printf "\n \033[34m%-25s\033[0m %s\n", $$1, $$2; \
}'
Loading

0 comments on commit a38e1ad

Please sign in to comment.