-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
191 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: "Setup Python Environment" | ||
description: "Set up Python environment for the given Python version" | ||
|
||
inputs: | ||
python-version: | ||
description: "Python version to use" | ||
required: true | ||
default: "3.12" | ||
uv-version: | ||
description: "uv version to use" | ||
required: true | ||
default: "0.5.2" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
|
||
- name: Install uv | ||
uses: astral-sh/setup-uv@v2 | ||
with: | ||
version: ${{ inputs.uv-version }} | ||
enable-cache: 'true' | ||
cache-suffix: ${{ matrix.python-version }} | ||
|
||
- name: Install Python dependencies | ||
run: uv sync --frozen | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Main | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: [opened, synchronize, reopened, ready_for_review] | ||
|
||
jobs: | ||
quality: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out | ||
uses: actions/checkout@v4 | ||
|
||
- uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/pre-commit | ||
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} | ||
|
||
- name: Set up the environment | ||
uses: ./.github/actions/setup-python-env | ||
|
||
- name: Run checks | ||
run: make check | ||
|
||
tests-and-type-check: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10", "3.11", "3.12", "3.13"] | ||
fail-fast: false | ||
defaults: | ||
run: | ||
shell: bash | ||
steps: | ||
- name: Check out | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up the environment | ||
uses: ./.github/actions/setup-python-env | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Run tests | ||
run: uv run python -m pytest tests | ||
|
||
- name: Check typing | ||
run: uv run mypy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
.PHONY: install | ||
install: ## Install the virtual environment and install the pre-commit hooks | ||
@echo "🚀 Creating virtual environment using uv" | ||
@uv sync | ||
@uv run pre-commit install | ||
|
||
.PHONY: check | ||
check: ## Run code quality tools. | ||
@echo "🚀 Checking lock file consistency with 'pyproject.toml'" | ||
@uv lock --locked | ||
@echo "🚀 Linting code: Running pre-commit" | ||
@uv run pre-commit run -a | ||
@echo "🚀 Static type checking: Running mypy" | ||
@uv run mypy | ||
|
||
.PHONY: test | ||
test: ## Test the code with pytest | ||
@echo "🚀 Testing code: Running pytest" | ||
@uv run python -m pytest --doctest-modules | ||
|
||
.PHONY: build | ||
build: clean-build ## Build wheel file | ||
@echo "🚀 Creating wheel file" | ||
@uvx --from build pyproject-build --installer uv | ||
|
||
.PHONY: clean-build | ||
clean-build: ## Clean build artifacts | ||
@echo "🚀 Removing build artifacts" | ||
@uv run python -c "import shutil; import os; shutil.rmtree('dist') if os.path.exists('dist') else None" | ||
|
||
.PHONY: publish | ||
publish: ## Publish a release to PyPI. | ||
@echo "🚀 Publishing." | ||
@uvx twine upload --repository-url https://upload.pypi.org/legacy/ dist/* | ||
|
||
.PHONY: build-and-publish | ||
build-and-publish: build publish ## Build and publish. | ||
|
||
.PHONY: help | ||
help: | ||
@uv run python -c "import re; \ | ||
[[print(f'\033[36m{m[0]:<20}\033[0m {m[1]}') for m in re.findall(r'^([a-zA-Z_-]+):.*?## (.*)$$', open(makefile).read(), re.M)] for makefile in ('$(MAKEFILE_LIST)').strip().split()]" | ||
|
||
.DEFAULT_GOAL := help |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.