Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move project to uv backend #7

Merged
merged 5 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 17 additions & 33 deletions .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,43 @@ on:
release:
types: [published]


env:
PYTHON_VERSION: "3.12"
POETRY_VERSION: "1.8.3"
POETRY_URL: https://install.python-poetry.org

jobs:
build:
name: 📦 Build
runs-on: ubuntu-latest
env:
UV_PYTHON: "3.12.6"

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

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
python-version: "3.12"
id: setup_python
version: "0.4.15"
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Cache Poetry cache
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: poetry-cache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.POETRY_VERSION }}
- name: Set up Python ${{ env.UV_PYTHON }}
run: uv python install ${{ env.UV_PYTHON }}

- name: Cache Packages
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-local-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('.github/workflows/*.yml') }}
- name: Install the project
run: uv sync --extra dev --extra tests

- name: Install Poetry
run: |
curl -sSL ${{ env.POETRY_URL }} | python3 - --version ${{ env.POETRY_VERSION }}
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Install dependencies
run: |
poetry lock --no-update
poetry install --only main
- name: Minimize uv cache
run: uv cache prune --ci

- name: Build dist
run: poetry build
run: uv build

- name: Verify wheel installation
run: |
mkdir -p verify
cd verify
python3 -m venv venv
venv/bin/pip install ../dist/*.whl
venv/bin/python -c "import ftl_extract; print(ftl_extract.__version__)"
uv venv ${{ env.UV_PYTHON }}
uv pip install ../dist/*.whl
uv run python -c "import ftl_extract; print(ftl_extract.__version__)"

- name: Store the distribution packages
uses: actions/upload-artifact@v4
Expand Down
42 changes: 12 additions & 30 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@ on:
pull_request:
branches: [ "master", "dev" ]

env:
PYTHON_VERSION: "3.12"
POETRY_VERSION: "1.8.3"
POETRY_URL: https://install.python-poetry.org

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -24,33 +18,21 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
python-version: ${{ matrix.python-version }}
id: setup_python
version: "0.4.15"
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Cache Poetry cache
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: poetry-cache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.POETRY_VERSION }}
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Cache Packages
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-local-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('.github/workflows/*.yml') }}

- name: Install Poetry
run: |
curl -sSL ${{ env.POETRY_URL }} | python3 - --version ${{ env.POETRY_VERSION }}
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Install dependencies
run: |
poetry lock --no-update
poetry install --with dev,test
- name: Install the project
run: uv sync --extra dev --extra tests

- name: Minimize uv cache
run: uv cache prune --ci

- name: Lint
run: make lint
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repos:
- id: "check-json"

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.6.1
rev: v0.6.7
hooks:
- id: ruff
args: [ "--fix" ]
Expand Down
56 changes: 30 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,45 @@ else
mkdir_cmd := $(shell mkdir -p $(reports_dir))
endif

.PHONY lint:
lint:
@echo "Running ruff..."
@poetry run ruff check --config pyproject.toml --diff $(code_dir) $(tests_dir)
echo "Running ruff..."
uv run ruff check --config pyproject.toml --diff $(code_dir) $(tests_dir)

@echo "Running MyPy..."
@poetry run mypy --config-file pyproject.toml $(code_dir)
echo "Running MyPy..."
uv run mypy --config-file pyproject.toml $(code_dir)

.PHONY format:
format:
@echo "Running ruff check with --fix..."
@poetry run ruff check --config pyproject.toml --fix --unsafe-fixes $(code_dir) $(tests_dir)
echo "Running ruff check with --fix..."
uv run ruff check --config pyproject.toml --fix --unsafe-fixes $(code_dir) $(tests_dir)

@echo "Running ruff..."
@poetry run ruff format --config pyproject.toml $(code_dir) $(tests_dir)
echo "Running ruff..."
uv run ruff format --config pyproject.toml $(code_dir) $(tests_dir)

@echo "Running isort..."
@poetry run isort --settings-file pyproject.toml $(code_dir) $(tests_dir)
echo "Running isort..."
uv run isort --settings-file pyproject.toml $(code_dir) $(tests_dir)

.PHONY livehtml:
livehtml:
@sphinx-autobuild "$(docs_source_dir)" "$(docs_dir)/_build/html" $(SPHINXOPTS) $(O)
uv run sphinx-autobuild "$(docs_source_dir)" "$(docs_dir)/_build/html" $(SPHINXOPTS) $(O)

.PHONY test:
test:
@echo "Running tests..."
@poetry run pytest -vv --cov=$(code_dir) --cov-report=html --cov-report=term --cov-config=.coveragerc $(tests_dir)
echo "Running tests..."
uv run pytest -vv --cov=$(code_dir) --cov-report=html --cov-report=term --cov-config=.coveragerc $(tests_dir)

.PHONY test-coverage:
test-coverage:
@echo "Running tests with coverage..."
@$(mkdir_cmd)
@poetry run pytest -vv --cov=$(code_dir) --cov-config=.coveragerc --html=$(reports_dir)/tests/index.html tests/
@poetry run coverage html -d $(reports_dir)/coverage


.PHONY poetry-show:
poetry-show:
@poetry show --top-level --latest

.PHONY poetry-show-outdated:
poetry-show-outdated:
@poetry show --top-level --outdated
echo "Running tests with coverage..."
$(mkdir_cmd)
uv run pytest -vv --cov=$(code_dir) --cov-config=.coveragerc --html=$(reports_dir)/tests/index.html tests/
uv run coverage html -d $(reports_dir)/coverage

.PHONY show-outdated:
show-outdated:
echo "Waiting for uv to create this feature..."

.PHONY uv-sync:
uv-sync:
uv sync --extra dev --extra tests --extra docs
Loading