Skip to content

Commit

Permalink
feat: Use make as a command runner (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
francium committed Dec 23, 2023
1 parent 73bfe6d commit 63b36b7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 13 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-py${{ matrix.python }}-
- name: Install dev dependencies
run: pip install --requirement requirements-dev.txt

# Install library
- name: Install result
run: pip install --editable .
# There's no virtual env in CI environment, just bypass it with a dummy
# env var value
run: VIRTUAL_ENV=none make install

# Tests
- name: Run tests
Expand All @@ -60,13 +58,13 @@ jobs:

# Linters
- name: Run flake8 (Python >= 3.10)
run: flake8
run: make lint-flake
if: matrix.python != '3.9' && matrix.python != '3.8'
- name: Run flake8 (Python < 3.10)
run: flake8 --extend-exclude tests/test_pattern_matching.py
run: make lint-flake-pre310
if: matrix.python == '3.9' || matrix.python == '3.8'
- name: Run mypy
run: mypy
run: make lint-mypy

# Packaging
- name: Build packages
Expand Down
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# phony trick from https://keleshev.com/my-book-writing-setup/
.PHONY: phony

install: phony
ifndef VIRTUAL_ENV
$(error install can only be run inside a Python virtual environment)
endif
@echo Installing dependencies...
pip install -r requirements-dev.txt
pip install -e .

lint: phony lint-flake lint-mypy

lint-flake: phony
flake8

lint-flake-pre310: phony
# Python <3.10 doesn't support pattern matching.
flake8 --extend-exclude tests/test_pattern_matching.py

lint-mypy: phony
mypy

test: phony
pytest
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,24 @@ Sometimes regular `do()` can handle async values, but this error means
you have hit a case where it does not. You should use `do_async()` here
instead.

## Development

- Set up: `pip install -e .`
- Test your changes: `flake8 src tests; mypy; pytest`
- Remember to test in Python 3.8 - 3.12.
## Contributing

These steps should work on any Unix-based system (Linux, macOS, etc) with Python
and `make` installed. On Windows, you will need to refer to the Python
documentation (linked below) and reference the `Makefile` for commands to run
from the non-unix shell you're using on Windows.

1. Setup and activate a virtual environment. See [Python docs][pydocs-venv] for more
information about virtual environments and setup.
2. Run `make install` to install dependencies
3. Switch to a new git branch and make your changes
4. Test your changes:
- `make test`
- `make lint`
- You can also start a Python REPL and import `result`
5. Git commit and create a new PR.

[pydocs-venv]: https://docs.python.org/3/library/venv.html

## FAQ

Expand Down

0 comments on commit 63b36b7

Please sign in to comment.