Skip to content

Commit

Permalink
add Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
ebonnal committed Dec 23, 2024
1 parent ddcdd7f commit 4b1dcf8
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 35 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,4 @@ jobs:
python-version: 3.8

- name: checks
run: |
python -m pip install -r requirements-dev.txt
python -m autoflake --in-place --remove-all-unused-imports --remove-unused-variables --ignore-init-module --check -r streamable tests
python -m black --check .
run: make venv lint
4 changes: 1 addition & 3 deletions .github/workflows/typing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,4 @@ jobs:
python-version: 3.8

- name: mypy
run: |
python -m pip install -r requirements-dev.txt
python -m mypy --install-types --non-interactive streamable tests
run: make venv type-check
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
.vscode
__pycache__
.venv
tmp*
Expand Down
44 changes: 16 additions & 28 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# Design Overview
# Makefile

`make all` or a specific target:
```bash
make venv
make test
make type-check
make lint
```

Run a specific test:
```bash
python -m unittest tests.test_stream.TestStream.test_distinct
```

# Design principles

## Fluent Interface Pattern
The lib is built around a single entry point, the `Stream` class. This is the only import required. This lib must be trivial to use, all the behaviors it exposes should be carefully named and designed to make them as self-explanatory as possible. A stream declaration should resemble natural language:
Expand All @@ -16,30 +31,3 @@ Each node in this composite structure exposes an `.accept` method enabling trave

## Decorator Pattern
A `Stream[T]` both inherits from `Iterable[T]` and holds an `Iterable[T]` as its `.source`: when you instantiate a stream from an iterable you decorate it with a fluent interface.

# Cheat Sheet: commands for contributors

```bash
git clone [email protected]:ebonnal/streamable
cd streamable
python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements-dev.txt
```

## run unittest and check coverage
```bash
python -m coverage run -m unittest && coverage report
```

## check typing
```bash
python -m mypy streamable tests
```

## lint
```bash
python -m autoflake --in-place --remove-all-unused-imports --remove-unused-variables --ignore-init-module -r streamable tests \
&& python -m isort streamable tests \
&& python -m black .
```
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
VENV_DIR := .venv

all: venv test type-check lint

help:
@echo "Available commands:"
@echo " make all - Run all tasks: venv, test, type-check, lint"
@echo " make venv - Create a virtual environment and install dependencies"
@echo " make test - Run unittests and check coverage"
@echo " make type-check - Check typing with mypy"
@echo " make lint - Lint the codebase"
@echo " make clean - Clean up the environment"

venv:
python3 -m venv $(VENV_DIR)
$(VENV_DIR)/bin/pip install -r requirements-dev.txt

test:
$(VENV_DIR)/bin/python -m coverage run -m unittest --failfast
$(VENV_DIR)/bin/coverage html

type-check:
$(VENV_DIR)/bin/python -m mypy --install-types --non-interactive streamable tests

lint:
$(VENV_DIR)/bin/python -m autoflake --in-place --remove-all-unused-imports --remove-unused-variables --ignore-init-module -r streamable tests
$(VENV_DIR)/bin/python -m isort streamable tests
$(VENV_DIR)/bin/python -m black .

0 comments on commit 4b1dcf8

Please sign in to comment.