diff --git a/Makefile b/Makefile index 14d05fd3f..769e5c29d 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,12 @@ .DEFAULT_GOAL := help +VENV := .venv TESTNET_VARIANT ?= conway_fast +## --------------------------------------------------------------------------- +## Setup +## --------------------------------------------------------------------------- + .PHONY: install install: ## Install cardano_node_tests and its dependencies into a virtual environment ./scripts/setup_dev_venv.sh @@ -30,48 +35,10 @@ reinstall-editable: ## Reinstall python package in editable mode from a given gi test-env: ## Set up test environment (variant: TESTNET_VARIANT=conway_fast) @./scripts/setup_test_env.sh $(TESTNET_VARIANT:%_fast=%) -# update flake.lock -.PHONY: update-flake-lock -update-flake-lock: ## Update flake.lock - nix flake update --accept-flake-config - -.PHONY: update-uv-lock -update-uv-lock: ## Update uv lockfile - @exit_code=0; \ - ./scripts/uv_update_lock.sh || exit_code=$$?; \ - if [ $$exit_code -ne 0 ] && [ $$exit_code -ne 10 ]; then \ - echo "uv lockfile update failed. Retrying without cache..." >&2; \ - ./scripts/uv_update_lock.sh --refresh; \ - else \ - exit $$exit_code; \ - fi - -.PHONY: init-lint -init-lint: ## Initialize linters - pre-commit clean - pre-commit gc - find . -path '*/.mypy_cache/*' -delete - pre-commit uninstall - pre-commit install --install-hooks - -.PHONY: lint -lint: ## Run linters - pre-commit run -a --show-diff-on-failure --color=always - -.PHONY: build-doc -build-doc: ## Build sphinx documentation - mkdir -p src_docs/build - $(MAKE) -C src_docs clean - $(MAKE) -C src_docs html - -.PHONY: doc -doc: ## Build and deploy sphinx documentation - ./scripts/deploy_doc.sh - # prepare cluster scripts for the given variant .PHONY: cluster-scripts cluster-scripts: ## Prepare local testnet cluster scripts (variant: TESTNET_VARIANT=conway_fast) - prepare-cluster-scripts -c -d dev_workdir/$(TESTNET_VARIANT) -t $(TESTNET_VARIANT) + $(VENV)/bin/prepare-cluster-scripts -c -d dev_workdir/$(TESTNET_VARIANT) -t $(TESTNET_VARIANT) # start the local testnet cluster .PHONY: start-cluster @@ -93,8 +60,87 @@ stop-cluster: ## Stop local testnet cluster (variant: TESTNET_VARIANT=conway_fas fi ./dev_workdir/$(TESTNET_VARIANT)/stop-cluster +## --------------------------------------------------------------------------- +## Linting +## --------------------------------------------------------------------------- + +.PHONY: init-lint +init-lint: ## Initialize linters + $(VENV)/bin/pre-commit clean + $(VENV)/bin/pre-commit gc + find . -path '*/.mypy_cache/*' -delete + $(VENV)/bin/pre-commit uninstall + $(VENV)/bin/pre-commit install --install-hooks + +.PHONY: lint +lint: ## Run linters + $(VENV)/bin/pre-commit run -a --show-diff-on-failure --color=always + +.PHONY: fmt +fmt: ## Format code with ruff + $(VENV)/bin/pre-commit run ruff-check -a + $(VENV)/bin/pre-commit run ruff-format -a + +## --------------------------------------------------------------------------- +## Documentation +## --------------------------------------------------------------------------- + +.PHONY: build-doc +build-doc: ## Build sphinx documentation + mkdir -p src_docs/build + $(MAKE) -C src_docs clean + $(MAKE) -C src_docs html + +.PHONY: doc +doc: ## Build and deploy sphinx documentation + ./scripts/deploy_doc.sh + +## --------------------------------------------------------------------------- +## Maintenance +## --------------------------------------------------------------------------- + +# update flake.lock +.PHONY: update-flake-lock +update-flake-lock: ## Update flake.lock + nix flake update --accept-flake-config + +.PHONY: update-uv-lock +update-uv-lock: ## Update uv lockfile + @exit_code=0; \ + ./scripts/uv_update_lock.sh || exit_code=$$?; \ + if [ $$exit_code -ne 0 ] && [ $$exit_code -ne 10 ]; then \ + echo "uv lockfile update failed. Retrying without cache..." >&2; \ + ./scripts/uv_update_lock.sh --refresh; \ + else \ + exit $$exit_code; \ + fi + +.PHONY: clean +clean: ## Clean build artifacts and caches + find . -type d -name __pycache__ -not -path './$(VENV)/*' -exec rm -rf {} + + find . -type d -name .pytest_cache -not -path './$(VENV)/*' -exec rm -rf {} + + find . -type d -name .mypy_cache -not -path './$(VENV)/*' -exec rm -rf {} + + find . -type d -name '*.egg-info' -not -path './$(VENV)/*' -exec rm -rf {} + + find . -name '*.pyc' -not -path './$(VENV)/*' -delete + +.PHONY: clean-all +clean-all: clean ## Clean all build artifacts, caches, and virtual environment + @echo "Removing virtual environment: $(VENV)" + rm -rf -- "$(VENV)" + +## --------------------------------------------------------------------------- +## Help +## --------------------------------------------------------------------------- + .PHONY: help help: ## Show this help message - @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n\nTargets:\n"} \ - /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-22s\033[0m %s\n", $$1, $$2 }' \ + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} \ + /^## [A-Z][a-zA-Z]*$$/ { section = substr($$0, 4); next } \ + /^[a-zA-Z_-]+:.*?##/ { \ + if (section != last_section) { \ + printf "\n\033[1m%s\033[0m\n", section; \ + last_section = section; \ + } \ + printf " \033[36m%-22s\033[0m %s\n", $$1, $$2; \ + }' \ $(MAKEFILE_LIST) diff --git a/cardano_node_tests/tests/test_dbsync.py b/cardano_node_tests/tests/test_dbsync.py index a44c0a8d4..fdbeeeb4d 100644 --- a/cardano_node_tests/tests/test_dbsync.py +++ b/cardano_node_tests/tests/test_dbsync.py @@ -259,9 +259,12 @@ def test_blocks(self, cluster: clusterlib.ClusterLib): # noqa: C901 ) raise AssertionError(msg) - # If cardano-node knows about Babbage and network is in Alonzo or higher era, check that - # the highest known protocol major version matches the expected value - if rec and not (rec.proto_major == 8 and rec.proto_minor == 0): + # Check that the highest known protocol major version matches the expected value + protocol_version = cluster.g_query.get_protocol_params()["protocolVersion"] + if rec and not ( + rec.proto_major == protocol_version["major"] + and rec.proto_minor == protocol_version["minor"] + ): pytest.xfail( f"protocol major version: {rec.proto_major}; " f"protocol minor version: {rec.proto_minor}"