Skip to content
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @Coding-Cuddles/kata-maintainers
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

updates:
- package-ecosystem: "uv"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
18 changes: 10 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- uses: actions/setup-python@v4
- uses: actions/setup-python@v7
with:
python-version: "3.8"
python-version: "3.11"

- uses: astral-sh/setup-uv@v6
- uses: astral-sh/setup-uv@v9.0.0
with:
version: "latest"
prune-cache: true

- name: Check formatting
run: make format-check
Expand All @@ -31,15 +32,16 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- uses: actions/setup-python@v4
- uses: actions/setup-python@v7
with:
python-version: "3.8"
python-version: "3.11"

- uses: astral-sh/setup-uv@v6
- uses: astral-sh/setup-uv@v9.0.0
with:
version: "latest"
prune-cache: true

- name: Test
run: make test
42 changes: 25 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
all: test
COLOR_CYAN := \033[36m
COLOR_RESET := \033[0m

UV := $(shell command -v uv 2> /dev/null)
SRCS := $(shell git ls-files *.py)
SRCS := $(shell git ls-files '*.py')

ifdef UV
RUNNER := uv run
else
RUNNER :=
endif
.DEFAULT_GOAL := help

.PHONY: all
all: test ## Run tests

.PHONY: help
help: ## Show this help message
@awk 'BEGIN {FS = ":.*##"; printf "Usage: make [options] $(COLOR_CYAN)[target] ...$(COLOR_RESET)\n\n"} \
/^[a-zA-Z_-]+:.*##/ {printf " $(COLOR_CYAN)%-20s$(COLOR_RESET) %s\n", $$1, $$2}' \
$(MAKEFILE_LIST)

.PHONY: test
test:
$(RUNNER) pytest test_*.py
test: ## Run tests
uv run pytest test_*.py

.PHONY: format
format:
$(RUNNER) ruff format $(SRCS)
format: ## Format Python sources in place
uv run ruff format $(SRCS)

.PHONY: format-check
format-check:
$(RUNNER) ruff format --check $(SRCS) \
format-check: ## Fail if Python sources require formatting
uv run ruff format --check $(SRCS) \
|| (echo "Some files require formatting. Run 'make format' to fix." && exit 1)

.PHONY: clean
clean:
git clean -Xfd
clean: ## Remove generated caches
find . \( -path ./.git -o -path ./.venv -o -path ./venv \) -prune \
-o -type d -name __pycache__ -exec rm -rf {} +
rm -rf .pytest_cache .ruff_cache
rm -f .coverage .coverage.*

ifndef VERBOSE
ifneq ($(VERBOSE),1)
.SILENT:
endif
84 changes: 74 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,84 @@
# Bootstrap for Python coding kata

[![CI](https://github.com/Coding-Cuddles/bootstrap-python-kata/actions/workflows/main.yml/badge.svg)](https://github.com/Coding-Cuddles/bootstrap-python-kata/actions/workflows/main.yml)
[![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

## Overview

This is a bootstrap repository for clean code katas in Python 3 using pytest.
Start a Python coding kata with pytest. Setup is complete when the starter test passes.

## Prerequisites

- [Python 3.8+](https://www.python.org/)
- [pytest](https://pytest.org)
Required:

- [Git](https://git-scm.com/downloads)
- [uv](https://docs.astral.sh/uv/getting-started/installation/)

Optional:

- [GNU Make](https://www.gnu.org/software/make/), for shorter commands. Every required task also
has a direct `uv` command.

You do not need to install Python or pytest separately. `uv` installs a compatible Python version
and the locked project dependencies when needed.

## Set up the kata

1. Clone the repository:

```console
git clone https://github.com/Coding-Cuddles/bootstrap-python-kata.git
```

2. Enter the repository directory:

```console
cd bootstrap-python-kata
```

3. Run the starter test. Use Make when it is installed:

```console
make test
```

Otherwise, run pytest through `uv` directly:

```console
uv run pytest
```

The first run may install Python and the project dependencies. Setup is complete when pytest
reports `1 passed`.

If the command fails with `uv: command not found`, install
[uv](https://docs.astral.sh/uv/getting-started/installation/) and repeat this step.

## Work on the kata

1. Replace the starter assertions in `test_something.py` with the first kata test.

2. Run the tests after each change. Use Make when it is installed:

```console
make test
```

Otherwise, run pytest through `uv` directly:

```console
uv run pytest
```

Continue when the test run passes.

## Usage
## Make command reference

### Run tests
Make is optional. Run `make` or `make help` to list these commands in the terminal.

```console
make test
```
| Command | Result |
| ------------------- | --------------------------------------- |
| `make all` | Run the test suite |
| `make test` | Run the test suite |
| `make format` | Format tracked Python files |
| `make format-check` | Check formatting without changing files |
| `make clean` | Remove generated caches |
12 changes: 8 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ name = "bootstrap-python-kata"
version = "1.0.0"
description = "Bootstrap for Python coding kata"
authors = [{ name = "Codding Cuddles" }]
requires-python = ">=3.8"
requires-python = ">=3.11"

dependencies = [
"pytest>=8.0",
"ruff>=0.11.0"
"pytest>=9.1.1"
]

[dependency-groups]
dev = [
"ruff>=0.16.1"
]

[tool.ruff]
target-version = "py38"
target-version = "py311"
line-length = 100

[tool.ruff.format]
Expand Down
Loading