test: test-mapping-site-js
cargo test --release
test-mapping-site-js:
node assets/mapping_site/index.test.js
build: test
cargo build --release --features stats
install:
cargo install --path . --force
install-hooks:
git config core.hooksPath .githooks
@echo "pre-push hook enabled (git config core.hooksPath .githooks) - see .githooks/pre-push"
benchmark-optimal:
cargo run --release --features test-fixtures --bin benchmark_optimal_solutions -- --csv
QUALITY_BASELINE := research/data/quality/quality_baseline.txt
BENCH_OUTPUT := target/benchmark_optimal_output.txt
check-quality:
cargo run --release --features test-fixtures --bin benchmark_optimal_solutions | tee $(BENCH_OUTPUT)
@total=$$(grep -m1 '^TOTAL' $(BENCH_OUTPUT) | awk '{print $$2}'); \
baseline_total=$$(grep '^TOTAL_MISMATCHES=' $(QUALITY_BASELINE) | cut -d= -f2); \
ms=$$(grep -oE '[0-9.]+ms/fixture' $(BENCH_OUTPUT) | grep -oE '[0-9.]+'); \
baseline_ms=$$(grep '^MS_PER_FIXTURE=' $(QUALITY_BASELINE) | cut -d= -f2); \
echo ""; \
echo "Quality: TOTAL mismatches = $$total (baseline: $$baseline_total)"; \
echo "Runtime: $$ms ms/fixture (baseline: $$baseline_ms)"; \
if [ "$$total" -gt "$$baseline_total" ]; then \
echo "error: quality regressed - TOTAL mismatches $$total > baseline $$baseline_total" >&2; \
exit 1; \
fi; \
over_2x=$$(awk -v ms="$$ms" -v base="$$baseline_ms" 'BEGIN { print (ms > base * 2) ? 1 : 0 }'); \
if [ "$$over_2x" = "1" ]; then \
echo "warning: runtime is more than 2x the baseline ($$ms ms/fixture vs $$baseline_ms ms/fixture) - investigate before deploying" >&2; \
fi
update-quality-baseline: check-quality
@total=$$(grep -m1 '^TOTAL' $(BENCH_OUTPUT) | awk '{print $$2}'); \
ms=$$(grep -oE '[0-9.]+ms/fixture' $(BENCH_OUTPUT) | grep -oE '[0-9.]+'); \
{ \
echo "# Baseline compared against by \`make check-quality\` / \`make deploy\` - see Makefile."; \
echo "# TOTAL_MISMATCHES: benchmark_optimal_solutions' first TOTAL row (mismatches vs. the"; \
echo "# human-authored ground truth in src/test/data/diffs/) - a hard gate, since this is"; \
echo "# algorithm-only and not machine-dependent: deploy fails if this number goes up."; \
echo "# MS_PER_FIXTURE: benchmark_optimal_solutions' own \"Runtime: ... ms/fixture\" line -"; \
echo "# informational only (a >2x jump warns but doesn't fail deploy), since wall-clock time"; \
echo "# varies by machine."; \
echo "# Update deliberately via \`make update-quality-baseline\` after a reviewed improvement,"; \
echo "# not automatically as a side effect of every deploy."; \
echo "TOTAL_MISMATCHES=$$total"; \
echo "MS_PER_FIXTURE=$$ms"; \
} > $(QUALITY_BASELINE); \
echo "Updated $(QUALITY_BASELINE): TOTAL_MISMATCHES=$$total MS_PER_FIXTURE=$$ms"
deploy-checks:
@if [ -n "$$(git status --porcelain)" ]; then \
echo "error: working tree is dirty - commit or stash before deploying" >&2; \
exit 1; \
fi
git fetch origin main
@if [ "$$(git rev-parse HEAD)" != "$$(git rev-parse origin/main)" ]; then \
echo "error: HEAD does not match origin/main - push your commits first" >&2; \
exit 1; \
fi
$(MAKE) check-quality
deploy-crates: deploy-checks
cargo publish --locked
deploy-github: deploy-checks
$(eval VERSION := $(shell grep -m1 '^version = ' Cargo.toml | sed -E 's/version = "(.*)"/\1/'))
@echo "Tagging and pushing v$(VERSION)..."
git tag v$(VERSION)
git push origin v$(VERSION)
deploy: deploy-crates deploy-github
hermetic-benchmark:
cargo bench --bench diff_code_benchmark
hermetic-benchmark-update-baseline:
cargo bench --bench diff_code_benchmark -- --save-baseline baseline