|
4 | 4 | # pip install ruff mypy pytest gltest (or: make setup) |
5 | 5 | # npm i -g genlayer (GenLayer CLI, for deploy) |
6 | 6 |
|
7 | | -PY ?= python3 |
| 7 | +# Use the local virtualenv's tools when it exists (so `make` works without |
| 8 | +# manually activating .venv), otherwise fall back to whatever is on PATH. |
| 9 | +# The venv bin is also prepended to PATH so tools that shell out to siblings |
| 10 | +# (genvm-lint → pyright) find them too. |
| 11 | +VENV_BIN := $(if $(wildcard .venv/bin),$(abspath .venv/bin)/,) |
| 12 | +ifneq ($(VENV_BIN),) |
| 13 | +export PATH := $(abspath .venv/bin):$(PATH) |
| 14 | +endif |
| 15 | +PY ?= $(if $(VENV_BIN),$(VENV_BIN)python,python3) |
| 16 | +RUFF := $(VENV_BIN)ruff |
| 17 | +MYPY := $(VENV_BIN)mypy |
| 18 | +PYTEST := $(VENV_BIN)pytest |
| 19 | +GENVM_LINT := $(VENV_BIN)genvm-lint |
8 | 20 | CONTRACT = grudge.py |
9 | 21 |
|
10 | | -.PHONY: setup lint format test test-math test-bradbury deploy clean |
| 22 | +# gltest is part of the GenLayer toolchain (not on PyPI). Use the venv copy if |
| 23 | +# present, otherwise whatever is on PATH. |
| 24 | +GLTEST := $(if $(wildcard .venv/bin/gltest),$(VENV_BIN)gltest,gltest) |
| 25 | + |
| 26 | +.PHONY: setup lint check typecheck format test test-math test-chain test-bradbury deploy clean |
11 | 27 |
|
12 | 28 | setup: |
13 | | - $(PY) -m pip install --quiet ruff mypy pytest gltest genvm-linter pyright |
| 29 | + $(PY) -m pip install --quiet ruff mypy pytest genlayer-test genvm-linter pyright |
14 | 30 |
|
15 | 31 | lint: |
16 | | - ruff check . --config pyproject.toml |
17 | | - ruff format --check . |
18 | | - MYPYPATH=stubs mypy $(CONTRACT) --strict --config-file pyproject.toml |
| 32 | + $(RUFF) check . --config pyproject.toml |
| 33 | + $(RUFF) format --check . |
| 34 | + MYPYPATH=stubs $(MYPY) $(CONTRACT) --strict --config-file pyproject.toml |
19 | 35 | $(PY) scripts/genvm_lint.py $(CONTRACT) |
20 | | - genvm-lint check $(CONTRACT) --json |
21 | | - genvm-lint typecheck $(CONTRACT) --json |
| 36 | + $(GENVM_LINT) check $(CONTRACT) --json |
| 37 | + $(GENVM_LINT) typecheck $(CONTRACT) --json |
| 38 | + |
| 39 | +# GenVM rule lint + contract validation (Depends header, one gl.Contract, |
| 40 | +# storable state, public-method ABI, etc.) |
| 41 | +check: |
| 42 | + $(GENVM_LINT) check $(CONTRACT) --json |
| 43 | + |
| 44 | +# GenVM static typecheck of the contract. |
| 45 | +typecheck: |
| 46 | + $(GENVM_LINT) typecheck $(CONTRACT) --json |
22 | 47 |
|
23 | 48 | format: |
24 | | - ruff format . |
| 49 | + $(RUFF) format . |
| 50 | + |
| 51 | +# CI default: fast Direct Mode tests that run the REAL contract in-memory |
| 52 | +# (no Docker, no network, LLM mocked) per the official GenLayer docs, plus the |
| 53 | +# pure settlement-math units. Milliseconds, runs everywhere. |
| 54 | +test: test-unit |
| 55 | + |
| 56 | +test-unit: |
| 57 | + $(PY) -m pytest tests/test_grudge_direct.py tests/test_settle_math.py -q |
25 | 58 |
|
26 | | -# CI default: settlement-math unit tests (no network) + gltest vs studionet. |
27 | | -test: test-math |
28 | | - gltest --network studionet |
| 59 | +# Back-compat alias. |
| 60 | +test-math: test-unit |
29 | 61 |
|
30 | | -test-math: |
31 | | - $(PY) -m pytest tests/test_settle_math.py -q |
| 62 | +# Studio-mode integration suite (multi-validator consensus over RPC). Point |
| 63 | +# NETWORK at a localnet simulator (default) or studionet. Needs gltest |
| 64 | +# installed AND a running simulator — run `make setup`. |
| 65 | +NETWORK ?= localnet |
| 66 | +test-chain: |
| 67 | + @command -v $(GLTEST) >/dev/null 2>&1 || { \ |
| 68 | + echo "✘ gltest not installed. Run: make setup"; exit 1; } |
| 69 | + $(GLTEST) tests/test_grudge.py --network $(NETWORK) |
32 | 70 |
|
33 | 71 | # Pre-release verification target — Bradbury history resets periodically, |
34 | 72 | # so this is NOT the CI default. |
35 | 73 | test-bradbury: |
36 | | - gltest --network testnet_bradbury |
| 74 | + $(GLTEST) --network testnet_bradbury |
37 | 75 |
|
38 | 76 | # Deploys to Bradbury and writes the address into the web app env + a record. |
39 | 77 | deploy: |
|
0 commit comments