Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use poethepoet instead of Makefile for python commands #83

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: |
sudo apt-get install -y cloc
echo "# Lines of Code Report" >> $GITHUB_STEP_SUMMARY
make loc >> $GITHUB_STEP_SUMMARY
poe loc >> $GITHUB_STEP_SUMMARY
- name: Install pybmds
run: |
python -m pip install -U pip wheel setuptools
Expand All @@ -63,7 +63,7 @@ jobs:
python -m pip install -e ".[pg,dev]"
- name: lint
run: |
make lint-py
poe lint-py
- name: test
env:
DJANGO_DB_NAME: bmds-online-test
Expand Down
92 changes: 0 additions & 92 deletions Makefile

This file was deleted.

21 changes: 6 additions & 15 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,17 @@ In one terminal, start the the python webserver:
source ./venv/bin/activate

# install latest packages and requirements from code
make sync-dev

# sync db state with application state
manage.py migrate
poe sync-dev

# run development webserver
manage.py runserver
poe run-py
```

In another terminal, start the node frontend webserver:

```bash
# navigate to frontend folder
cd ./frontend

# install javascript dependencies
yarn

# start node hot-reloading server
npm start
poe run-js
```

If you navigate to [localhost](http://127.0.0.1:8000/) and see a website, you're ready to begin coding!
Expand Down Expand Up @@ -149,7 +140,7 @@ Integration tests use [playwright](https://playwright.dev/python/). By default,

```bash
# to run all
make test-integration
poe test-integration

# or a custom method to run a single test
INTEGRATION_TESTS=1 py.test -sv tests/integration/test_dichotomous.py --pdb
Expand All @@ -158,7 +149,7 @@ INTEGRATION_TESTS=1 py.test -sv tests/integration/test_dichotomous.py --pdb
When editing integration tests, use the interactive mode to capture user operations:

```bash
make test-integration-debug
poe test-integration-debug

# use set instead of export on windows
export INTEGRATION_TESTS=1
Expand All @@ -177,6 +168,6 @@ textual run --dev bmds_ui.desktop.cli:main
To build containers for deployment:

```bash
make build
poe build
docker compose -f compose/build.yml --project-directory . build
```
91 changes: 0 additions & 91 deletions make.bat

This file was deleted.

95 changes: 95 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ dependencies = [
dev = [
# build
"flit~=3.9.0",
"poethepoet~=0.32.2",

# debug
"django-debug-toolbar~=4.4.6",
Expand Down Expand Up @@ -140,3 +141,97 @@ lint.isort.known-first-party = ["bmds_ui", "pybmds"]
addopts = "--ds=bmds_ui.main.settings.testing --reuse-db --nomigrations --record-mode=once"
testpaths = ["tests"]
python_files = ["test_*.py"]

[tool.poe.tasks.sync-dev]
help = "Sync dev environment after code checkout"
sequence = [
{cmd = 'uv pip install -e ".[dev,pg]"'},
{cmd = "yarn --cwd frontend"},
{cmd = "python manage.py migrate"},
]

[tool.poe.tasks.run-py]
help = "Run python developer environment"
cmd = "python manage.py runserver 8100"

[tool.poe.tasks.run-js]
help = "Run javascript developer environment"
cmd = "npm --prefix ./frontend run start"

[tool.poe.tasks.test]
help = "Run python tests"
cmd = "py.test"

[tool.poe.tasks.test-integration]
help = "Run integration tests (requires `npm run start`)"
sequence = [
{cmd = "playwright install --with-deps chromium"},
{shell = "INTEGRATION_TESTS=1 py.test -sv tests/integration/"},
]

[tool.poe.tasks.test-integration-debug]
help = "Run integration tests in debug mode (requires `npm run start`)"
sequence = [
{cmd = "playwright install --with-deps chromium"},
{shell = "INTEGRATION_TESTS=1 PWDEBUG=1 py.test -sv tests/integration/"},
]

[tool.poe.tasks.test-js]
help = "Run javascript tests"
cmd = "npm --prefix ./frontend run test"

[tool.poe.tasks.format]
help = "Fix formatting issues where possible"
sequence = ["format-py", "format-js"]

[tool.poe.tasks.format-py]
help = "Fix python formatting issues where possible"
sequence = [
{cmd = "ruff format ."},
{cmd = "ruff check . --fix --show-fixes"},
]

[tool.poe.tasks.format-js]
help = "Fix javascript formatting issues where possible"
cmd = "npm --prefix ./frontend run format"

[tool.poe.tasks.lint]
help = "Check formatting issues"
sequence = ["lint-py", "lint-js"]

[tool.poe.tasks.lint-py]
help = "Check python formatting issues"
sequence = [
{cmd = "ruff format . --check"},
{cmd = "ruff check ."},
]

[tool.poe.tasks.lint-js]
help = "Check javascript formatting issues"
cmd = "npm --prefix ./frontend run lint"

[tool.poe.tasks.build]
help = "Build package"
sequence = [
{cmd = "npm --prefix ./frontend run build"},
{cmd = "python manage.py set_git_commit"},
{cmd = "uv build"},
]

[tool.poe.tasks.coverage]
help = "Run python coverage and create HTML report"
sequence = [
{cmd = "coverage run -m pytest"},
{cmd = "coverage html -d coverage_html -i"},
]

[tool.poe.tasks.loc]
help = "Generate lines of code report"
cmd = """cloc \
--exclude-dir=build,dist,migrations,node_modules,logs,private,public,scripts,vendor,venv \
--exclude-ext=json,yaml,svg,toml,ini \
--vcs=git \
--counted loc-files.txt \
--md \
.
"""
Loading