Skip to content

Commit 56fc16a

Browse files
committed
build: refresh Python kata bootstrap
- Require Python 3.11 and refresh pytest, Ruff, and the uv lockfile. - Document zero-start setup with optional Make entry points. - Add self-documenting targets and cache-only cleanup. - Refresh CI and add Dependabot and Kata Maintainers ownership.
1 parent 33e5622 commit 56fc16a

7 files changed

Lines changed: 181 additions & 126 deletions

File tree

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @Coding-Cuddles/kata-maintainers

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
3+
updates:
4+
- package-ecosystem: "uv"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
9+
- package-ecosystem: "github-actions"
10+
directory: "/"
11+
schedule:
12+
interval: "weekly"

.github/workflows/main.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v4
14+
- uses: actions/checkout@v7
1515

16-
- uses: actions/setup-python@v4
16+
- uses: actions/setup-python@v7
1717
with:
18-
python-version: "3.8"
18+
python-version: "3.11"
1919

20-
- uses: astral-sh/setup-uv@v6
20+
- uses: astral-sh/setup-uv@v9.0.0
2121
with:
2222
version: "latest"
23+
prune-cache: true
2324

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

3334
steps:
34-
- uses: actions/checkout@v4
35+
- uses: actions/checkout@v7
3536

36-
- uses: actions/setup-python@v4
37+
- uses: actions/setup-python@v7
3738
with:
38-
python-version: "3.8"
39+
python-version: "3.11"
3940

40-
- uses: astral-sh/setup-uv@v6
41+
- uses: astral-sh/setup-uv@v9.0.0
4142
with:
4243
version: "latest"
44+
prune-cache: true
4345

4446
- name: Test
4547
run: make test

Makefile

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,39 @@
1-
all: test
1+
COLOR_CYAN := \033[36m
2+
COLOR_RESET := \033[0m
23

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

6-
ifdef UV
7-
RUNNER := uv run
8-
else
9-
RUNNER :=
10-
endif
6+
.DEFAULT_GOAL := help
7+
8+
.PHONY: all
9+
all: test ## Run tests
10+
11+
.PHONY: help
12+
help: ## Show this help message
13+
@awk 'BEGIN {FS = ":.*##"; printf "Usage: make [options] $(COLOR_CYAN)[target] ...$(COLOR_RESET)\n\n"} \
14+
/^[a-zA-Z_-]+:.*##/ {printf " $(COLOR_CYAN)%-20s$(COLOR_RESET) %s\n", $$1, $$2}' \
15+
$(MAKEFILE_LIST)
1116

1217
.PHONY: test
13-
test:
14-
$(RUNNER) pytest test_*.py
18+
test: ## Run tests
19+
uv run pytest test_*.py
1520

1621
.PHONY: format
17-
format:
18-
$(RUNNER) ruff format $(SRCS)
22+
format: ## Format Python sources in place
23+
uv run ruff format $(SRCS)
1924

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

2530
.PHONY: clean
26-
clean:
27-
git clean -Xfd
31+
clean: ## Remove generated caches
32+
find . \( -path ./.git -o -path ./.venv -o -path ./venv \) -prune \
33+
-o -type d -name __pycache__ -exec rm -rf {} +
34+
rm -rf .pytest_cache .ruff_cache
35+
rm -f .coverage .coverage.*
2836

29-
ifndef VERBOSE
37+
ifneq ($(VERBOSE),1)
3038
.SILENT:
3139
endif

README.md

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,84 @@
11
# Bootstrap for Python coding kata
22

33
[![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)
4+
[![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)
5+
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
46

5-
## Overview
6-
7-
This is a bootstrap repository for clean code katas in Python 3 using pytest.
7+
Start a Python coding kata with pytest. Setup is complete when the starter test passes.
88

99
## Prerequisites
1010

11-
- [Python 3.8+](https://www.python.org/)
12-
- [pytest](https://pytest.org)
11+
Required:
12+
13+
- [Git](https://git-scm.com/downloads)
14+
- [uv](https://docs.astral.sh/uv/getting-started/installation/)
15+
16+
Optional:
17+
18+
- [GNU Make](https://www.gnu.org/software/make/), for shorter commands. Every required task also
19+
has a direct `uv` command.
20+
21+
You do not need to install Python or pytest separately. `uv` installs a compatible Python version
22+
and the locked project dependencies when needed.
23+
24+
## Set up the kata
25+
26+
1. Clone the repository:
27+
28+
```console
29+
git clone https://github.com/Coding-Cuddles/bootstrap-python-kata.git
30+
```
31+
32+
2. Enter the repository directory:
33+
34+
```console
35+
cd bootstrap-python-kata
36+
```
37+
38+
3. Run the starter test. Use Make when it is installed:
39+
40+
```console
41+
make test
42+
```
43+
44+
Otherwise, run pytest through `uv` directly:
45+
46+
```console
47+
uv run pytest
48+
```
49+
50+
The first run may install Python and the project dependencies. Setup is complete when pytest
51+
reports `1 passed`.
52+
53+
If the command fails with `uv: command not found`, install
54+
[uv](https://docs.astral.sh/uv/getting-started/installation/) and repeat this step.
55+
56+
## Work on the kata
57+
58+
1. Replace the starter assertions in `test_something.py` with the first kata test.
59+
60+
2. Run the tests after each change. Use Make when it is installed:
61+
62+
```console
63+
make test
64+
```
65+
66+
Otherwise, run pytest through `uv` directly:
67+
68+
```console
69+
uv run pytest
70+
```
71+
72+
Continue when the test run passes.
1373

14-
## Usage
74+
## Make command reference
1575

16-
### Run tests
76+
Make is optional. Run `make` or `make help` to list these commands in the terminal.
1777

18-
```console
19-
make test
20-
```
78+
| Command | Result |
79+
| ------------------- | --------------------------------------- |
80+
| `make all` | Run the test suite |
81+
| `make test` | Run the test suite |
82+
| `make format` | Format tracked Python files |
83+
| `make format-check` | Check formatting without changing files |
84+
| `make clean` | Remove generated caches |

pyproject.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ name = "bootstrap-python-kata"
33
version = "1.0.0"
44
description = "Bootstrap for Python coding kata"
55
authors = [{ name = "Codding Cuddles" }]
6-
requires-python = ">=3.8"
6+
requires-python = ">=3.11"
77

88
dependencies = [
9-
"pytest>=8.0",
10-
"ruff>=0.11.0"
9+
"pytest>=9.1.1"
10+
]
11+
12+
[dependency-groups]
13+
dev = [
14+
"ruff>=0.16.1"
1115
]
1216

1317
[tool.ruff]
14-
target-version = "py38"
18+
target-version = "py311"
1519
line-length = 100
1620

1721
[tool.ruff.format]

0 commit comments

Comments
 (0)