|
| 1 | +alias test := tests |
| 2 | + |
| 3 | +# print list of available recipes |
| 4 | +list: |
| 5 | + @just --list |
| 6 | + |
| 7 | +# print API version |
| 8 | +version: |
| 9 | + @echo "Test-API version: $(uv run python3 -c "from tekst import __version__ as v; print(v, end='')")" |
| 10 | + |
| 11 | +# install dependencies |
| 12 | +install: |
| 13 | + uv sync |
| 14 | + |
| 15 | +# format code base, fix linting errors |
| 16 | +fix: |
| 17 | + uv run ruff format . |
| 18 | + uv run ruff check . --fix |
| 19 | + |
| 20 | +# check code formatting and style |
| 21 | +check: |
| 22 | + uv run ruff format . --check |
| 23 | + uv run ruff check . --extend-select N |
| 24 | + |
| 25 | +# run tests |
| 26 | +tests ARGS="": install (services-up "test") && (services-down "test") |
| 27 | + -TEKST_CUSTOM_ENV_FILE=.env.test uv run pytest {{ARGS}} |
| 28 | + |
| 29 | +# run dev environment |
| 30 | +dev: (services-up "dev") && (services-down "dev") |
| 31 | + -TEKST_DEV_MODE=true uv run python3 -m tekst bootstrap |
| 32 | + @printf "\n\ |
| 33 | + ╭───────────────────────────────────────────────────────╮\n\ |
| 34 | + │ 🌐 Tekst-Web Dev Server ... http://127.0.0.1 │\n\ |
| 35 | + │ 🐍 Tekst-API .............. http://127.0.0.1/api │\n\ |
| 36 | + │ 📖 API Docs ............... http://127.0.0.1/api/docs │\n\ |
| 37 | + │ 📬 MailPit ................ http://127.0.0.1:8025 │\n\ |
| 38 | + │ 📂 MongoExpress ........... http://127.0.0.1:8081 │\n\ |
| 39 | + ╰───────────────────────────────────────────────────────╯\n\ |
| 40 | + \n\ |
| 41 | + " |
| 42 | + -TEKST_DEV_MODE=true uv run fastapi dev tekst/app.py |
| 43 | + |
| 44 | +# export OpenAPI schema to openapi.json |
| 45 | +schema: |
| 46 | + TEKST_DEV_MODE=true TEKST_LOG_LEVEL=warning uv run python3 -m tekst schema -f |
| 47 | + |
| 48 | +# run full pre-commit toolchain |
| 49 | +all: |
| 50 | + just fix |
| 51 | + just tests |
| 52 | + just check |
| 53 | + just schema |
| 54 | + |
| 55 | +# build updated container images in services stack |
| 56 | +services-build: |
| 57 | + docker compose -f ../dev/compose.yml --profile dev --profile test build |
| 58 | + |
| 59 | +# run services stack |
| 60 | +services-up SCOPE="test": gen-smtp-ssl-cert && wait-for-mongodb wait-for-elasticsearch |
| 61 | + docker compose -f ../dev/compose.yml --profile {{SCOPE}} -p tekst-{{SCOPE}} up --detach |
| 62 | + |
| 63 | +# kill services stack |
| 64 | +services-down SCOPE="test": |
| 65 | + docker compose -f ../dev/compose.yml --profile {{SCOPE}} -p tekst-{{SCOPE}} down --volumes |
| 66 | + |
| 67 | +# clean up generated files |
| 68 | +cleanup: |
| 69 | + uv run ruff clean |
| 70 | + rm -rf \ |
| 71 | + */**/__pycache__ \ |
| 72 | + */**/.pytest_cache \ |
| 73 | + .ruff_cache \ |
| 74 | + .coverage \ |
| 75 | + dist \ |
| 76 | + htmlcov \ |
| 77 | + |
| 78 | +[private] |
| 79 | +wait-for-mongodb: |
| 80 | + @printf "Waiting for MongoDB service"; sleep 2; printf "\n" |
| 81 | + |
| 82 | +[private] |
| 83 | +wait-for-elasticsearch: |
| 84 | + @printf "Waiting for Elasticsearch service"; while ! $(curl -f 127.0.0.1:9200 > /dev/null 2>&1); do sleep 1; printf "."; done; printf "\n" |
| 85 | + |
| 86 | +[private] |
| 87 | +gen-smtp-ssl-cert: |
| 88 | + @cd ../dev/smtp-ssl && ./generate.sh |
0 commit comments