Skip to content

Commit 63b36b7

Browse files
authored
feat: Use make as a command runner (#167)
1 parent 73bfe6d commit 63b36b7

File tree

3 files changed

+49
-13
lines changed

3 files changed

+49
-13
lines changed

.github/workflows/ci.yml

+6-8
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@ jobs:
3838
restore-keys: |
3939
${{ runner.os }}-pip-py${{ matrix.python }}-
4040
- name: Install dev dependencies
41-
run: pip install --requirement requirements-dev.txt
42-
43-
# Install library
44-
- name: Install result
45-
run: pip install --editable .
41+
# There's no virtual env in CI environment, just bypass it with a dummy
42+
# env var value
43+
run: VIRTUAL_ENV=none make install
4644

4745
# Tests
4846
- name: Run tests
@@ -60,13 +58,13 @@ jobs:
6058

6159
# Linters
6260
- name: Run flake8 (Python >= 3.10)
63-
run: flake8
61+
run: make lint-flake
6462
if: matrix.python != '3.9' && matrix.python != '3.8'
6563
- name: Run flake8 (Python < 3.10)
66-
run: flake8 --extend-exclude tests/test_pattern_matching.py
64+
run: make lint-flake-pre310
6765
if: matrix.python == '3.9' || matrix.python == '3.8'
6866
- name: Run mypy
69-
run: mypy
67+
run: make lint-mypy
7068

7169
# Packaging
7270
- name: Build packages

Makefile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# phony trick from https://keleshev.com/my-book-writing-setup/
2+
.PHONY: phony
3+
4+
install: phony
5+
ifndef VIRTUAL_ENV
6+
$(error install can only be run inside a Python virtual environment)
7+
endif
8+
@echo Installing dependencies...
9+
pip install -r requirements-dev.txt
10+
pip install -e .
11+
12+
lint: phony lint-flake lint-mypy
13+
14+
lint-flake: phony
15+
flake8
16+
17+
lint-flake-pre310: phony
18+
# Python <3.10 doesn't support pattern matching.
19+
flake8 --extend-exclude tests/test_pattern_matching.py
20+
21+
lint-mypy: phony
22+
mypy
23+
24+
test: phony
25+
pytest

README.md

+18-5
Original file line numberDiff line numberDiff line change
@@ -419,11 +419,24 @@ Sometimes regular `do()` can handle async values, but this error means
419419
you have hit a case where it does not. You should use `do_async()` here
420420
instead.
421421

422-
## Development
423-
424-
- Set up: `pip install -e .`
425-
- Test your changes: `flake8 src tests; mypy; pytest`
426-
- Remember to test in Python 3.8 - 3.12.
422+
## Contributing
423+
424+
These steps should work on any Unix-based system (Linux, macOS, etc) with Python
425+
and `make` installed. On Windows, you will need to refer to the Python
426+
documentation (linked below) and reference the `Makefile` for commands to run
427+
from the non-unix shell you're using on Windows.
428+
429+
1. Setup and activate a virtual environment. See [Python docs][pydocs-venv] for more
430+
information about virtual environments and setup.
431+
2. Run `make install` to install dependencies
432+
3. Switch to a new git branch and make your changes
433+
4. Test your changes:
434+
- `make test`
435+
- `make lint`
436+
- You can also start a Python REPL and import `result`
437+
5. Git commit and create a new PR.
438+
439+
[pydocs-venv]: https://docs.python.org/3/library/venv.html
427440

428441
## FAQ
429442

0 commit comments

Comments
 (0)