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"
49 changes: 20 additions & 29 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,40 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v7

- name: Install poetry
run: pipx install poetry

- name: Set up Python
uses: actions/setup-python@v4
- uses: actions/setup-python@v7
with:
python-version: '3.8'
cache: 'poetry'
python-version: "3.11"

- name: Install dependencies
run: poetry install
- uses: astral-sh/setup-uv@v9.0.0
with:
version: "latest"
prune-cache: true

- name: Check formatting
run: |
source $(poetry env info --path)/bin/activate
make format-check
run: make format-check

test:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v7

- name: Install poetry
run: pipx install poetry

- name: Set up Python
uses: actions/setup-python@v4
- uses: actions/setup-python@v7
with:
python-version: '3.8'
cache: 'poetry'
python-version: "3.11"

- name: Install dependencies
run: poetry install
- uses: astral-sh/setup-uv@v9.0.0
with:
version: "latest"
prune-cache: true

- name: Run main
run: make run

- name: Test
run: |
source $(poetry env info --path)/bin/activate
make test
run: make test
19 changes: 0 additions & 19 deletions .replit

This file was deleted.

41 changes: 28 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
all: test
COLOR_CYAN := \033[36m
COLOR_RESET := \033[0m

SRCS := $(shell git ls-files *.py)
SRCS := $(shell git ls-files '*.py')

.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: run
run:
./main.py
run: ## Run the main entry point
uv run python main.py

.PHONY: test
test:
pytest test_*.py
test: ## Run tests
uv run pytest test_*.py

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

.PHONY: format-check
format-check:
yapf --diff $(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
94 changes: 84 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Roman numerals kata in Python

[![CI](https://github.com/Coding-Cuddles/roman-numerals-python-kata/actions/workflows/main.yml/badge.svg)](https://github.com/Coding-Cuddles/roman-numerals-python-kata/actions/workflows/main.yml)
[![Replit](https://img.shields.io/badge/Try%20with%20Replit-black?logo=replit)](https://replit.com/new/github/Coding-Cuddles/roman-numerals-python-kata)
[![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

Expand Down Expand Up @@ -61,24 +62,97 @@ their corresponding Arabic digits.
* If you do know an algorithm, evaluate if it can be implemented using strict
TDD principles.

## Usage
## Prerequisites

You can import this project into [Replit](https://replit.com), and it will
handle all dependencies automatically.
Required:

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

* [Python 3.8+](https://www.python.org/)
* [pytest](https://pytest.org)
Optional:

### Run main
- [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/roman-numerals-python-kata.git
```

2. Enter the repository directory:

```console
cd roman-numerals-python-kata
```

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

```console
make test
```

Otherwise, run pytest through `uv` directly:

```console
uv run pytest test_*.py
```

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. Add the next behavior to `test_roman_numerals.py`, then implement it in `roman_numerals.py`.

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 test_*.py
```

Continue when the test run passes.

## Run the entry point

The repository retains `main.py` as its command-line entry point. Use Make when it is installed:

```console
make run
```

### Run tests
Otherwise, run it through `uv` directly:

```console
make test
uv run python main.py
```

The command prints `Hello World!`.

## Make command reference

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

| Command | Result |
| ------------------- | --------------------------------------- |
| `make all` | Run the test suite |
| `make help` | List public Make targets |
| `make run` | Run `main.py` |
| `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 |
Loading
Loading